_updateLoadingState: function(channel) { logger.debug("Update channel state", channel); if(channel) { this.channels[channel.name].isReady = !channel.state.loading && !channel.state.syncing; this.channels[channel.name].loading = channel.state.loading; this.channels[channel.name].syncing = channel.state.syncing; if(channel.state.loading) { UIActions.startLoading(channel.name, "loadhistory", "Connecting..."); if(this.connectTimeout[channel.name]) clearTimeout(this.connectTimeout[channel.name]); this.connectTimeout[channel.name] = setTimeout(() => { UIActions.startLoading(channel.name, "loadhistory", `Connecting to the channel is taking a long time. This usually means connection problems with the network.`); }, 10000); } else { clearTimeout(this.connectTimeout[channel.name]); delete this.connectTimeout[channel.name]; UIActions.stopLoading(channel.name, "loadhistory"); } if(channel.state.syncing > 0 && !this.syncTimeout[channel.name]) { logger.debug("Syncing"); UIActions.startLoading(channel.name, "sync", "Syncing..."); if(this.syncTimeout[channel.name]) clearTimeout(this.syncTimeout[channel.name]); this.syncTimeout[channel.name] = setTimeout(() => { UIActions.startLoading(channel.name, "synctimeout", "Syncing is taking a long time. This usually means connection problems with the network."); }, 10000); } else { logger.debug("Clear"); clearTimeout(this.syncTimeout[channel.name]); delete this.syncTimeout[channel.name]; UIActions.stopLoading(channel.name, "sync"); UIActions.stopLoading(channel.name, "synctimeout"); } } },
.then((post) => { logger.debug("Sent:", post); UIActions.stopLoading(channel, "send"); })
.then((post) => UIActions.stopLoading(channel, "file"))
.then((messages) => { this._addMessages(channel, messages, olderThanHash !== null); this.channels[channel].loading = false; UIActions.stopLoading(channel, "loadmessages"); })