]> cat aescling's git repositories - mastodon.git/commitdiff
Focus tab of Mastodon when clicking notification (#2989)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Thu, 11 May 2017 11:34:05 +0000 (20:34 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 11 May 2017 11:34:05 +0000 (13:34 +0200)
app/javascript/mastodon/actions/notifications.js

index 1be4ae3a119ad8a0588363886f9edc9d75d04480..bb494924daeb69256bc4bd1d26924afc3bd25709 100644 (file)
@@ -50,7 +50,11 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
       const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
       const body  = (notification.status && notification.status.spoiler_text.length > 0) ? unescapeHTML(notification.status.spoiler_text) : unescapeHTML(notification.status ? notification.status.content : '');
 
-      new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
+      const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
+      notify.addEventListener('click', () => {
+        window.focus();
+        notify.close();
+      });
     }
   };
 };