From 5633618ac2d550b74035a52122408046bc380765 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 20 Apr 2022 17:09:31 -0400 Subject: [PATCH 1/9] Remove Dashboard.navigate usage in app router --- src/components/appRouter.js | 92 ++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index f0f23096b..0354d1741 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -8,7 +8,6 @@ import globalize from '../scripts/globalize'; import itemHelper from './itemHelper'; import loading from './loading/loading'; import viewManager from './viewManager/viewManager'; -import Dashboard from '../utils/dashboard'; import ServerConnections from './ServerConnections'; import alert from './alert'; import reactControllerFactory from './reactControllerFactory'; @@ -52,26 +51,6 @@ class AppRouter { }); } - showLocalLogin(serverId) { - Dashboard.navigate('login.html?serverid=' + serverId); - } - - showVideoOsd() { - return Dashboard.navigate('video'); - } - - showSelectServer() { - Dashboard.navigate('selectserver.html'); - } - - showSettings() { - Dashboard.navigate('mypreferencesmenu.html'); - } - - showNowPlaying() { - this.show('queue'); - } - beginConnectionWizard() { clearBackdrop(); loading.show(); @@ -497,7 +476,7 @@ class AppRouter { }).then(data => { if (data !== null && data.StartupWizardCompleted === false) { ServerConnections.setLocalApiClient(firstResult.ApiClient); - Dashboard.navigate('wizardstart.html'); + this.show('wizardstart.html'); } else { this.handleConnectionResult(firstResult); } @@ -617,30 +596,6 @@ class AppRouter { }; } - showGuide() { - Dashboard.navigate('livetv.html?tab=1'); - } - - goHome() { - Dashboard.navigate('home.html'); - } - - showSearch() { - Dashboard.navigate('search.html'); - } - - showLiveTV() { - Dashboard.navigate('livetv.html'); - } - - showRecordedTV() { - Dashboard.navigate('livetv.html?tab=3'); - } - - showFavorites() { - Dashboard.navigate('home.html?tab=1'); - } - getRouteUrl(item, options) { if (!item) { throw new Error('item cannot be null'); @@ -835,10 +790,53 @@ class AppRouter { return '#!/details?id=' + id + '&serverId=' + serverId; } + + showLocalLogin(serverId) { + return this.show('login.html?serverid=' + serverId); + } + + showVideoOsd() { + return this.show('video'); + } + + showSelectServer() { + return this.show('selectserver.html'); + } + + showSettings() { + return this.show('mypreferencesmenu.html'); + } + + showNowPlaying() { + return this.show('queue'); + } + + showGuide() { + return this.show('livetv.html?tab=1'); + } + + goHome() { + return this.show('home.html'); + } + + showSearch() { + return this.show('search.html'); + } + + showLiveTV() { + return this.show('livetv.html'); + } + + showRecordedTV() { + return this.show('livetv.html?tab=3'); + } + + showFavorites() { + return this.show('home.html?tab=1'); + } } export const appRouter = new AppRouter(); window.Emby = window.Emby || {}; - window.Emby.Page = appRouter; From 5438d3b32c228a262932ecf21e088860dc636269 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 20 Apr 2022 17:40:36 -0400 Subject: [PATCH 2/9] Limit public methods in app router --- src/components/appRouter.js | 150 ++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 76 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 0354d1741..cce0f7910 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -14,10 +14,40 @@ import reactControllerFactory from './reactControllerFactory'; const history = createHashHistory(); +const normalizeImageOptions = options => { + let setQuality; + if (options.maxWidth || options.width || options.maxHeight || options.height || options.fillWidth || options.fillHeight) { + setQuality = true; + } + + if (setQuality && !options.quality) { + options.quality = 90; + } +}; + +const getMaxBandwidth = () => { + /* eslint-disable compat/compat */ + if (navigator.connection) { + let max = navigator.connection.downlinkMax; + if (max && max > 0 && max < Number.POSITIVE_INFINITY) { + max /= 8; + max *= 1000000; + max *= 0.7; + return parseInt(max, 10); + } + } + /* eslint-enable compat/compat */ + + return null; +}; + +/** + * Page types of "no return" (when "Go back" should behave differently, probably quitting the application). + */ +const START_PAGE_TYPES = ['home', 'login', 'selectserver']; + class AppRouter { allRoutes = new Map(); - backdropContainer; - backgroundContainer; currentRouteInfo; currentViewLoadRequest; firstConnectionResult; @@ -26,17 +56,13 @@ class AppRouter { msgTimeout; promiseShow; resolveOnNextShow; - previousRoute = {}; - /** - * Pages of "no return" (when "Go back" should behave differently, probably quitting the application). - */ - startPages = ['home', 'login', 'selectserver']; + previousRoute; constructor() { document.addEventListener('viewshow', () => this.onViewShow()); // TODO: Can this baseRoute logic be simplified? - this.baseRoute = window.location.href.split('?')[0].replace(this.getRequestFile(), ''); + this.baseRoute = window.location.href.split('?')[0].replace(this.#getRequestFile(), ''); // support hashbang this.baseRoute = this.baseRoute.split('#')[0]; if (this.baseRoute.endsWith('/') && !this.baseRoute.endsWith('://')) { @@ -51,13 +77,13 @@ class AppRouter { }); } - beginConnectionWizard() { + #beginConnectionWizard() { clearBackdrop(); loading.show(); ServerConnections.connect({ enableAutoLogin: appSettings.enableAutoLogin() }).then((result) => { - this.handleConnectionResult(result); + this.#handleConnectionResult(result); }); } @@ -107,6 +133,7 @@ class AppRouter { return this.promiseShow; } + // TODO: Unused? async showDirect(path) { if (this.promiseShow) await this.promiseShow; @@ -142,9 +169,9 @@ class AppRouter { start() { loading.show(); - this.initApiClients(); + this.#initApiClients(); - Events.on(appHost, 'resume', this.onAppResume); + Events.on(appHost, 'resume', this.#onAppResume); ServerConnections.connect({ enableAutoLogin: appSettings.enableAutoLogin() @@ -168,22 +195,19 @@ class AppRouter { } canGoBack() { - const curr = this.current(); + const curr = this.currentRouteInfo?.route; if (!curr) { return false; } - if (!document.querySelector('.dialogContainer') && this.startPages.indexOf(curr.type) !== -1) { + if (!document.querySelector('.dialogContainer') && START_PAGE_TYPES.includes(curr.type)) { return false; } return window.history.length > 1; } - current() { - return this.currentRouteInfo ? this.currentRouteInfo.route : null; - } - + // TODO: Unused? invokeShortcut(id) { if (id.indexOf('library-') === 0) { id = id.replace('library-', ''); @@ -231,7 +255,7 @@ class AppRouter { setBackdropTransparency(level); } - handleConnectionResult(result) { + #handleConnectionResult(result) { switch (result.State) { case 'SignedIn': loading.hide(); @@ -262,7 +286,7 @@ class AppRouter { } } - loadContentUrl(ctx, next, route, request) { + #loadContentUrl(ctx, next, route, request) { let url; if (route.contentPath && typeof (route.contentPath) === 'function') { url = route.contentPath(ctx.querystring); @@ -284,19 +308,19 @@ class AppRouter { } promise.then((html) => { - this.loadContent(ctx, route, html, request); + this.#loadContent(ctx, route, html, request); }); } - handleRoute(ctx, next, route) { - this.authenticate(ctx, route, () => { - this.initRoute(ctx, next, route); + #handleRoute(ctx, next, route) { + this.#authenticate(ctx, route, () => { + this.#initRoute(ctx, next, route); }); } - initRoute(ctx, next, route) { + #initRoute(ctx, next, route) { const onInitComplete = (controllerFactory) => { - this.sendRouteToViewManager(ctx, next, route, controllerFactory); + this.#sendRouteToViewManager(ctx, next, route, controllerFactory); }; if (route.pageComponent) { @@ -308,20 +332,21 @@ class AppRouter { } } - cancelCurrentLoadRequest() { + #cancelCurrentLoadRequest() { const currentRequest = this.currentViewLoadRequest; if (currentRequest) { currentRequest.cancel = true; } } - sendRouteToViewManager(ctx, next, route, controllerFactory) { + #sendRouteToViewManager(ctx, next, route, controllerFactory) { + // TODO: isDummyBackToHome is never true? if (this.isDummyBackToHome && route.type === 'home') { this.isDummyBackToHome = false; return; } - this.cancelCurrentLoadRequest(); + this.#cancelCurrentLoadRequest(); const isBackNav = ctx.isBack; const currentRequest = { @@ -343,7 +368,7 @@ class AppRouter { const onNewViewNeeded = () => { if (typeof route.path === 'string') { - this.loadContentUrl(ctx, next, route, currentRequest); + this.#loadContentUrl(ctx, next, route, currentRequest); } else { next(); } @@ -408,54 +433,27 @@ class AppRouter { } } - normalizeImageOptions(options) { - let setQuality; - if (options.maxWidth || options.width || options.maxHeight || options.height || options.fillWidth || options.fillHeight) { - setQuality = true; - } - - if (setQuality && !options.quality) { - options.quality = 90; - } - } - - getMaxBandwidth() { - /* eslint-disable compat/compat */ - if (navigator.connection) { - let max = navigator.connection.downlinkMax; - if (max && max > 0 && max < Number.POSITIVE_INFINITY) { - max /= 8; - max *= 1000000; - max *= 0.7; - return parseInt(max, 10); - } - } - /* eslint-enable compat/compat */ - - return null; - } - onApiClientCreated(e, newApiClient) { - newApiClient.normalizeImageOptions = this.normalizeImageOptions; - newApiClient.getMaxBandwidth = this.getMaxBandwidth; + newApiClient.normalizeImageOptions = normalizeImageOptions; + newApiClient.getMaxBandwidth = getMaxBandwidth; Events.off(newApiClient, 'requestfail', this.onRequestFail); Events.on(newApiClient, 'requestfail', this.onRequestFail); } - initApiClient(apiClient, instance) { + #initApiClient(apiClient, instance) { instance.onApiClientCreated({}, apiClient); } - initApiClients() { + #initApiClients() { ServerConnections.getApiClients().forEach((apiClient) => { - this.initApiClient(apiClient, this); + this.#initApiClient(apiClient, this); }); Events.on(ServerConnections, 'apiclientcreated', this.onApiClientCreated); } - onAppResume() { + #onAppResume() { const apiClient = ServerConnections.currentApiClient(); if (apiClient) { @@ -463,7 +461,7 @@ class AppRouter { } } - authenticate(ctx, route, callback) { + #authenticate(ctx, route, callback) { const firstResult = this.firstConnectionResult; this.firstConnectionResult = null; @@ -478,7 +476,7 @@ class AppRouter { ServerConnections.setLocalApiClient(firstResult.ApiClient); this.show('wizardstart.html'); } else { - this.handleConnectionResult(firstResult); + this.#handleConnectionResult(firstResult); } }).catch(error => { console.error(error); @@ -486,7 +484,7 @@ class AppRouter { return; } else if (firstResult.State !== 'SignedIn') { - this.handleConnectionResult(firstResult); + this.#handleConnectionResult(firstResult); return; } } @@ -500,7 +498,7 @@ class AppRouter { if (!shouldExitApp && (!apiClient || !apiClient.isLoggedIn()) && !route.anonymous) { console.debug('[appRouter] route does not allow anonymous access: redirecting to login'); - this.beginConnectionWizard(); + this.#beginConnectionWizard(); return; } @@ -520,9 +518,9 @@ class AppRouter { this.goHome(); return; } else if (route.roles) { - this.validateRoles(apiClient, route.roles).then(() => { + this.#validateRoles(apiClient, route.roles).then(() => { callback(); - }, this.beginConnectionWizard); + }, this.#beginConnectionWizard); return; } } @@ -531,13 +529,13 @@ class AppRouter { callback(); } - validateRoles(apiClient, roles) { + #validateRoles(apiClient, roles) { return Promise.all(roles.split(',').map((role) => { - return this.validateRole(apiClient, role); + return this.#validateRole(apiClient, role); })); } - validateRole(apiClient, role) { + #validateRole(apiClient, role) { if (role === 'admin') { return apiClient.getCurrentUser().then((user) => { if (user.Policy.IsAdministrator) { @@ -551,7 +549,7 @@ class AppRouter { return Promise.resolve(); } - loadContent(ctx, route, html, request) { + #loadContent(ctx, route, html, request) { html = globalize.translateHtml(html, route.dictionary); request.view = html; @@ -565,7 +563,7 @@ class AppRouter { ctx.handled = true; } - getRequestFile() { + #getRequestFile() { let path = window.location.pathname || ''; const index = path.lastIndexOf('/'); @@ -584,7 +582,7 @@ class AppRouter { #getHandler(route) { return (ctx, next) => { - const ignore = route.dummyRoute === true || this.previousRoute.dummyRoute === true; + const ignore = route.dummyRoute === true || this.previousRoute?.dummyRoute === true; this.previousRoute = route; if (ignore) { // Resolve 'show' promise @@ -592,7 +590,7 @@ class AppRouter { return; } - this.handleRoute(ctx, next, route); + this.#handleRoute(ctx, next, route); }; } From a59722126ff9fe75a205baacc0ed5595a527aa19 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 21 Apr 2022 13:43:12 -0400 Subject: [PATCH 3/9] Remove api client setup from app router --- src/components/ServerConnections.js | 38 +++++++++++++- src/components/appRouter.js | 81 +++++------------------------ src/scripts/site.js | 4 ++ 3 files changed, 54 insertions(+), 69 deletions(-) diff --git a/src/components/ServerConnections.js b/src/components/ServerConnections.js index 7e42432b5..e313f4cfd 100644 --- a/src/components/ServerConnections.js +++ b/src/components/ServerConnections.js @@ -1,20 +1,49 @@ import { ConnectionManager, Credentials, ApiClient, Events } from 'jellyfin-apiclient'; + import { appHost } from './apphost'; import Dashboard from '../utils/dashboard'; import { setUserInfo } from '../scripts/settings/userSettings'; +import appSettings from '../scripts/settings/appSettings'; + +const normalizeImageOptions = options => { + if (!options.quality && (options.maxWidth || options.width || options.maxHeight || options.height || options.fillWidth || options.fillHeight)) { + options.quality = 90; + } +}; + +const getMaxBandwidth = () => { + /* eslint-disable compat/compat */ + if (navigator.connection) { + let max = navigator.connection.downlinkMax; + if (max && max > 0 && max < Number.POSITIVE_INFINITY) { + max /= 8; + max *= 1000000; + max *= 0.7; + return parseInt(max, 10); + } + } + /* eslint-enable compat/compat */ + + return null; +}; class ServerConnections extends ConnectionManager { constructor() { super(...arguments); this.localApiClient = null; - Events.on(this, 'localusersignedout', function (eventName, logoutInfo) { + Events.on(this, 'localusersignedout', (_e, logoutInfo) => { setUserInfo(null, null); if (window.NativeShell && typeof window.NativeShell.onLocalUserSignedOut === 'function') { window.NativeShell.onLocalUserSignedOut(logoutInfo); } }); + + Events.on(this, 'apiclientcreated', (_e, apiClient) => { + apiClient.getMaxBandwidth = getMaxBandwidth; + apiClient.normalizeImageOptions = normalizeImageOptions; + }); } initApiClient(server) { @@ -38,6 +67,13 @@ class ServerConnections extends ConnectionManager { console.debug('loaded ApiClient singleton'); } + connect(options) { + return super.connect({ + enableAutoLogin: appSettings.enableAutoLogin(), + options + }); + } + setLocalApiClient(apiClient) { if (apiClient) { this.localApiClient = apiClient; diff --git a/src/components/appRouter.js b/src/components/appRouter.js index cce0f7910..1f84d0bb2 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -2,7 +2,6 @@ import { Events } from 'jellyfin-apiclient'; import { Action, createHashHistory } from 'history'; import { appHost } from './apphost'; -import appSettings from '../scripts/settings/appSettings'; import { clearBackdrop, setBackdropTransparency } from './backdrop/backdrop'; import globalize from '../scripts/globalize'; import itemHelper from './itemHelper'; @@ -14,33 +13,6 @@ import reactControllerFactory from './reactControllerFactory'; const history = createHashHistory(); -const normalizeImageOptions = options => { - let setQuality; - if (options.maxWidth || options.width || options.maxHeight || options.height || options.fillWidth || options.fillHeight) { - setQuality = true; - } - - if (setQuality && !options.quality) { - options.quality = 90; - } -}; - -const getMaxBandwidth = () => { - /* eslint-disable compat/compat */ - if (navigator.connection) { - let max = navigator.connection.downlinkMax; - if (max && max > 0 && max < Number.POSITIVE_INFINITY) { - max /= 8; - max *= 1000000; - max *= 0.7; - return parseInt(max, 10); - } - } - /* eslint-enable compat/compat */ - - return null; -}; - /** * Page types of "no return" (when "Go back" should behave differently, probably quitting the application). */ @@ -80,9 +52,7 @@ class AppRouter { #beginConnectionWizard() { clearBackdrop(); loading.show(); - ServerConnections.connect({ - enableAutoLogin: appSettings.enableAutoLogin() - }).then((result) => { + ServerConnections.connect().then(result => { this.#handleConnectionResult(result); }); } @@ -169,13 +139,18 @@ class AppRouter { start() { loading.show(); - this.#initApiClients(); - Events.on(appHost, 'resume', this.#onAppResume); + ServerConnections.getApiClients().forEach(apiClient => { + Events.off(apiClient, 'requestfail', this.onRequestFail); + Events.on(apiClient, 'requestfail', this.onRequestFail); + }); - ServerConnections.connect({ - enableAutoLogin: appSettings.enableAutoLogin() - }).then((result) => { + Events.on(ServerConnections, 'apiclientcreated', (_e, apiClient) => { + Events.off(apiClient, 'requestfail', this.onRequestFail); + Events.on(apiClient, 'requestfail', this.onRequestFail); + }); + + ServerConnections.connect().then(result => { this.firstConnectionResult = result; // Handle the initial route @@ -239,9 +214,7 @@ class AppRouter { } const url = this.getRouteUrl(item, options); - this.show(url, { - item: item - }); + this.show(url, { item }); } } @@ -417,7 +390,7 @@ class AppRouter { this.msgTimeout = setTimeout(this.onForcedLogoutMessageTimeout, 100); } - onRequestFail(e, data) { + onRequestFail(_e, data) { const apiClient = this; if (data.status === 403) { @@ -433,34 +406,6 @@ class AppRouter { } } - onApiClientCreated(e, newApiClient) { - newApiClient.normalizeImageOptions = normalizeImageOptions; - newApiClient.getMaxBandwidth = getMaxBandwidth; - - Events.off(newApiClient, 'requestfail', this.onRequestFail); - Events.on(newApiClient, 'requestfail', this.onRequestFail); - } - - #initApiClient(apiClient, instance) { - instance.onApiClientCreated({}, apiClient); - } - - #initApiClients() { - ServerConnections.getApiClients().forEach((apiClient) => { - this.#initApiClient(apiClient, this); - }); - - Events.on(ServerConnections, 'apiclientcreated', this.onApiClientCreated); - } - - #onAppResume() { - const apiClient = ServerConnections.currentApiClient(); - - if (apiClient) { - apiClient.ensureWebSocket(); - } - } - #authenticate(ctx, route, callback) { const firstResult = this.firstConnectionResult; diff --git a/src/scripts/site.js b/src/scripts/site.js index 6ec0e7709..6a9b104af 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -163,6 +163,10 @@ async function onAppReady() { import('../assets/css/ios.scss'); } + Events.on(appHost, 'resume', () => { + ServerConnections.currentApiClient()?.ensureWebSocket(); + }); + appRouter.start(); if (!browser.tv && !browser.xboxOne && !browser.ps4) { From c9613718350e1b490e0518cebedbb9c946dcd8e7 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 21 Apr 2022 13:47:12 -0400 Subject: [PATCH 4/9] Remove unused methods in app router --- src/components/appRouter.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 1f84d0bb2..4b915eb1d 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -103,19 +103,6 @@ class AppRouter { return this.promiseShow; } - // TODO: Unused? - async showDirect(path) { - if (this.promiseShow) await this.promiseShow; - - this.promiseShow = new Promise((resolve) => { - this.resolveOnNextShow = resolve; - // Schedule a call to return the promise - setTimeout(() => history.push(this.baseUrl() + path), 0); - }); - - return this.promiseShow; - } - #goToRoute({ location, action }) { // Strip the leading "!" if present const normalizedPath = location.pathname.replace(/^!/, ''); @@ -182,25 +169,6 @@ class AppRouter { return window.history.length > 1; } - // TODO: Unused? - invokeShortcut(id) { - if (id.indexOf('library-') === 0) { - id = id.replace('library-', ''); - id = id.split('_'); - - this.showItem(id[0], id[1]); - } else if (id.indexOf('item-') === 0) { - id = id.replace('item-', ''); - id = id.split('_'); - this.showItem(id[0], id[1]); - } else { - id = id.split('_'); - this.show(this.getRouteUrl(id[0], { - serverId: id[1] - })); - } - } - showItem(item, serverId, options) { // TODO: Refactor this so it only gets items, not strings. if (typeof (item) === 'string') { From 4d4725f05d940c9027b1f8ac61e599557ca27b44 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 21 Apr 2022 13:57:01 -0400 Subject: [PATCH 5/9] Fix code smells --- src/components/appRouter.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 4b915eb1d..1ed134c90 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -24,7 +24,6 @@ class AppRouter { currentViewLoadRequest; firstConnectionResult; forcedLogoutMsg; - isDummyBackToHome; msgTimeout; promiseShow; resolveOnNextShow; @@ -227,7 +226,7 @@ class AppRouter { } } - #loadContentUrl(ctx, next, route, request) { + #loadContentUrl(ctx, _next, route, request) { let url; if (route.contentPath && typeof (route.contentPath) === 'function') { url = route.contentPath(ctx.querystring); @@ -281,12 +280,6 @@ class AppRouter { } #sendRouteToViewManager(ctx, next, route, controllerFactory) { - // TODO: isDummyBackToHome is never true? - if (this.isDummyBackToHome && route.type === 'home') { - this.isDummyBackToHome = false; - return; - } - this.#cancelCurrentLoadRequest(); const isBackNav = ctx.isBack; From dbfc1e27b48cebb323b1248012d36fa891afae2e Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 21 Apr 2022 13:58:39 -0400 Subject: [PATCH 6/9] Fix missing spread operator --- src/components/ServerConnections.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ServerConnections.js b/src/components/ServerConnections.js index e313f4cfd..a15b384f7 100644 --- a/src/components/ServerConnections.js +++ b/src/components/ServerConnections.js @@ -70,7 +70,7 @@ class ServerConnections extends ConnectionManager { connect(options) { return super.connect({ enableAutoLogin: appSettings.enableAutoLogin(), - options + ...options }); } From de0ae288cf96599e05994e121236534ab9426c1d Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 22 Apr 2022 14:30:05 -0400 Subject: [PATCH 7/9] Fix private method access in app router --- src/components/appRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 1ed134c90..b21929d25 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -426,7 +426,7 @@ class AppRouter { } else if (route.roles) { this.#validateRoles(apiClient, route.roles).then(() => { callback(); - }, this.#beginConnectionWizard); + }, this.#beginConnectionWizard.bind(this)); return; } } From df3f53bbc0ec8cb316251adaf63ed4d8fdc6f8c5 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 22 Apr 2022 15:06:17 -0400 Subject: [PATCH 8/9] Remove unnecessary api call in app router --- src/components/appRouter.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index b21929d25..b0a1489ae 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -202,13 +202,7 @@ class AppRouter { this.goHome(); break; case 'ServerSignIn': - result.ApiClient.getPublicUsers().then((users) => { - if (users.length) { - this.showLocalLogin(result.Servers[0].Id); - } else { - this.showLocalLogin(result.Servers[0].Id, true); - } - }); + this.showLocalLogin(result.ApiClient.serverId()); break; case 'ServerSelection': this.showSelectServer(); From 43adbd5490d31eba3088952164733fa605dc669d Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Mon, 25 Apr 2022 16:46:19 -0400 Subject: [PATCH 9/9] Revert single optional check in app router --- src/components/appRouter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/appRouter.js b/src/components/appRouter.js index b0a1489ae..a75d8823d 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -27,7 +27,7 @@ class AppRouter { msgTimeout; promiseShow; resolveOnNextShow; - previousRoute; + previousRoute = {}; constructor() { document.addEventListener('viewshow', () => this.onViewShow()); @@ -482,7 +482,7 @@ class AppRouter { #getHandler(route) { return (ctx, next) => { - const ignore = route.dummyRoute === true || this.previousRoute?.dummyRoute === true; + const ignore = route.dummyRoute === true || this.previousRoute.dummyRoute === true; this.previousRoute = route; if (ignore) { // Resolve 'show' promise