-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification badge to mobile menu icon
Maybe the user count badge will be annoying to have included in the total, probably no one even knows what it’s for… maybe should be a separate indicator.
- Loading branch information
Showing
5 changed files
with
62 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,12 @@ | ||
import { computed } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
import Controller from '@ember/controller'; | ||
|
||
import ObjectProxy from '@ember/object/proxy'; | ||
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin'; | ||
let ObjectPromiseProxy = ObjectProxy.extend(PromiseProxyMixin); | ||
|
||
export default Controller.extend({ | ||
sidebar: service(), | ||
session: service(), | ||
store: service(), | ||
userSocket: service(), | ||
|
||
userCount: computed('userSocket.present.length', function () { | ||
const count = this.get('userSocket.present.length'); | ||
|
||
if (count > 1) { | ||
return count; | ||
} else { | ||
return undefined; | ||
} | ||
}), | ||
|
||
postsRequest: computed(function () { | ||
return ObjectPromiseProxy.create({ | ||
promise: this.get('store').findAll('post').then(posts => { | ||
return { | ||
posts | ||
}; | ||
}) | ||
}); | ||
}), | ||
|
||
unreadCount: computed('[email protected]', function () { | ||
let posts = this.get('postsRequest.posts') | ||
|
||
if (posts) { | ||
return posts.filterBy('unread').length; | ||
} else { | ||
return 0; | ||
} | ||
}), | ||
|
||
actions: { | ||
logout() { | ||
this.get('session').invalidate(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,48 @@ | ||
import Service from '@ember/service'; | ||
import { inject as service } from '@ember/service'; | ||
import { computed } from '@ember/object'; | ||
|
||
import ObjectProxy from '@ember/object/proxy'; | ||
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin'; | ||
let ObjectPromiseProxy = ObjectProxy.extend(PromiseProxyMixin); | ||
|
||
export default Service.extend({ | ||
open: false | ||
store: service(), | ||
userSocket: service(), | ||
|
||
open: false, | ||
|
||
userCount: computed('userSocket.present.length', function () { | ||
const count = this.get('userSocket.present.length'); | ||
|
||
if (count > 1) { | ||
return count; | ||
} else { | ||
return 0; | ||
} | ||
}), | ||
|
||
postsRequest: computed(function () { | ||
return ObjectPromiseProxy.create({ | ||
promise: this.get('store').findAll('post').then(posts => { | ||
return { | ||
posts | ||
}; | ||
}) | ||
}); | ||
}), | ||
|
||
unreadCount: computed('[email protected]', function () { | ||
let posts = this.get('postsRequest.posts') | ||
|
||
if (posts) { | ||
return posts.filterBy('unread').length; | ||
} else { | ||
return 0; | ||
} | ||
}), | ||
|
||
notificationCount: computed('userCount', 'unreadCount', function() { | ||
return this.get('userCount') + this.get('unreadCount'); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters