summaryrefslogtreecommitdiffstats
path: root/client/components/notifications/notifications.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2020-04-02 01:09:35 +0300
committerLauri Ojansivu <x@xet7.org>2020-04-02 01:09:35 +0300
commite34f240c35b6eaec3e3ac2830129ddf914de5feb (patch)
tree9185e821c0e24cd1c9ae55da416d30b974035c31 /client/components/notifications/notifications.js
parent56667112d7fd146a9847794207e9a2224b1115d7 (diff)
parent8ea86ae0b9e4351b935fde45c77f37d09778739d (diff)
downloadwekan-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.js32
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'),
+ );
+}