Mercurial Hosting > chat
changeset 111:37ab261aee7b default tip
notify fix
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 16 Sep 2025 00:01:53 -0600 |
parents | d2637760cd00 |
children | |
files | src/chat.js src/heartbeat.js.luan |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/chat.js Mon Sep 15 13:29:10 2025 -0600 +++ b/src/chat.js Tue Sep 16 00:01:53 2025 -0600 @@ -284,7 +284,7 @@ } function heartbeat() { - let url = `heartbeat.js?last_update=${lastUpdate}`; + let url = `heartbeat.js?last_update=${lastUpdate}&focus=${document.hasFocus()}`; if( currentChatId ) url += `&chat=${currentChatId}`; ajax(url);
--- a/src/heartbeat.js.luan Mon Sep 15 13:29:10 2025 -0600 +++ b/src/heartbeat.js.luan Tue Sep 16 00:01:53 2025 -0600 @@ -20,6 +20,8 @@ local get_online = Online.get or error() local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() +local Notify = require "site:/lib/Notify.luan" +local notify_active = Notify.active or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "heartbeat.js" @@ -47,6 +49,11 @@ return end + local focus = Http.request.parameters.focus or error() + if focus == "true" then + notify_active(user) + end + local online = get_online(user) %> online = <%=json_string(online,compressed)%>;