Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets-thread-comment): thread-comment resource save error (#4050)

zhangwffd426a8e146
diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png
index fa2ba6004a..197e186e6a 100644
Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png differ
diff --git a/mockdata/src/sheets/demo/default-workbook-data-demo.ts b/mockdata/src/sheets/demo/default-workbook-data-demo.ts
index 2c73f69893..4301136053 100644
--- a/mockdata/src/sheets/demo/default-workbook-data-demo.ts
+++ b/mockdata/src/sheets/demo/default-workbook-data-demo.ts
@@ -24022,7 +24022,7 @@ export const DEFAULT_WORKBOOK_DATA_DEMO: IWorkbookData = {
}),
},
{
- name: 'SHEET_THREAD_COMMENT_PLUGIN',
+ name: 'SHEET_UNIVER_THREAD_COMMENT_PLUGIN',
data: JSON.stringify({
'sheet-0011': [{ text: { textRuns: [], paragraphs: [{ startIndex: 3, paragraphStyle: {} }], sectionBreaks: [{ startIndex: 4 }], dataStream: '123\\n\\r', customRanges: [] }, dT: '2024/05/17 21:16', id: 'jwV0QtHwUbhG3o--iy1qa', ref: 'H9', personId: 'mockId', unitId: 'workbook-01', subUnitId: 'sheet-0011' }],
'dv-test': [
diff --git a/packages/thread-comment/src/controllers/tc-resource.controller.ts b/packages/thread-comment/src/controllers/tc-resource.controller.ts
index fc20d7ef3e..ddf74c7763 100644
--- a/packages/thread-comment/src/controllers/tc-resource.controller.ts
+++ b/packages/thread-comment/src/controllers/tc-resource.controller.ts
@@ -44,7 +44,7 @@ export class ThreadCommentResourceController extends Disposable {
...info.root,
children: info.children,
});
- resultMap[info.unitId] = subUnitComments;
+ resultMap[info.subUnitId] = subUnitComments;
});
return JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap, unitID));
diff --git a/packages/thread-comment/src/models/thread-comment.model.ts b/packages/thread-comment/src/models/thread-comment.model.ts
index ff80fdbf5d..f979643334 100644
--- a/packages/thread-comment/src/models/thread-comment.model.ts
+++ b/packages/thread-comment/src/models/thread-comment.model.ts
@@ -224,6 +224,9 @@ export class ThreadCommentModel extends Disposable {
...rest,
parentId: parentId === origin.id ? undefined : parentId,
};
+ if (!comment.threadId) {
+ comment.threadId = comment.parentId || comment.id;
+ }
const addCommentItem = (item: IThreadComment) => {
commentMap.set(item.id, item);