summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-06-06 10:46:09 -0300
committerHarrison Healey <harrisonmhealey@gmail.com>2016-06-06 09:46:09 -0400
commit6cee1f87f2361f3c4b431190ae2df2b12a2157ef (patch)
tree8ca1e5798baf0aa6a046b37b59d7b50751342c60 /webapp
parent6ab893dcba2dc45f9dd34546b1a1b5d7604c1a7f (diff)
downloadchat-6cee1f87f2361f3c4b431190ae2df2b12a2157ef.tar.gz
chat-6cee1f87f2361f3c4b431190ae2df2b12a2157ef.tar.bz2
chat-6cee1f87f2361f3c4b431190ae2df2b12a2157ef.zip
PLT-2990 Clicking on a desktop notification from another team opens the team (#3253)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/stores/notification_store.jsx9
-rw-r--r--webapp/stores/team_store.jsx9
-rw-r--r--webapp/utils/utils.jsx6
3 files changed, 18 insertions, 6 deletions
diff --git a/webapp/stores/notification_store.jsx b/webapp/stores/notification_store.jsx
index 202b24432..5935b876b 100644
--- a/webapp/stores/notification_store.jsx
+++ b/webapp/stores/notification_store.jsx
@@ -32,6 +32,7 @@ class NotificationStoreClass extends EventEmitter {
if (msgProps.mentions) {
mentions = JSON.parse(msgProps.mentions);
}
+ const teamId = msgProps.team_id;
const channel = ChannelStore.get(post.channel_id);
const user = UserStore.getCurrentUser();
@@ -67,14 +68,14 @@ class NotificationStoreClass extends EventEmitter {
if (notifyText.length === 0) {
if (msgProps.image) {
- Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'), channel);
+ Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'), channel, teamId);
} else if (msgProps.otherFile) {
- Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'), channel);
+ Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'), channel, teamId);
} else {
- Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.something', ' did something new'), channel);
+ Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.something', ' did something new'), channel, teamId);
}
} else {
- Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText, channel);
+ Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText, channel, teamId);
}
if (!user.notify_props || user.notify_props.desktop_sound === 'true') {
Utils.ding();
diff --git a/webapp/stores/team_store.jsx b/webapp/stores/team_store.jsx
index 210d5c211..f4d60ba74 100644
--- a/webapp/stores/team_store.jsx
+++ b/webapp/stores/team_store.jsx
@@ -109,6 +109,15 @@ class TeamStoreClass extends EventEmitter {
return '';
}
+ getTeamUrl(id) {
+ const team = this.get(id);
+ if (team) {
+ return getWindowLocationOrigin() + '/' + team.name;
+ }
+
+ return null;
+ }
+
saveTeam(team) {
this.teams[team.id] = team;
}
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index e4e3370db..fdce93ef0 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -119,7 +119,7 @@ export function getCookie(name) {
var requestedNotificationPermission = false;
-export function notifyMe(title, body, channel) {
+export function notifyMe(title, body, channel, teamId) {
if (!('Notification' in window)) {
return;
}
@@ -134,7 +134,9 @@ export function notifyMe(title, body, channel) {
notification.onclick = () => {
window.focus();
if (channel) {
- browserHistory.push(getTeamURLNoOriginFromAddressBar() + '/channels/' + channel.name);
+ browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/' + channel.name);
+ } else if (teamId) {
+ browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/town-square');
} else {
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
}