From 967d2a24621aa6c973ad211ae1a3fcf5da1c6009 Mon Sep 17 00:00:00 2001 From: Rizky Date: Sun, 11 Feb 2024 20:59:08 +0700 Subject: [PATCH] wip fix --- pkgs/core/utils/diff.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/core/utils/diff.ts b/pkgs/core/utils/diff.ts index 46bb78a2..d889cd21 100644 --- a/pkgs/core/utils/diff.ts +++ b/pkgs/core/utils/diff.ts @@ -2,8 +2,8 @@ import { applyPatch, calcPatch } from "./diff-internal"; import { Packr } from "msgpackr"; import { gunzip, gzip } from "zlib"; -const MAX_HISTORY = 10; // max history item -const DIFF_TIMEOUT = 50; // in ms +const MAX_HISTORY = 25; // max history item +const MAX_DIFF_TIMEOUT = 50; // in ms const packr = new Packr({}); @@ -74,12 +74,12 @@ export class Diff { return old_data[key1] === this._data[key2]; }, () => { - return performance.now() - now > DIFF_TIMEOUT; + return performance.now() - now > MAX_DIFF_TIMEOUT; } ), ]; - if (performance.now() - now <= DIFF_TIMEOUT) { + if (performance.now() - now <= MAX_DIFF_TIMEOUT) { done( new Uint8Array( packr.pack({ diff: result_diff, mode: "patch", ts: this.ts }) @@ -113,7 +113,7 @@ export class Diff { } } else { num_array.push(num); - } + } } this._data = num_array; }