@@ -331,7 +331,6 @@ class HTMLChatApp {
331331 } ) ;
332332
333333 // Block browser's contextmenu (system) on this element on all platforms
334- // (it does show up if you hold for longer (must mean I'm doing something wrong haha, but not complaining))
335334 target . addEventListener ( 'contextmenu' , function ( e ) {
336335 e . preventDefault ( ) ;
337336 } ) ;
@@ -514,6 +513,10 @@ class HTMLChatApp {
514513
515514 async fetchMessages ( forceRefresh = false ) {
516515 try {
516+ // Check for new messages for notifications and update stored message IDs
517+ // Load last message time (default 0 for first load)
518+ const lastMessageTime = await this . loadFromStorage ( `htmlchat_${ this . elements . roomSelect . value } _last_time` ) || 0 ;
519+
517520 if ( ! forceRefresh ) {
518521 const cached = this . loadFromStorage (
519522 `htmlchat_${ this . elements . roomSelect . value } `
@@ -556,10 +559,6 @@ class HTMLChatApp {
556559 console . log ( 'Server moderator status:' , this . serverIsModerator ) ;
557560 }
558561
559- // Check for new messages for notifications and update stored message IDs
560- // Load last message time (default 0 for first load)
561- const lastMessageTime = this . loadFromStorage ( `htmlchat_${ this . elements . roomSelect . value } _last_time` ) || 0 ;
562-
563562 // Check for new messages after initial load
564563 if ( ! this . initialLoad && messages . length > 0 ) {
565564 const latestTime = Math . max ( ...messages . map ( m => m . time || 0 ) ) ;
@@ -584,11 +583,6 @@ class HTMLChatApp {
584583 // Mark as loaded
585584 this . initialLoad = false ;
586585
587- this . saveToStorage (
588- `htmlchat_${ this . elements . roomSelect . value } _count` ,
589- messages . length
590- ) ;
591-
592586 // Store messages with proper IDs for deletion
593587 if ( this . messageRenderer ) {
594588 this . elements . chatBox . innerHTML =
0 commit comments