A platform for community discussion. Free, open, simple.
Revert "FEATURE: Service to track message bus connectivity + offline indicator(#21259)" (#21282)
Mark VanLandingham3527fbcd8e30
diff --git a/app/assets/javascripts/discourse/app/components/offline-indicator.hbs b/app/assets/javascripts/discourse/app/components/offline-indicator.hbsdeleted file mode 100644index ee53efd7aeb..00000000000--- a/app/assets/javascripts/discourse/app/components/offline-indicator.hbs+++ /dev/null@@ -1,10 +0,0 @@-{{#if this.showing}}- <div class="offline-indicator">- <span>{{i18n "offline_indicator.no_internet"}}</span>- <DButton- @label="offline_indicator.refresh_page"- @display="link"- @action={{this.refresh}}- />- </div>-{{/if}}\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/offline-indicator.js b/app/assets/javascripts/discourse/app/components/offline-indicator.jsdeleted file mode 100644index 3a6edebe7a3..00000000000--- a/app/assets/javascripts/discourse/app/components/offline-indicator.js+++ /dev/null@@ -1,16 +0,0 @@-import Component from "@glimmer/component";-import { action } from "@ember/object";-import { inject as service } from "@ember/service";--export default class OfflineIndicator extends Component {- @service messageBusConnectivity;-- get showing() {- return !this.messageBusConnectivity.connected;- }-- @action- refresh() {- window.location.reload(true);- }-}diff --git a/app/assets/javascripts/discourse/app/initializers/message-bus.js b/app/assets/javascripts/discourse/app/initializers/message-bus.jsindex 8c66934a492..8eb790749df 100644--- a/app/assets/javascripts/discourse/app/initializers/message-bus.js+++ b/app/assets/javascripts/discourse/app/initializers/message-bus.js@@ -5,14 +5,23 @@ import { handleLogoff } from "discourse/lib/ajax";import userPresent, { onPresenceChange } from "discourse/lib/user-presence";const LONG_POLL_AFTER_UNSEEN_TIME = 1200000; // 20 minutes+const CONNECTIVITY_ERROR_CLASS = "message-bus-offline";-function ajax(opts, messageBusConnectivity) {+function updateConnectivityIndicator(stat) {+ if (stat === "error") {+ document.documentElement.classList.add(CONNECTIVITY_ERROR_CLASS);+ } else {+ document.documentElement.classList.remove(CONNECTIVITY_ERROR_CLASS);+ }+}++function ajax(opts) {if (opts.complete) {const oldComplete = opts.complete;opts.complete = function (xhr, stat) {handleLogoff(xhr);oldComplete(xhr, stat);- messageBusConnectivity.setConnectivity(stat !== "error");+ updateConnectivityIndicator(stat);};} else {opts.complete = handleLogoff;@@ -33,10 +42,7 @@ export default {const messageBus = container.lookup("service:message-bus"),user = container.lookup("service:current-user"),- siteSettings = container.lookup("service:site-settings"),- messageBusConnectivity = container.lookup(- "service:message-bus-connectivity"- );+ siteSettings = container.lookup("service:site-settings");messageBus.alwaysLongPoll = !isProduction();messageBus.shouldLongPollCallback = () =>@@ -91,7 +97,7 @@ export default {if (userPresent()) {opts.headers["Discourse-Present"] = "true";}- return ajax(opts, messageBusConnectivity);+ return ajax(opts);};} else {messageBus.ajax = function (opts) {@@ -99,7 +105,7 @@ export default {if (userPresent()) {opts.headers["Discourse-Present"] = "true";}- return ajax(opts, messageBusConnectivity);+ return ajax(opts);};messageBus.baseUrl = getURL("/");diff --git a/app/assets/javascripts/discourse/app/services/message-bus-connectivity.js b/app/assets/javascripts/discourse/app/services/message-bus-connectivity.jsdeleted file mode 100644index 876ecb34e99..00000000000--- a/app/assets/javascripts/discourse/app/services/message-bus-connectivity.js+++ /dev/null@@ -1,16 +0,0 @@-import Service from "@ember/service";-import { tracked } from "@glimmer/tracking";--const CONNECTIVITY_ERROR_CLASS = "message-bus-offline";--export default class MessageBusConnectivity extends Service {- @tracked connected = true;-- setConnectivity(connected) {- this.connected = connected;- document.documentElement.classList.toggle(- CONNECTIVITY_ERROR_CLASS,- !connected- );- }-}diff --git a/app/assets/javascripts/discourse/app/templates/application.hbs b/app/assets/javascripts/discourse/app/templates/application.hbsindex 623f253f224..2c6d11c0e4a 100644--- a/app/assets/javascripts/discourse/app/templates/application.hbs+++ b/app/assets/javascripts/discourse/app/templates/application.hbs@@ -24,7 +24,6 @@{{/if}}<SoftwareUpdatePrompt />- <OfflineIndicator /><PluginOutlet@name="below-site-header"diff --git a/app/assets/stylesheets/common/components/_index.scss b/app/assets/stylesheets/common/components/_index.scssindex f5a3a14717f..bd9a319233c 100644--- a/app/assets/stylesheets/common/components/_index.scss+++ b/app/assets/stylesheets/common/components/_index.scss@@ -22,7 +22,6 @@@import "ignored-user-list";@import "keyboard_shortcuts";@import "navs";-@import "offline-indicator";@import "pick-files-button";@import "relative-time-picker";@import "share-and-invite-modal";diff --git a/app/assets/stylesheets/common/components/offline-indicator.scss b/app/assets/stylesheets/common/components/offline-indicator.scssdeleted file mode 100644index f2a19795faa..00000000000--- a/app/assets/stylesheets/common/components/offline-indicator.scss+++ /dev/null@@ -1,10 +0,0 @@-.offline-indicator {- position: fixed;- top: var(--header-offset);- left: 50%;- transform: translate(-50%, 0);- padding: 0.5em 1em;- background-color: var(--primary-very-low);- border-radius: var(--d-nav-pill-border-radius);- z-index: z("header") - 10;-}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex ed5a76e4b18..86427f2212b 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -2065,10 +2065,6 @@ en:intro: "Hello! Looks like you’re enjoying the discussion, but you haven’t signed up for an account yet."value_prop: "Tired of scrolling through the same posts? When you create an account you’ll always come back to where you left off. With an account you can also be notified of new replies, save bookmarks, and use likes to thank others. We can all work together to make this community great. :heart:"- offline_indicator:- no_internet: "No internet connection."- refresh_page: "Refresh page"-summary:enabled_description: "You're viewing a summary of this topic: the most interesting posts as determined by the community."description:diff --git a/spec/system/network_disconnected_spec.rb b/spec/system/network_disconnected_spec.rbdeleted file mode 100644index f5ec3067903..00000000000--- a/spec/system/network_disconnected_spec.rb+++ /dev/null@@ -1,27 +0,0 @@-# frozen_string_literal: true--RSpec.describe "Network Disconnected", type: :system, js: true do- fab!(:current_user) { Fabricate(:user) }-- def with_network_disconnected- page.driver.browser.network_conditions = { offline: true }- yield- page.driver.browser.network_conditions = { offline: false }- end-- it "Message bus connectivity service adds class to DOM and displays offline indicator" do- sign_in(current_user)- visit("/c")-- expect(page).to have_no_css("html.message-bus-offline")- expect(page).to have_no_css(".offline-indicator")-- with_network_disconnected do- # Message bus connectivity services adds the disconnected class to the DOM- expect(page).to have_css("html.message-bus-offline")-- # Offline indicator is rendered- expect(page).to have_css(".offline-indicator")- end- end-end