From 8344734e2b4b7873b8596ac7e611279aa76ae37b Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Mon, 26 Aug 2024 20:55:02 -0700 Subject: [PATCH] Remove optimization that caused scrubbing misbehavior --- src/components/timeline-core.ts | 7 ------- src/utils/basic.ts | 6 ++++-- tests/utils/basic.test.ts | 4 ++++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/timeline-core.ts b/src/components/timeline-core.ts index 502ac0cc..d204c58d 100644 --- a/src/components/timeline-core.ts +++ b/src/components/timeline-core.ts @@ -678,13 +678,6 @@ export class FrigateCardTimelineCore extends LitElement { query: mediaQuery, }, queryExecutorOptions: { - // Reject the new results unless there is something to be gained (i.e. they - // are not a subset of the existing results). Example usecase: On initial - // view load in mini timeline mode, the first 50 events are fetched -- the - // first drag of the timeline should not dispatch new results unless - // something is actually useful (as otherwise it creates a visible 'flicker' - // for the user as the viewer reloads all the media). - rejectResults: (results) => !!view.queryResults?.isSupersetOf(results), selectResult: { id: this.viewManagerEpoch?.manager diff --git a/src/utils/basic.ts b/src/utils/basic.ts index 36d5342e..e530849b 100644 --- a/src/utils/basic.ts +++ b/src/utils/basic.ts @@ -105,13 +105,15 @@ export function contentsChanged( * @param func The Console func to call. */ export function errorToConsole( - e: Error | { message: unknown }, + e: Error | { message: unknown } | string, func: CallableFunction = console.warn, ): void { if (e instanceof FrigateCardError && e.context) { func(e, e.context); - } else { + } else if (typeof e === 'object' && 'message' in e) { func(e.message); + } else { + func(e); } } diff --git a/tests/utils/basic.test.ts b/tests/utils/basic.test.ts index 81f6ff39..257bbe3c 100644 --- a/tests/utils/basic.test.ts +++ b/tests/utils/basic.test.ts @@ -124,6 +124,10 @@ describe('errorToConsole', () => { errorToConsole(error, func); expect(func).toHaveBeenCalledWith('ERROR'); }); + it('should log string', () => { + errorToConsole('string message'); + expect(spy).toHaveBeenCalledWith('string message'); + }); }); describe('isHoverableDevice', () => {