Skip to content

Commit 2100382

Browse files
committed
fix: replace eslint-disable stubs with real JSDoc in group/threadDrawer
- Remove blanket jsdoc suppressions; document factory option callbacks with @returns/@param descriptions - Fix threadDrawer loadMessagesRef formatting and late-binding JSDoc - standalone_message.html: keep file-level eslint-disable with explanation comment
1 parent b4a57c3 commit 2100382

3 files changed

Lines changed: 51 additions & 58 deletions

File tree

src/public/parts/shells/chat/public/src/group.mjs

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,16 @@ async function applyGroupHash() {
387387
// ─── 文件处理(uploadGroupFile / downloadGroupFile / fetchGroupFileAsBlob / enqueuePendingFile)──
388388

389389
// loadMessages / scheduleMessagePatch 由下方 createChannelView 赋值,此处先声明供晚绑定
390-
// eslint-disable-next-line prefer-const
391390
let loadMessages, scheduleMessagePatch
392391

393392
// loadMessages 在此处尚未定义,使用晚绑定包装,确保实际调用时已初始化
394-
/* eslint-disable jsdoc/require-returns */
395393
const { uploadGroupFile, downloadGroupFile, fetchGroupFileAsBlob, enqueuePendingFile, pendingFiles } = createFileHandlers({
396394
groupId, Sentry, showToastI18n, escapeHtml,
397395
/**
398-
*
396+
* @returns {Promise<void>} 重新加载当前频道消息
399397
*/
400398
loadMessages: () => loadMessages(),
401399
})
402-
/* eslint-enable jsdoc/require-returns */
403400

404401
// ─── 表情回应(toggleReaction)────────────────────────────────────────────
405402

@@ -409,38 +406,37 @@ async function applyGroupHash() {
409406
/** @type {{ open: Function, close: Function, destroy: Function } | null} */
410407
let threadDrawerInstance = null
411408

412-
/* eslint-disable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type */
413409
const { renderMessageItem, attachLastMessageTimeline } = createMessageItemRenderer({
414410
groupId,
415411
channelId,
416412
msgBox,
417413
/**
418-
*
414+
* @returns {Promise<void>} 重新加载当前频道消息
419415
*/
420416
loadMessages: () => loadMessages(),
421417
/**
422-
*
418+
* @returns {unknown[]} 当前展示用消息数组
423419
*/
424420
getDisplayMessages: () => channelState.displayMessages,
425421
/**
426-
*
422+
* @returns {Record<string, string>} 成员头像 URL 缓存
427423
*/
428424
getMemberAvatarCache: () => memberAvatarCache,
429425
toggleReaction,
430426
fetchGroupFileAsBlob,
431427
downloadGroupFile,
432428
loadBookmarks,
433429
/**
434-
*
430+
* @returns {unknown[]} DM 拉黑列表
435431
*/
436432
getDmBlocklist: () => dmBlocklist,
437433
/**
438-
*
439-
* @param next
434+
* @param {unknown} next 新的拉黑列表
435+
* @returns {void}
440436
*/
441437
setDmBlocklist: next => { dmBlocklist = next },
442438
/**
443-
*
439+
* @returns {Set<string>} 已被编辑过的消息 ID 集合
444440
*/
445441
getEditedIds: () => {
446442
const s = new Set()
@@ -451,7 +447,7 @@ async function applyGroupHash() {
451447
return s
452448
},
453449
/**
454-
*
450+
* @returns {void} 内容高度变化时滚动到底部
455451
*/
456452
onContentResize: () => {
457453
if (!channelState.msgScrollContainer) return
@@ -460,18 +456,17 @@ async function applyGroupHash() {
460456
channelState.msgScrollContainer.scrollTop = channelState.msgScrollContainer.scrollHeight
461457
},
462458
/**
463-
* @param {string} threadChannelId
459+
* @param {string} threadChannelId 子线程频道 ID
460+
* @returns {void}
464461
*/
465462
onOpenThread: threadChannelId => { threadDrawerInstance?.open(threadChannelId) },
466463
})
467-
/* eslint-enable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type */
468464

469465
// ─── Thread Drawer ────────────────────────────────────────────────────────
470466

471-
/* eslint-disable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type */
472467
/**
473468
* 为指定线程频道创建专用消息渲染器(复用群组级共享依赖)。
474-
* @param {object} threadCtx
469+
* @param {object} threadCtx 线程上下文
475470
* @param {string} threadCtx.channelId 线程频道 ID
476471
* @param {HTMLElement} threadCtx.msgBox 线程消息容器元素
477472
* @param {Function} threadCtx.loadMessages 线程消息刷新函数
@@ -482,45 +477,42 @@ async function applyGroupHash() {
482477
groupId,
483478
channelId: threadChannelId,
484479
msgBox: threadMsgBox,
485-
/**
486-
*
487-
*/
488480
loadMessages: threadLoadMessages,
489481
/**
490-
*
482+
* @returns {unknown[]} 线程视图无合并展示列表,恒为空
491483
*/
492484
getDisplayMessages: () => [],
493485
/**
494-
*
486+
* @returns {Record<string, string>} 成员头像 URL 缓存
495487
*/
496488
getMemberAvatarCache: () => memberAvatarCache,
497489
toggleReaction,
498490
fetchGroupFileAsBlob,
499491
downloadGroupFile,
500492
loadBookmarks,
501493
/**
502-
*
494+
* @returns {unknown[]} DM 拉黑列表
503495
*/
504496
getDmBlocklist: () => dmBlocklist,
505497
/**
506-
*
507-
* @param {object} next
498+
* @param {unknown} next 新的拉黑列表
499+
* @returns {void}
508500
*/
509501
setDmBlocklist: next => { dmBlocklist = next },
510502
/**
511-
*
503+
* @returns {Set<string>} 线程内不跟踪编辑态,恒为空集
512504
*/
513505
getEditedIds: () => new Set(),
514506
/**
515-
*
507+
* @returns {void} 线程内无内容自适应滚动
516508
*/
517509
onContentResize: () => {},
518510
/**
519-
* @param {string} nestedThreadId 嵌套子线程 ID
511+
* @param {string} nestedThreadId 嵌套子线程频道 ID
512+
* @returns {void}
520513
*/
521514
onOpenThread: nestedThreadId => { threadDrawerInstance?.open(nestedThreadId) },
522515
})
523-
/* eslint-enable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type */
524516

525517
threadDrawerInstance = createThreadDrawer({
526518
groupId,
@@ -577,7 +569,6 @@ async function applyGroupHash() {
577569
}
578570

579571
// 创建频道视图(含 loadMessages 和 scheduleMessagePatch)
580-
/* eslint-disable jsdoc/require-returns */
581572
;({ loadMessages, scheduleMessagePatch } = createChannelView({
582573
groupId,
583574
channelId,
@@ -586,19 +577,19 @@ async function applyGroupHash() {
586577
signal,
587578
state: channelState,
588579
/**
589-
*
580+
* @returns {object | null} 最近一次拉取的频道元数据
590581
*/
591582
getLastChannelMeta: () => lastChannelMeta,
592583
/**
593-
*
584+
* @returns {object | null} 最近一次拉取的群设置
594585
*/
595586
getLastGroupSettings: () => lastGroupSettings,
596587
/**
597-
*
588+
* @returns {string[]} @ 提及可用的角色名列表
598589
*/
599590
getMentionCharNames: () => mentionCharNames,
600591
/**
601-
*
592+
* @returns {Record<string, object>} 已打开频道缓存
602593
*/
603594
getOpenedChannels: () => openedChannels,
604595
enqueuePendingFile,
@@ -607,7 +598,6 @@ async function applyGroupHash() {
607598
renderMessageItem,
608599
attachLastMessageTimeline,
609600
}))
610-
/* eslint-enable jsdoc/require-returns */
611601

612602
await pullIncrementalDagEvents()
613603
await loadState()
@@ -634,7 +624,7 @@ async function applyGroupHash() {
634624
groupWs.addEventListener('open', () => {
635625
sendWebsocketMessage({ type: 'group_ws_rpc_identity', clientNodeId: wsClientId })
636626
}, { once: true })
637-
/* eslint-disable jsdoc/require-returns */
627+
638628
groupWs.onmessage = createWsMessageHandler({
639629
groupId,
640630
channelId,
@@ -649,48 +639,46 @@ async function applyGroupHash() {
649639
loadState,
650640
loadBookmarks,
651641
/**
652-
*
642+
* @returns {WebSocket} 当前群 WebSocket 实例
653643
*/
654644
getGroupWs: () => groupWs,
655645
shouldLoadChannel,
656646
handleGroupWebSocketRpc,
657647
handleSessionEvent,
658648
msgBox,
659649
})
660-
/* eslint-enable jsdoc/require-returns */
661650

662-
/* eslint-disable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type, no-unused-vars */
663651
const { postMessage, startAvSession } = createMessageInputHandlers({
664652
groupId,
665653
channelId,
666654
signal,
667655
input,
668656
wsClientId,
669657
/**
670-
*
658+
* @returns {unknown[]} 待发送附件队列
671659
*/
672660
getPendingFiles: () => pendingFiles,
673661
/**
674-
*
662+
* @returns {void} 清空待发送附件队列
675663
*/
676664
clearPendingFiles: () => { pendingFiles.length = 0 },
677665
enqueuePendingFile,
678666
uploadGroupFile,
679667
/**
680-
*
668+
* @returns {unknown} 当前音视频会话句柄
681669
*/
682670
getAvSession: () => channelState.avSession,
683671
/**
684-
*
685-
* @param s
672+
* @param {unknown} s 新的音视频会话句柄
673+
* @returns {void}
686674
*/
687675
setAvSession: s => { channelState.avSession = s },
688676
/**
689-
*
677+
* @returns {object | null} 最近一次频道元数据
690678
*/
691679
getLastChannelMeta: () => lastChannelMeta,
692680
/**
693-
*
681+
* @returns {Record<string, object>} 频道列表快照
694682
*/
695683
getLastChannels: () => lastChannels,
696684
loadMessages,
@@ -700,12 +688,8 @@ async function applyGroupHash() {
700688
updateMentionPopover,
701689
sendTypingBroadcast,
702690
})
703-
/* eslint-enable jsdoc/require-returns, jsdoc/require-param-description, jsdoc/require-param-type, no-unused-vars */
704691
}
705692

706-
/**
707-
* @returns {Promise<void>}
708-
*/
709693
/** DM 拉黑列表(本地缓存,sessionStorage 为辅) */
710694
let dmBlocklist = []
711695
/**

src/public/parts/shells/chat/public/src/templates/standalone_message.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<!-- eslint-disable -->
3+
<!-- 模板引擎 HTML,非独立脚本;须整文件禁用 eslint 避免误解析内嵌语法 -->
34
<html lang="${main_locale}">
45
${
56
let messageHtml = setValue('messageHtml', await renderMarkdownAsStandAloneHtmlString(message.content_for_show || message.content))

src/public/parts/shells/chat/public/src/ui/threadDrawer.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,30 @@ export function createThreadDrawer({ groupId, panel, createThreadRenderer }) {
186186
msgVirtualList = null
187187
msgBox.innerHTML = '<div class="flex justify-center items-center flex-1 p-6"><span class="loading loading-spinner loading-sm opacity-60"></span></div>'
188188

189-
/* eslint-disable jsdoc/require-returns, jsdoc/require-jsdoc */
190-
// 晚绑定:loadMessages 需先于 renderMessageItem 声明,通过包装器延迟调用
191-
// eslint-disable-next-line prefer-const
192-
let loadFn = () => Promise.resolve()
189+
// 晚绑定:renderMessageItem 在 createThreadRenderer 之后才存在,用可替换的 run 避免 let 重赋值
190+
const loadMessagesRef = {
191+
/**
192+
* @returns {Promise<void>} 加载或刷新线程消息(占位实现)
193+
*/
194+
run: () => Promise.resolve(),
195+
}
193196

194197
const { renderMessageItem } = createThreadRenderer({
195198
channelId: threadChannelId,
196199
msgBox,
197-
loadMessages: () => loadFn(),
200+
/**
201+
* @returns {Promise<void>} 调用当前绑定的线程加载函数
202+
*/
203+
loadMessages: () => loadMessagesRef.run(),
198204
})
199205

200-
loadFn = () => fetchAndRender(threadChannelId, renderMessageItem, signal)
201-
/* eslint-enable jsdoc/require-returns, jsdoc/require-jsdoc */
206+
/**
207+
* @returns {Promise<void>} 拉取并渲染线程频道消息
208+
*/
209+
loadMessagesRef.run = () => fetchAndRender(threadChannelId, renderMessageItem, signal)
202210

203211
try {
204-
await loadFn()
212+
await loadMessagesRef.run()
205213
}
206214
catch (e) {
207215
if (!signal.aborted) {

0 commit comments

Comments
 (0)