summaryrefslogtreecommitdiffstats
path: root/webapp/stores
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/stores')
-rw-r--r--webapp/stores/browser_store.jsx6
-rw-r--r--webapp/stores/integration_store.jsx9
-rw-r--r--webapp/stores/notification_store.jsx22
-rw-r--r--webapp/stores/post_store.jsx6
-rw-r--r--webapp/stores/search_store.jsx19
-rw-r--r--webapp/stores/team_store.jsx4
6 files changed, 59 insertions, 7 deletions
diff --git a/webapp/stores/browser_store.jsx b/webapp/stores/browser_store.jsx
index 99aebc466..fcd177662 100644
--- a/webapp/stores/browser_store.jsx
+++ b/webapp/stores/browser_store.jsx
@@ -203,7 +203,11 @@ class BrowserStoreClass {
}
hasSeenLandingPage() {
- return JSON.parse(sessionStorage.getItem('__landingPageSeen__'));
+ if (this.isLocalStorageSupported()) {
+ return JSON.parse(sessionStorage.getItem('__landingPageSeen__'));
+ }
+
+ return true;
}
setLandingPageSeen(landingPageSeen) {
diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx
index 33680452b..ae818b443 100644
--- a/webapp/stores/integration_store.jsx
+++ b/webapp/stores/integration_store.jsx
@@ -137,6 +137,15 @@ class IntegrationStore extends EventEmitter {
this.setCommands(teamId, commands);
}
+ editCommand(command) {
+ const teamId = command.team_id;
+ const commands = this.getCommands(teamId);
+
+ commands.push(command);
+
+ this.setCommands(teamId, commands);
+ }
+
updateCommand(command) {
const teamId = command.team_id;
const commands = this.getCommands(teamId);
diff --git a/webapp/stores/notification_store.jsx b/webapp/stores/notification_store.jsx
index dc707b50e..d5e8acb4d 100644
--- a/webapp/stores/notification_store.jsx
+++ b/webapp/stores/notification_store.jsx
@@ -26,6 +26,9 @@ class NotificationStoreClass extends EventEmitter {
removeChangeListener(callback) {
this.removeListener(CHANGE_EVENT, callback);
}
+ setFocus(focus) {
+ this.inFocus = focus;
+ }
handleRecievedPost(post, msgProps) {
// Send desktop notification
@@ -98,11 +101,21 @@ class NotificationStoreClass extends EventEmitter {
duration = parseInt(user.notify_props.desktop_duration, 10) * 1000;
}
+ //Play a sound if explicitly set in settings
const sound = !user.notify_props || user.notify_props.desktop_sound === 'true';
- Utils.notifyMe(title, body, channel, teamId, duration, !sound);
- if (sound && !UserAgent.isWindowsApp() && !UserAgent.isMacApp()) {
- Utils.ding();
+ // Notify if you're not looking in the right channel or when
+ // the window itself is not active
+ const activeChannel = ChannelStore.getCurrent();
+ const notify = activeChannel.id !== channel.id || !this.inFocus;
+
+ if (notify) {
+ Utils.notifyMe(title, body, channel, teamId, duration, !sound);
+
+ //Don't add extra sounds on native desktop clients
+ if (sound && !UserAgent.isWindowsApp() && !UserAgent.isMacApp() && !UserAgent.isMobileApp()) {
+ Utils.ding();
+ }
}
}
}
@@ -118,6 +131,9 @@ NotificationStore.dispatchToken = AppDispatcher.register((payload) => {
NotificationStore.handleRecievedPost(action.post, action.websocketMessageProps);
NotificationStore.emitChange();
break;
+ case ActionTypes.BROWSER_CHANGE_FOCUS:
+ NotificationStore.setFocus(action.focus);
+ break;
}
});
diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx
index a4e49fc98..fbe5cd457 100644
--- a/webapp/stores/post_store.jsx
+++ b/webapp/stores/post_store.jsx
@@ -245,7 +245,7 @@ class PostStoreClass extends EventEmitter {
this.postsInfo[id].postList = combinedPosts;
}
- storePost(post) {
+ storePost(post, isNewPost = false) {
const postList = makePostListNonNull(this.getAllPosts(post.channel_id));
if (post.pending_post_id !== '') {
@@ -255,7 +255,7 @@ class PostStoreClass extends EventEmitter {
post.pending_post_id = '';
postList.posts[post.id] = post;
- if (postList.order.indexOf(post.id) === -1) {
+ if (isNewPost && postList.order.indexOf(post.id) === -1) {
postList.order.unshift(post.id);
}
@@ -629,7 +629,7 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
PostStore.emitChange();
break;
case ActionTypes.RECEIVED_POST:
- PostStore.storePost(action.post);
+ PostStore.storePost(action.post, true);
PostStore.emitChange();
break;
case ActionTypes.RECEIVED_EDIT_POST:
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index d1458ceed..46a086ddb 100644
--- a/webapp/stores/search_store.jsx
+++ b/webapp/stores/search_store.jsx
@@ -96,6 +96,21 @@ class SearchStoreClass extends EventEmitter {
this.isMentionSearch = isMentionSearch;
this.isFlaggedPosts = isFlaggedPosts;
}
+
+ deletePost(post) {
+ const results = this.getSearchResults();
+ if (results == null) {
+ return;
+ }
+
+ if (post.id in results.posts) {
+ // make sure to copy the post so that component state changes work properly
+ results.posts[post.id] = Object.assign({}, post, {
+ state: Constants.POST_DELETED,
+ file_ids: []
+ });
+ }
+ }
}
var SearchStore = new SearchStoreClass();
@@ -115,6 +130,10 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => {
case ActionTypes.SHOW_SEARCH:
SearchStore.emitShowSearch();
break;
+ case ActionTypes.POST_DELETED:
+ SearchStore.deletePost(action.post);
+ SearchStore.emitSearchChange();
+ break;
default:
}
});
diff --git a/webapp/stores/team_store.jsx b/webapp/stores/team_store.jsx
index 858e2688e..7775a4a3a 100644
--- a/webapp/stores/team_store.jsx
+++ b/webapp/stores/team_store.jsx
@@ -265,6 +265,10 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
TeamStore.appendMyTeamMember(action.member);
TeamStore.emitChange();
break;
+ case ActionTypes.UPDATE_TEAM:
+ TeamStore.saveTeam(action.team);
+ TeamStore.emitChange();
+ break;
case ActionTypes.RECEIVED_ALL_TEAMS:
TeamStore.saveTeams(action.teams);
TeamStore.emitChange();