mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 00:53:19 +08:00
fix(NewPostNotification): 当标题或描述变更时也计算差异
之前仅当内容变更时才计算差异,导致标题或描述变更时用户看不到具体变化。 现在当内容未变但描述或标题变更时,也计算并显示相应的差异。
This commit is contained in:
@@ -493,8 +493,19 @@
|
||||
const contentChanged = post.content !== stored.content;
|
||||
|
||||
if (titleChanged || dateChanged || descriptionChanged || contentChanged) {
|
||||
// Calculate diff only if content changed
|
||||
const diff = contentChanged ? computeDiff(stored.content, post.content) : null;
|
||||
// Calculate diff for content
|
||||
let diff = null;
|
||||
|
||||
if (contentChanged) {
|
||||
diff = computeDiff(stored.content, post.content);
|
||||
} else if (descriptionChanged) {
|
||||
// If content is same but description changed, show description diff
|
||||
diff = computeDiff(stored.description, post.description);
|
||||
// Add a label to indicate this is description diff?
|
||||
// The UI doesn't support labels inside diff yet, but at least user sees the text change.
|
||||
} else if (titleChanged) {
|
||||
diff = computeDiff(stored.title, post.title);
|
||||
}
|
||||
|
||||
detectedChanges.push({
|
||||
...post,
|
||||
|
||||
Reference in New Issue
Block a user