mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 16:24:55 +00:00
FEATURE: Enable experimental Badging API (#7173)
This commit is contained in:
parent
d6d71de855
commit
fb8bcd7469
19
app/assets/javascripts/discourse/initializers/badging.js.es6
Normal file
19
app/assets/javascripts/discourse/initializers/badging.js.es6
Normal file
@ -0,0 +1,19 @@
|
||||
// Updates the PWA badging if avaliable
|
||||
export default {
|
||||
name: "badging",
|
||||
after: "message-bus",
|
||||
|
||||
initialize(container) {
|
||||
const appEvents = container.lookup("app-events:main");
|
||||
const user = container.lookup("current-user:main");
|
||||
|
||||
if (!user) return; // must be logged in
|
||||
if (!window.ExperimentalBadge) return; // must have the Badging API
|
||||
|
||||
appEvents.on("notifications:changed", () => {
|
||||
let notifications =
|
||||
user.get("unread_notifications") + user.get("unread_private_messages");
|
||||
window.ExperimentalBadge.set(notifications);
|
||||
});
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user