From 6e8a4bbf71d60f285b9938bf3d36ffc030d0ebe1 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 3 Feb 2023 17:10:32 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7244 --- app/src/history/diff.ts | 18 +++++++++++----- app/src/history/history.ts | 42 ++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts index c767aa332..2c225b4f7 100644 --- a/app/src/history/diff.ts +++ b/app/src/history/diff.ts @@ -97,12 +97,20 @@ const renderCompare = (element: HTMLElement) => { } }; -export const showDiff = (ids: string) => { - const idArray = ids.split(","); - if (idArray.length !== 2) { +export const showDiff = (data: { id: string, time: string }[]) => { + if (data.length !== 2) { return; } - fetchPost("/api/repo/diffRepoSnapshots", {left: idArray[0], right: idArray[1]}, (response) => { + let left + let right + if (data[0].time > data[1].time) { + left = data[1].id + right = data[0].id + } else { + left = data[0].id + right = data[1].id + } + fetchPost("/api/repo/diffRepoSnapshots", {left, right}, (response) => { const dialog = new Dialog({ title: window.siyuan.languages.compare, content: `
@@ -114,7 +122,7 @@ export const showDiff = (ids: string) => { ${window.siyuan.languages.update} - +