Fossil SCM

/chat: when tapping on a #NNNN reference, if the referred-to message is not loaded in the local history then search the chat history for message #NNNN.

stephan 2024-07-06 09:33 markdown-tagrefs
Commit 347084af906fd210f18811f618be02c133482a68fc8e51bae5abdf32f8c7ced7
1 file changed +11 -10
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1016,17 +1016,17 @@
10161016
while(e && !e.classList.contains(className)){
10171017
e = e.parentNode;
10181018
}
10191019
return e;
10201020
};
1021
-
1021
+
10221022
/** To be passed each MessageWidget's top-level DOM element
10231023
after initial processing of the message, to set up
10241024
hashtag and numtag references. */
10251025
const setupHashtags = function f(elem){
1026
- if(!f.$click){
1027
- f.$click = function(ev){
1026
+ if(!f.$clickTag){
1027
+ f.$clickTag = function(ev){
10281028
/* Click handler for hashtags */
10291029
const tag = ev.target.dataset.hashtag;
10301030
if(tag){
10311031
Chat.setHashtagFilter(
10321032
tag===Chat.filter.hashtag.activeTag
@@ -1051,18 +1051,18 @@
10511051
const rc = window.history.pushState(state, "");
10521052
//console.debug("Pushing history for msgid", state);
10531053
//console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack);
10541054
}
10551055
}else{
1056
- F.toast.warning("Message #"+tag+" not found in loaded messages.");
1056
+ Chat.submitSearch('#'+tag);
10571057
}
10581058
}
10591059
};
10601060
}
10611061
elem.querySelectorAll('[data-hashtag]').forEach(function(e){
10621062
e.dataset.hashtag = e.dataset.hashtag.toLowerCase();
1063
- e.addEventListener('click', f.$click, false);
1063
+ e.addEventListener('click', f.$clickTag, false);
10641064
})
10651065
elem.querySelectorAll('[data-numtag]').forEach(
10661066
(e)=>e.addEventListener('click', f.$clickNum, false)
10671067
)
10681068
}/*setupHashtags()*/;
@@ -1483,11 +1483,11 @@
14831483
}/*_handleLegendClicked()*/
14841484
}/*MessageWidget.prototype*/;
14851485
/** Assumes that e is a MessageWidget element, ensures that
14861486
Chat.e.viewMessages is visible, scrolls the message,
14871487
and animates it a bit to make it more visible. */
1488
- cf.scrollToMessageElem = function(e){
1488
+ ctor.scrollToMessageElem = function(e){
14891489
if(e.firstElementChild){
14901490
Chat.setCurrentView(Chat.e.viewMessages);
14911491
e.scrollIntoView(false);
14921492
Chat.animate(e, 'anim-fade-out-in');
14931493
}
@@ -2569,15 +2569,16 @@
25692569
}
25702570
return e;
25712571
};
25722572
Chat.clearSearch(true);
25732573
/**
2574
- Submits a history search using the main input field's current
2575
- text. It is assumed that Chat.e.viewSearch===Chat.e.currentView.
2574
+ Submits a history search using either its argument or the the
2575
+ main input field's current text.
25762576
*/
2577
- Chat.submitSearch = function(){
2578
- const term = this.inputValue(true);
2577
+ Chat.submitSearch = function(term){
2578
+ Chat.setCurrentView(Chat.e.viewSearch);
2579
+ if(!arguments.length) term = this.inputValue(true);
25792580
const eMsgTgt = this.clearSearch(true);
25802581
if( !term ) return;
25812582
D.append( eMsgTgt, "Searching for ",term," ...");
25822583
const fd = new FormData();
25832584
fd.set('q', term);
25842585
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1016,17 +1016,17 @@
1016 while(e && !e.classList.contains(className)){
1017 e = e.parentNode;
1018 }
1019 return e;
1020 };
1021
1022 /** To be passed each MessageWidget's top-level DOM element
1023 after initial processing of the message, to set up
1024 hashtag and numtag references. */
1025 const setupHashtags = function f(elem){
1026 if(!f.$click){
1027 f.$click = function(ev){
1028 /* Click handler for hashtags */
1029 const tag = ev.target.dataset.hashtag;
1030 if(tag){
1031 Chat.setHashtagFilter(
1032 tag===Chat.filter.hashtag.activeTag
@@ -1051,18 +1051,18 @@
1051 const rc = window.history.pushState(state, "");
1052 //console.debug("Pushing history for msgid", state);
1053 //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack);
1054 }
1055 }else{
1056 F.toast.warning("Message #"+tag+" not found in loaded messages.");
1057 }
1058 }
1059 };
1060 }
1061 elem.querySelectorAll('[data-hashtag]').forEach(function(e){
1062 e.dataset.hashtag = e.dataset.hashtag.toLowerCase();
1063 e.addEventListener('click', f.$click, false);
1064 })
1065 elem.querySelectorAll('[data-numtag]').forEach(
1066 (e)=>e.addEventListener('click', f.$clickNum, false)
1067 )
1068 }/*setupHashtags()*/;
@@ -1483,11 +1483,11 @@
1483 }/*_handleLegendClicked()*/
1484 }/*MessageWidget.prototype*/;
1485 /** Assumes that e is a MessageWidget element, ensures that
1486 Chat.e.viewMessages is visible, scrolls the message,
1487 and animates it a bit to make it more visible. */
1488 cf.scrollToMessageElem = function(e){
1489 if(e.firstElementChild){
1490 Chat.setCurrentView(Chat.e.viewMessages);
1491 e.scrollIntoView(false);
1492 Chat.animate(e, 'anim-fade-out-in');
1493 }
@@ -2569,15 +2569,16 @@
2569 }
2570 return e;
2571 };
2572 Chat.clearSearch(true);
2573 /**
2574 Submits a history search using the main input field's current
2575 text. It is assumed that Chat.e.viewSearch===Chat.e.currentView.
2576 */
2577 Chat.submitSearch = function(){
2578 const term = this.inputValue(true);
 
2579 const eMsgTgt = this.clearSearch(true);
2580 if( !term ) return;
2581 D.append( eMsgTgt, "Searching for ",term," ...");
2582 const fd = new FormData();
2583 fd.set('q', term);
2584
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1016,17 +1016,17 @@
1016 while(e && !e.classList.contains(className)){
1017 e = e.parentNode;
1018 }
1019 return e;
1020 };
1021
1022 /** To be passed each MessageWidget's top-level DOM element
1023 after initial processing of the message, to set up
1024 hashtag and numtag references. */
1025 const setupHashtags = function f(elem){
1026 if(!f.$clickTag){
1027 f.$clickTag = function(ev){
1028 /* Click handler for hashtags */
1029 const tag = ev.target.dataset.hashtag;
1030 if(tag){
1031 Chat.setHashtagFilter(
1032 tag===Chat.filter.hashtag.activeTag
@@ -1051,18 +1051,18 @@
1051 const rc = window.history.pushState(state, "");
1052 //console.debug("Pushing history for msgid", state);
1053 //console.debug("Chat.numtagHistoryStack =",Chat.numtagHistoryStack);
1054 }
1055 }else{
1056 Chat.submitSearch('#'+tag);
1057 }
1058 }
1059 };
1060 }
1061 elem.querySelectorAll('[data-hashtag]').forEach(function(e){
1062 e.dataset.hashtag = e.dataset.hashtag.toLowerCase();
1063 e.addEventListener('click', f.$clickTag, false);
1064 })
1065 elem.querySelectorAll('[data-numtag]').forEach(
1066 (e)=>e.addEventListener('click', f.$clickNum, false)
1067 )
1068 }/*setupHashtags()*/;
@@ -1483,11 +1483,11 @@
1483 }/*_handleLegendClicked()*/
1484 }/*MessageWidget.prototype*/;
1485 /** Assumes that e is a MessageWidget element, ensures that
1486 Chat.e.viewMessages is visible, scrolls the message,
1487 and animates it a bit to make it more visible. */
1488 ctor.scrollToMessageElem = function(e){
1489 if(e.firstElementChild){
1490 Chat.setCurrentView(Chat.e.viewMessages);
1491 e.scrollIntoView(false);
1492 Chat.animate(e, 'anim-fade-out-in');
1493 }
@@ -2569,15 +2569,16 @@
2569 }
2570 return e;
2571 };
2572 Chat.clearSearch(true);
2573 /**
2574 Submits a history search using either its argument or the the
2575 main input field's current text.
2576 */
2577 Chat.submitSearch = function(term){
2578 Chat.setCurrentView(Chat.e.viewSearch);
2579 if(!arguments.length) term = this.inputValue(true);
2580 const eMsgTgt = this.clearSearch(true);
2581 if( !term ) return;
2582 D.append( eMsgTgt, "Searching for ",term," ...");
2583 const fd = new FormData();
2584 fd.set('q', term);
2585

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button