comparison src/chat.js @ 92:c41e200c3e76

try to fix lost posts
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Mar 2025 15:43:14 -0600
parents 3053a4fc10be
children d0566cc4a2ac
comparison
equal deleted inserted replaced
91:9196d936d4fa 92:c41e200c3e76
176 if( currentChatId ) 176 if( currentChatId )
177 url += `?chat=${currentChatId}`; 177 url += `?chat=${currentChatId}`;
178 ajax(url); 178 ajax(url);
179 } 179 }
180 180
181 function added(html) { 181 function added(html,updated) {
182 let input = document.querySelector('div[input]'); 182 let input = document.querySelector('div[input]');
183 input.insertAdjacentHTML('beforebegin',html); 183 input.insertAdjacentHTML('beforebegin',html);
184 fixPosts(); 184 fixPosts();
185 input.scrollIntoView({block: 'end'}); 185 input.scrollIntoView({block: 'end'});
186 if( document.hasFocus() ) 186 if( document.hasFocus() )
187 active(); 187 active();
188 lastUpdate = updated;
188 } 189 }
189 190
190 function getChats(chatId,updated) { 191 function getChats(chatId,updated) {
191 let first = document.querySelector('div[chat]'); 192 let first = document.querySelector('div[chat]');
192 if( !first || first.getAttribute('chat') !== chatId ) { 193 if( !first || first.getAttribute('chat') !== chatId ) {
193 // console.log('getChats'); 194 // console.log('getChats');
194 ajax('get_chats.js'); 195 ajax('get_chats.js');
196 if( updated )
197 lastUpdate = updated;
195 } else if( first && (currentChatId !== chatId || spy) ) { 198 } else if( first && (currentChatId !== chatId || spy) ) {
196 incUnread(first); 199 incUnread(first);
197 } 200 }
198 if( updated )
199 lastUpdate = updated;
200 if( !document.hasFocus() ) { 201 if( !document.hasFocus() ) {
201 document.title = title + ' *'; 202 document.title = title + ' *';
202 } 203 }
203 } 204 }
204 205