Display loading indicator for entire application, rather than

individual components.
This commit is contained in:
John Furrow
2016-03-19 20:17:37 +01:00
parent c3d6bee205
commit ff728429d8
13 changed files with 203 additions and 30 deletions
+33
View File
@@ -12,6 +12,7 @@ class UIStoreClass extends BaseStore {
this.activeContextMenu = null;
this.activeModal = null;
this.dependencies = [];
this.latestTorrentLocation = null;
this.torrentDetailsHash = null;
this.torrentDetailsOpen = false;
@@ -63,10 +64,36 @@ class UIStoreClass extends BaseStore {
this.emit(EventTypes.UI_TORRENT_DETAILS_OPEN_CHANGE);
}
hasSatisfiedDependencies() {
return this.dependencies.length === 0;
}
isTorrentDetailsOpen() {
return this.torrentDetailsOpen;
}
registerDependency(ids) {
if (!Array.isArray(ids)) {
ids = [ids];
}
ids.forEach((id) => {
if (this.dependencies.indexOf(id) === -1) {
this.dependencies.push(id);
}
});
}
satisfyDependency(id) {
let dependencyIndex = this.dependencies.indexOf(id);
if (dependencyIndex > -1) {
this.dependencies.splice(dependencyIndex, 1);
}
this.verifyDependencies();
}
setActiveContextMenu(contextMenu = {}) {
this.activeContextMenu = contextMenu;
this.emit(EventTypes.UI_CONTEXT_MENU_CHANGE);
@@ -76,6 +103,12 @@ class UIStoreClass extends BaseStore {
this.activeModal = modal;
this.emit(EventTypes.UI_MODAL_CHANGE);
}
verifyDependencies() {
if (this.dependencies.length === 0) {
this.emit(EventTypes.UI_DEPENDENCIES_LOADED);
}
}
}
let UIStore = new UIStoreClass();