MCPcopy Create free account
hub / github.com/CatMuse/HiNote / updateComment

Method updateComment

src/services/comment/CommentService.ts:128–154  ·  view source on GitHub ↗

* 更新评论

(highlight: HighlightInfo, commentId: string, content: string)

Source from the content-addressed store, hash-verified

126 * 更新评论
127 */
128 async updateComment(highlight: HighlightInfo, commentId: string, content: string): Promise<void> {
129 const file = await this.getFileForHighlight(highlight);
130 if (!file || !highlight.comments) return;
131
132 const comment = highlight.comments.find(c => c.id === commentId);
133 if (comment) {
134 const oldContent = comment.content;
135
136 comment.content = content;
137 comment.updatedAt = Date.now();
138 highlight.updatedAt = Date.now();
139 await this.highlightManager.addHighlight(file, highlight);
140
141 // 通过 EventManager 触发批注更新事件,用于闪卡同步
142 if (highlight.id) {
143 this.plugin.eventManager.emitCommentUpdate(file.path, oldContent, content, highlight.id);
144 }
145
146 // 只更新单个卡片,而不是刷新整个视图
147 if (this.onCardUpdate) {
148 this.onCardUpdate(highlight);
149 } else if (this.onRefreshView) {
150 // 降级方案:如果没有 onCardUpdate,则刷新整个视图
151 await this.onRefreshView();
152 }
153 }
154 }
155
156 /**
157 * 删除评论

Callers 1

configureMethod · 0.80

Calls 3

getFileForHighlightMethod · 0.95
addHighlightMethod · 0.80
emitCommentUpdateMethod · 0.80

Tested by

no test coverage detected