This commit is contained in:
Rizky 2024-08-02 17:04:06 +07:00
parent 2f0125dd8e
commit 4cf9bf2697
2 changed files with 28 additions and 4 deletions

View File

@ -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 } },

View File

@ -19,7 +19,7 @@ export const EdPageHistoryList = () => {
<Loading backdrop={false} />
) : (
<div className="flex flex-1 flex-col items-stretch">
{local.list.map((e) => {
{local.list.map((e, idx) => {
return (
<div
className={cx(
@ -34,6 +34,15 @@ export const EdPageHistoryList = () => {
local.render();
}}
>
<div
className={cx(css`
width: 20px;
border-right: 1px solid #ccc;
margin-right: 5px;
`)}
>
{idx + 1}
</div>
<div className="flex-1">
{format(parseInt(e.ts) * 5000, "yyyy-MM-dd HH:mm:ss")}
</div>