PERF: Avoid rendering a component that isn't required most of the time (#21942)

What is this change required?

The `enable_offline_indicator` site setting is disabled by default so
there is no need for us to be rendering an extra Ember component when
the site setting is not enabled.
This commit is contained in:
Alan Guo Xiang Tan 2023-06-07 07:23:19 +09:00 committed by GitHub
parent 1cbc65ba79
commit f682071ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -4,13 +4,9 @@ import { inject as service } from "@ember/service";
export default class OfflineIndicator extends Component {
@service messageBusConnectivity;
@service siteSettings;
get showing() {
return (
this.siteSettings.enable_offline_indicator &&
!this.messageBusConnectivity.connected
);
return !this.messageBusConnectivity.connected;
}
@action

View File

@ -8,6 +8,7 @@ export default class MessageBusConnectivity extends Service {
setConnectivity(connected) {
this.connected = connected;
document.documentElement.classList.toggle(
CONNECTIVITY_ERROR_CLASS,
!connected

View File

@ -24,7 +24,10 @@
{{/if}}
<SoftwareUpdatePrompt />
<OfflineIndicator />
{{#if this.siteSettings.enable_offline_indicator}}
<OfflineIndicator />
{{/if}}
<PluginOutlet
@name="below-site-header"