Skip to content

Commit

Permalink
fix: proper reload of ext data
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Sep 25, 2020
1 parent b74c856 commit 8679bf5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/directives/views/componentView.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RootScopeMessages } from './../../messages';
import { WebApplication } from '@/ui_models/application';
import { SNComponent, ComponentAction, LiveItem } from 'snjs';
import { WebDirective } from './../../types';
Expand Down Expand Up @@ -199,7 +200,7 @@ class ComponentViewCtrl implements ComponentViewScope {
this.error = undefined;
}
if (this.expired && doManualReload) {
this.$rootScope.$broadcast('reload-ext-dat');
this.$rootScope.$broadcast(RootScopeMessages.ReloadExtendedData);
}
}

Expand Down
4 changes: 4 additions & 0 deletions app/assets/javascripts/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum RootScopeMessages {
ReloadExtendedData = 'reload-ext-data',
NewUpdateAvailable = 'new-update-available'
}
3 changes: 2 additions & 1 deletion app/assets/javascripts/views/application/application_view.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RootScopeMessages } from './../../messages';
import { WebDirective } from '@/types';
import { getPlatformString } from '@/utils';
import template from './application-view.pug';
Expand Down Expand Up @@ -82,7 +83,7 @@ class ApplicationViewCtrl extends PureViewCtrl {
}

onUpdateAvailable() {
this.$rootScope!.$broadcast('new-update-available');
this.$rootScope!.$broadcast(RootScopeMessages.NewUpdateAvailable);
};

/** @override */
Expand Down
5 changes: 3 additions & 2 deletions app/assets/javascripts/views/footer/footer_view.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RootScopeMessages } from './../../messages';
import { ApplicationGroup } from '@/ui_models/application_group';
import { FooterStatus, WebDirective } from '@/types';
import { dateToLocalizedString, preventRefreshing } from '@/utils';
Expand Down Expand Up @@ -171,10 +172,10 @@ class FooterViewCtrl extends PureViewCtrl<{}, {
}

addRootScopeListeners() {
this.rootScopeListener1 = this.$rootScope.$on("reload-ext-data", () => {
this.rootScopeListener1 = this.$rootScope.$on(RootScopeMessages.ReloadExtendedData, () => {
this.reloadExtendedData();
});
this.rootScopeListener2 = this.$rootScope.$on("new-update-available", () => {
this.rootScopeListener2 = this.$rootScope.$on(RootScopeMessages.NewUpdateAvailable, () => {
this.$timeout(() => {
this.onNewUpdateAvailable();
});
Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/directives/component-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.sk-p
| Extensions are in a read-only state.
.right
.sk-app-bar-item(ng-click='ctrl.reloadIframe()')
.sk-app-bar-item(ng-click='ctrl.reloadStatus(true)')
.sk-button.info
.sk-label Reload
.sk-app-bar-item
Expand Down
4 changes: 4 additions & 0 deletions dist/@types/app/assets/javascripts/messages.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare enum RootScopeMessages {
ReloadExtendedData = "reload-ext-data",
NewUpdateAvailable = "new-update-available"
}

0 comments on commit 8679bf5

Please sign in to comment.