summaryrefslogtreecommitdiffstats
path: root/web/react/utils/async_client.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r--web/react/utils/async_client.jsx54
1 files changed, 46 insertions, 8 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 8cf111d55..88b5aa739 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -55,9 +55,13 @@ export function getChannels(checkVersion) {
var serverVersion = xhr.getResponseHeader('X-Version-ID');
if (serverVersion !== BrowserStore.getLastServerVersion()) {
- BrowserStore.setLastServerVersion(serverVersion);
- window.location.reload(true);
- console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
+ if (!BrowserStore.getLastServerVersion() || BrowserStore.getLastServerVersion() === '') {
+ BrowserStore.setLastServerVersion(serverVersion);
+ } else {
+ BrowserStore.setLastServerVersion(serverVersion);
+ window.location.reload(true);
+ console.log('Detected version update refreshing the page'); //eslint-disable-line no-console
+ }
}
}
@@ -106,10 +110,15 @@ export function getChannel(id) {
);
}
-export function updateLastViewedAt() {
- const channelId = ChannelStore.getCurrentId();
+export function updateLastViewedAt(id) {
+ let channelId;
+ if (id) {
+ channelId = id;
+ } else {
+ channelId = ChannelStore.getCurrentId();
+ }
- if (channelId === null) {
+ if (channelId == null) {
return;
}
@@ -159,8 +168,13 @@ export function getMoreChannels(force) {
}
}
-export function getChannelExtraInfo() {
- const channelId = ChannelStore.getCurrentId();
+export function getChannelExtraInfo(id) {
+ let channelId;
+ if (id) {
+ channelId = id;
+ } else {
+ channelId = ChannelStore.getCurrentId();
+ }
if (channelId != null) {
if (isCallInProgress('getChannelExtraInfo_' + channelId)) {
@@ -731,3 +745,27 @@ export function savePreferences(preferences, success, error) {
}
);
}
+
+export function getSuggestedCommands(command, suggestionId, component) {
+ client.executeCommand(
+ '',
+ command,
+ true,
+ (data) => {
+ // pull out the suggested commands from the returned data
+ const terms = data.suggestions.map((suggestion) => suggestion.suggestion);
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
+ id: suggestionId,
+ matchedPretext: command,
+ terms,
+ items: data.suggestions,
+ component
+ });
+ },
+ (err) => {
+ dispatchError(err, 'getCommandSuggestions');
+ }
+ );
+}