From f36c9565362b741c58672204fe0c155252affe28 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 24 Jan 2023 13:00:11 -0600 Subject: Resolve all remaining lint issues (#88) * Rework 'navIdx' variables from number arrays to strings to avoid equality-check failures in react hooks * Resolve all remaining lint issues * Fix tests * Use node v18 in gh action test --- src/state/models/navigation.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/state/models/navigation.ts') diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 8d69e5c04..224ffef0d 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -3,7 +3,7 @@ import {TABS_ENABLED} from '../../build-flags' let __id = 0 function genId() { - return ++__id + return String(++__id) } // NOTE @@ -24,10 +24,10 @@ interface HistoryItem { url: string ts: number title?: string - id: number + id: string } -export type HistoryPtr = [number, number] +export type HistoryPtr = string // `{tabId}-{historyId}` export class NavigationTabModel { id = genId() @@ -151,7 +151,7 @@ export class NavigationTabModel { } } - setTitle(id: number, title: string) { + setTitle(id: string, title: string) { this.history = this.history.map(h => { if (h.id === id) { return {...h, title} @@ -174,7 +174,7 @@ export class NavigationTabModel { } } - hydrate(v: unknown) { + hydrate(_v: unknown) { // TODO fixme // if (isObj(v)) { // if (hasProp(v, 'history') && Array.isArray(v.history)) { @@ -241,7 +241,7 @@ export class NavigationModel { return this.tabs.length } - isCurrentScreen(tabId: number, index: number) { + isCurrentScreen(tabId: string, index: number) { return this.tab.id === tabId && this.tab.index === index } @@ -257,7 +257,8 @@ export class NavigationModel { } setTitle(ptr: HistoryPtr, title: string) { - this.tabs.find(t => t.id === ptr[0])?.setTitle(ptr[1], title) + const [tid, hid] = ptr.split('-') + this.tabs.find(t => t.id === tid)?.setTitle(hid, title) } handleLink(url: string) { @@ -338,7 +339,7 @@ export class NavigationModel { } } - hydrate(v: unknown) { + hydrate(_v: unknown) { // TODO fixme this.clear() /*if (isObj(v)) { -- cgit 1.4.1