@@ -50,15 +50,19 @@ export default {
5050 } ;
5151
5252 const getTotalPostReactionCount = async ( id ) => {
53+ if ( CACHED [ id ] === "loading" ) return ;
54+
5355 const { setText, closeAfter } = UfsGlobal . DOM . notify ( {
5456 msg : "Đang đếm số lượng reaction..." ,
5557 duration : 10000 ,
5658 } ) ;
59+ const numberFormater = UfsGlobal . Utils . getNumberFormatter ( "standard" ) ;
5760
5861 let res ;
5962 if ( CACHED [ id ] ) {
6063 res = CACHED [ id ] ;
6164 } else {
65+ CACHED [ id ] = "loading" ;
6266 res = {
6367 total : 0 ,
6468 each : { } ,
@@ -67,18 +71,22 @@ export default {
6771 const count = await getPostReactionsCount ( id , reactionId ) ;
6872 res . total += count ;
6973 res . each [ name ] = count ;
70- setText ( `Đang đếm số lượng reaction ${ name } ... Tổng: ${ res . total } ` ) ;
74+ setText (
75+ `Đang đếm số lượng reaction ${ name } ... Tổng: ${ numberFormater . format (
76+ res . total
77+ ) } `
78+ ) ;
7179 }
7280 CACHED [ id ] = res ;
7381 }
7482
7583 setText (
7684 "<p style='color:white;font-size:20px;padding:0;margin:0'>Tổng " +
77- res . total +
85+ numberFormater . format ( res . total ) +
7886 " reaction.<br/>Bao gồm " +
7987 Object . entries ( res . each )
8088 . filter ( ( [ key , value ] ) => value > 0 )
81- . map ( ( [ key , value ] ) => `${ value } ${ key } ` )
89+ . map ( ( [ key , value ] ) => `${ numberFormater . format ( value ) } ${ key } ` )
8290 . join ( ", " ) +
8391 "</p>"
8492 ) ;
@@ -88,9 +96,11 @@ export default {
8896 const originalXMLSend = XMLHttpRequest . prototype . send ;
8997 XMLHttpRequest . prototype . send = function ( ) {
9098 let s = arguments [ 0 ] ?. toString ( ) || "" ;
91- if ( s . includes ( "CometUFIReactionsCountTooltipContentQuery" ) ) {
92- console . log ( this ) ;
93- const original = this . onreadystatechange ;
99+ if (
100+ s . includes ( "CometUFIReactionsCountTooltipContentQuery" ) ||
101+ s . includes ( "CometUFIReactionIconTooltipContentQuery" )
102+ ) {
103+ const originalReady = this . onreadystatechange ;
94104 this . onreadystatechange = function ( ) {
95105 if ( this . readyState == 4 ) {
96106 try {
@@ -106,7 +116,7 @@ export default {
106116 console . log ( err ) ;
107117 }
108118 }
109- original . apply ( this , arguments ) ;
119+ originalReady . apply ( this , arguments ) ;
110120 } ;
111121 }
112122 originalXMLSend . apply ( this , arguments ) ;
0 commit comments