From 4a13e62477b6d271616644001dedacfe8d07f0bb Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 2 Nov 2018 13:03:00 -0400 Subject: [PATCH] cache canLaunch result --- src/models/view/loginUriView.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/models/view/loginUriView.ts b/src/models/view/loginUriView.ts index ae9f5090534..2ac71bd8f2d 100644 --- a/src/models/view/loginUriView.ts +++ b/src/models/view/loginUriView.ts @@ -23,6 +23,7 @@ export class LoginUriView implements View { private _uri: string; private _domain: string; private _hostname: string; + private _canLaunch: boolean; // tslint:enable constructor(u?: LoginUri) { @@ -39,6 +40,7 @@ export class LoginUriView implements View { set uri(value: string) { this._uri = value; this._domain = null; + this._canLaunch = null; } get domain(): string { @@ -72,14 +74,18 @@ export class LoginUriView implements View { } get canLaunch(): boolean { - if (this.uri == null) { - return false; + if (this._canLaunch != null) { + return this._canLaunch; } - for (let i = 0; i < CanLaunchWhitelist.length; i++) { - if (this.uri.indexOf(CanLaunchWhitelist[i]) === 0) { - return true; + if (this.uri != null) { + for (let i = 0; i < CanLaunchWhitelist.length; i++) { + if (this.uri.indexOf(CanLaunchWhitelist[i]) === 0) { + this._canLaunch = true; + return this._canLaunch; + } } } - return false; + this._canLaunch = false; + return this._canLaunch; } }