diff options
author | metamuffin <metamuffin@disroot.org> | 2022-09-10 18:34:37 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-09-10 18:34:37 +0200 |
commit | 0fe8df550d95926aca1607e6f9ef7ac8cb929adf (patch) | |
tree | 6a9b9da6f246d003688ab68ba1064fd779013063 /client-web/source/chat.ts | |
parent | f268bd2087fbfb57b8504becf364a00ddebde075 (diff) | |
download | keks-meet-0fe8df550d95926aca1607e6f9ef7ac8cb929adf.tar keks-meet-0fe8df550d95926aca1607e6f9ef7ac8cb929adf.tar.bz2 keks-meet-0fe8df550d95926aca1607e6f9ef7ac8cb929adf.tar.zst |
notifications
Diffstat (limited to 'client-web/source/chat.ts')
-rw-r--r-- | client-web/source/chat.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/client-web/source/chat.ts b/client-web/source/chat.ts index e08437b..5776df4 100644 --- a/client-web/source/chat.ts +++ b/client-web/source/chat.ts @@ -1,6 +1,7 @@ import { ChatMessage } from "../../common/packets.d.ts"; -import { ediv, espan, image_view, OverlayUi } from "./helper.ts"; +import { ediv, espan, image_view, notify, OverlayUi } from "./helper.ts"; import { log } from "./logger.ts"; +import { PREFS } from "./preferences/mod.ts"; import { Room } from "./room.ts"; import { User } from "./user/mod.ts"; @@ -60,14 +61,10 @@ export class Chat extends OverlayUi { espan(sender.display_name, { class: "author" }), ": ", ...els )) this.shown = true - this.notify(sender, message) - } - notify(sender: User, message: ChatMessage) { - if (sender.local || document.hasFocus()) return - if (Notification.permission != "granted") return - let body = "(empty message)" - if (message.text) body = message.text - if (message.image) body = "(image)" - new Notification(`keks-meet: ${sender.display_name}`, { body }) + + let body_str = "(empty message)" + if (message.text) body_str = message.text + if (message.image) body_str = "(image)" + if (!sender.local && PREFS.notify_chat) notify(body_str, sender.display_name) } } |