changeset 77:624654817f99

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Mar 2025 19:29:41 -0600
parents 4dfe5af67f91
children 2a602ef53eef
files src/active.js.luan src/added.js.luan src/chat.js
diffstat 3 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/active.js.luan	Sun Mar 09 18:45:39 2025 -0600
+++ b/src/active.js.luan	Sun Mar 09 19:29:41 2025 -0600
@@ -1,11 +1,20 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local Http = require "luan:http/Http.luan"
 local User = require "site:/lib/User.luan"
 local current_user = User.current or error()
 local Notify = require "site:/lib/Notify.luan"
+local remove_notify = Notify.remove or error()
+local Chat = require "site:/lib/Chat.luan"
+local get_chat_by_id = Chat.get_by_id or error()
 
 
 return function()
 	local user = current_user() or error()
-	Notify.remove(user)
+	remove_notify(user)
+	local chat = Http.request.parameters.chat
+	if chat ~= nil then
+		chat = get_chat_by_id(chat) or error()
+		chat.read(user)
+	end
 end
--- a/src/added.js.luan	Sun Mar 09 18:45:39 2025 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-local Luan = require "luan:Luan.luan"
-local error = Luan.error
-local Http = require "luan:http/Http.luan"
-local User = require "site:/lib/User.luan"
-local current_user = User.current or error()
-local Chat = require "site:/lib/Chat.luan"
-local get_chat_by_id = Chat.get_by_id or error()
-
-
-return function()
-	local user = current_user() or error()
-	local chat = Http.request.parameters.chat or error()
-	chat = get_chat_by_id(chat) or error()
-	chat.read(user)
-end
--- a/src/chat.js	Sun Mar 09 18:45:39 2025 -0600
+++ b/src/chat.js	Sun Mar 09 19:29:41 2025 -0600
@@ -148,14 +148,20 @@
 	}
 }
 
+function active() {
+	let url = 'active.js';
+	if( currentChatId )
+		url += `?chat=${currentChatId}`;
+	ajax(url);
+}
+
 function added(html) {
 	let input = document.querySelector('div[input]');
 	input.insertAdjacentHTML('beforebegin',html);
 	fixPosts();
 	input.scrollIntoView({block: 'end'});
-	ajax(`added.js?chat=${currentChatId}`);
 	if( document.hasFocus() )
-		ajax('active.js');
+		active();
 }
 
 function getChats(chatId,updated) {
@@ -191,7 +197,7 @@
 window.onfocus = function() {
 	// console.log('onfocus');
 	document.title = title;
-	ajax('active.js');
+	active();
 };
 
 let urlRegex = /(^|\s)(https?:\/\/\S+)/g;