From 4cf9bf2697ec4af5ebe615903caf6aee1a5fdde4 Mon Sep 17 00:00:00 2001 From: Rizky Date: Fri, 2 Aug 2024 17:04:06 +0700 Subject: [PATCH] fix --- app/srv/ws/sync/actions/yjs_diff_local.ts | 21 ++++++++++++++++--- .../src/nova/ed/panel/tree/history-list.tsx | 11 +++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/srv/ws/sync/actions/yjs_diff_local.ts b/app/srv/ws/sync/actions/yjs_diff_local.ts index 00f00df1..f597eccf 100644 --- a/app/srv/ws/sync/actions/yjs_diff_local.ts +++ b/app/srv/ws/sync/actions/yjs_diff_local.ts @@ -18,7 +18,7 @@ export const yjs_diff_local: SAction["yjs"]["diff_local"] = async function ( return; } if (mode === "page" || mode === "comp") { - const doc = docs[mode][id].doc as Y.Doc; + const doc = docs[mode][id].doc as YJS.Doc; const diff = await gunzipAsync(bin); const um = docs[mode][id].um; um.addTrackedOrigin(this.client_id); @@ -55,11 +55,26 @@ export const yjs_diff_local: SAction["yjs"]["diff_local"] = async function ( ts: "desc", }, }); - const ids = []; + const ids: string[] = []; + + let last_ts = 0; + let last_stacked = false; for (let i = 0; i < res.length; i++) { + const ts = parseInt(res[i].ts); + + if (!last_ts) last_ts = ts; + if (i > 25) { - ids.push(res[i].id); + if (!last_stacked) { + if (((last_ts - ts) / 1000) * 60 < 10) { + last_stacked = true; + ids.push(res[i].id); + } + } else { + last_stacked = false; + } } + last_ts = ts; } await _db.page_history.deleteMany({ where: { id: { in: ids } }, diff --git a/app/web/src/nova/ed/panel/tree/history-list.tsx b/app/web/src/nova/ed/panel/tree/history-list.tsx index 61aaa43d..674e73b9 100644 --- a/app/web/src/nova/ed/panel/tree/history-list.tsx +++ b/app/web/src/nova/ed/panel/tree/history-list.tsx @@ -19,7 +19,7 @@ export const EdPageHistoryList = () => { ) : (
- {local.list.map((e) => { + {local.list.map((e, idx) => { return (
{ local.render(); }} > +
+ {idx + 1} +
{format(parseInt(e.ts) * 5000, "yyyy-MM-dd HH:mm:ss")}