@fabianactor/dsh-lil-whale-group-ui 1.12.1 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +44 -17
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -967,13 +967,17 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
967
967
|
|
|
968
968
|
async function markRead(channel, peer) {
|
|
969
969
|
try {
|
|
970
|
-
await fetch('/group/api/read', {
|
|
970
|
+
const response = await fetch('/group/api/read', {
|
|
971
971
|
method: 'POST',
|
|
972
972
|
headers: { 'content-type': 'application/json', 'x-llw-panel': '1' },
|
|
973
973
|
body: JSON.stringify({ channel, peer }),
|
|
974
974
|
})
|
|
975
|
+
// 2026-11-19(Fabian 报"红点清了又回来"):以前不看 response.ok,
|
|
976
|
+
// 403/500 也当读过了。返回值给调用方,失败才谈得上重试。
|
|
977
|
+
return response.ok
|
|
975
978
|
} catch {
|
|
976
979
|
// 清不掉就继续亮着,比假装看过好
|
|
980
|
+
return false
|
|
977
981
|
}
|
|
978
982
|
}
|
|
979
983
|
|
|
@@ -2119,8 +2123,11 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2119
2123
|
|
|
2120
2124
|
// 贴底了就把"回到历史未读"收掉:人已经看见最新的了,留着只剩误导。
|
|
2121
2125
|
// 2026-11-17 第 2 条:清完红点后来新消息,长消息把分割线顶出视口上沿,提示又亮。
|
|
2126
|
+
// 2026-11-19 第 3 条:贴底时提示消失、稍一上滑又出现——"到底"本身就是"已经见过这截"的证据,
|
|
2127
|
+
// 记进 historyVisitedRef;之后同一根线不再亮,等读完一批(markRead)才放行。
|
|
2122
2128
|
useEffect(() => {
|
|
2123
2129
|
if (!atBottom) return
|
|
2130
|
+
historyVisitedRef.current = true
|
|
2124
2131
|
if (historyAboveRef.current) { historyAboveRef.current = false; setHistoryAbove(false) }
|
|
2125
2132
|
}, [atBottom])
|
|
2126
2133
|
|
|
@@ -2158,21 +2165,39 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2158
2165
|
// 看过 1.5 秒才算读过:让红点有出现的余地,也不至于一闪就没。
|
|
2159
2166
|
// 依赖里必须有 atBottom:翻历史回到底部的那一下才是"看见了";
|
|
2160
2167
|
// 以前少了它,读完了未读也不清(2026-11-15 第 5 条)。
|
|
2168
|
+
// 2026-11-19(Fabian 报"切走再回来红点又出现"):两个坑补上——
|
|
2169
|
+
// ①定时器被 clearTimeout 吞掉:1.5 秒内切走/离开页面,这次"读完"永远不会记;
|
|
2170
|
+
// ②markRead 失败没人重试,而依赖不变,effect 不会再来一遍。
|
|
2171
|
+
const groupReadTimerRef = useRef(null)
|
|
2172
|
+
const finishGroupRead = useCallback(() => {
|
|
2173
|
+
groupReadTimerRef.current = null
|
|
2174
|
+
void markRead('group').then((ok) => {
|
|
2175
|
+
if (!ok) {
|
|
2176
|
+
// 服务端没记上:五秒后再来一次,别让"清不掉"沉成"以为清掉了"。
|
|
2177
|
+
groupReadTimerRef.current = setTimeout(finishGroupRead, 5000)
|
|
2178
|
+
return
|
|
2179
|
+
}
|
|
2180
|
+
historyVisitedRef.current = false
|
|
2181
|
+
// 读完一批后分割线会挪到新位置:立刻重量,别等下一次滚动。
|
|
2182
|
+
measureHistory()
|
|
2183
|
+
refresh()
|
|
2184
|
+
// 面板读完一批,喊一声;侧边栏红点不用等下一轮轮询。
|
|
2185
|
+
window.dispatchEvent(new Event('dsh-group-read'))
|
|
2186
|
+
})
|
|
2187
|
+
}, [refresh, measureHistory])
|
|
2161
2188
|
useEffect(() => {
|
|
2162
|
-
if (tab !== 'group' || unread.group === 0 || !atBottom) return
|
|
2163
|
-
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return
|
|
2164
|
-
const timer = setTimeout(
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
return () => clearTimeout(timer)
|
|
2175
|
-
}, [tab, unread.group, refresh, atBottom])
|
|
2189
|
+
if (tab !== 'group' || unread.group === 0 || !atBottom) return undefined
|
|
2190
|
+
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return undefined
|
|
2191
|
+
const timer = setTimeout(finishGroupRead, 1500)
|
|
2192
|
+
groupReadTimerRef.current = timer
|
|
2193
|
+
return () => {
|
|
2194
|
+
// 切 tab / 离开页面:先把这次"读完"记上,再让定时器走开。
|
|
2195
|
+
clearTimeout(timer)
|
|
2196
|
+
if (groupReadTimerRef.current !== timer) return
|
|
2197
|
+
groupReadTimerRef.current = null
|
|
2198
|
+
void markRead('group')
|
|
2199
|
+
}
|
|
2200
|
+
}, [tab, unread.group, refresh, atBottom, finishGroupRead])
|
|
2176
2201
|
// 翻历史时底下来了新消息:只数"最后一条之后新增了几条",回到底部就清零。
|
|
2177
2202
|
// 不用未读数(未读是服务器口径,可能包含别的窗口看过的,不能当"你还没看"的证据)。
|
|
2178
2203
|
const lastSeenTsRef = useRef('')
|
|
@@ -2414,7 +2439,9 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2414
2439
|
},
|
|
2415
2440
|
},
|
|
2416
2441
|
item.key === 'group'
|
|
2417
|
-
|
|
2442
|
+
// 2026-11-19:以前"在群聊且贴底"就把计数藏起来,看着像清了;
|
|
2443
|
+
// 切到别的页又照实显示。现在只信服务端给的数,"清了"就等于真清了。
|
|
2444
|
+
? (unread.group > 0 ? item.label + ' (' + unread.group + ')' : item.label)
|
|
2418
2445
|
: item.key === 'dm'
|
|
2419
2446
|
? (dmTotal(unread) > 0 ? item.label + ' (' + dmTotal(unread) + ')' : item.label)
|
|
2420
2447
|
: item.label,
|
|
@@ -3800,7 +3827,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
3800
3827
|
inject: ['slots'],
|
|
3801
3828
|
apply(ctx) {
|
|
3802
3829
|
// 一行"我跑的是哪一版"的自报,方便判断浏览器是不是还在用旧 bundle
|
|
3803
|
-
console.info('[dsh-lil-whale-group-ui] client build
|
|
3830
|
+
console.info('[dsh-lil-whale-group-ui] client build v55 · read-truth:', Object.keys(MARKDOWN_LABELS).join(','))
|
|
3804
3831
|
// 「正在回复…」那三个点的呼吸动画 + 过场转圈。只在浏览器里注入一次。
|
|
3805
3832
|
if (typeof document !== 'undefined' && !document.getElementById('dsh-lil-whale-group-keyframes')) {
|
|
3806
3833
|
const style = document.createElement('style')
|