diff options
author | Lauri Ojansivu <x@xet7.org> | 2020-04-02 01:09:35 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2020-04-02 01:09:35 +0300 |
commit | e34f240c35b6eaec3e3ac2830129ddf914de5feb (patch) | |
tree | 9185e821c0e24cd1c9ae55da416d30b974035c31 /client/components/notifications/notifications.js | |
parent | 56667112d7fd146a9847794207e9a2224b1115d7 (diff) | |
parent | 8ea86ae0b9e4351b935fde45c77f37d09778739d (diff) | |
download | wekan-e34f240c35b6eaec3e3ac2830129ddf914de5feb.tar.gz wekan-e34f240c35b6eaec3e3ac2830129ddf914de5feb.tar.bz2 wekan-e34f240c35b6eaec3e3ac2830129ddf914de5feb.zip |
Merge branch 'jtbairdsr-master'
Diffstat (limited to 'client/components/notifications/notifications.js')
-rw-r--r-- | client/components/notifications/notifications.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/client/components/notifications/notifications.js b/client/components/notifications/notifications.js new file mode 100644 index 00000000..c0aa6cb5 --- /dev/null +++ b/client/components/notifications/notifications.js @@ -0,0 +1,32 @@ +// this hides the notifications drawer if anyone clicks off of the panel +Template.body.events({ + click(event) { + if ( + !$(event.target).is('#notifications *') && + Session.get('showNotificationsDrawer') + ) { + toggleNotificationsDrawer(); + } + }, +}); + +Template.notifications.helpers({ + unreadNotifications() { + const notifications = Users.findOne(Meteor.userId()).notifications(); + const unreadNotifications = _.filter(notifications, v => !v.read); + return unreadNotifications.length; + }, +}); + +Template.notifications.events({ + 'click .notifications-drawer-toggle'() { + toggleNotificationsDrawer(); + }, +}); + +export function toggleNotificationsDrawer() { + Session.set( + 'showNotificationsDrawer', + !Session.get('showNotificationsDrawer'), + ); +} |