Skip to content

Commit

Permalink
make blank.html "dom-ready" event timeout configurable
Browse files Browse the repository at this point in the history
* config.json: "timeouts.webViewBlankDOMLoaded" number value in milliseconds
* ref: #247
  • Loading branch information
vladimiry committed Feb 2, 2020
1 parent fb4fef5 commit 75e2b5a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/electron-main/storage-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ const CONFIG_UPGRADES: Record<string, (config: Config) => void> = {
}
})();
},
"4.2.2": (config) => {
(() => {
const key = "webViewBlankDOMLoaded";
if (typeof config.timeouts[key] !== "number") {
config.timeouts[key] = INITIAL_STORES.config().timeouts[key];
}
})();
},
};

export function upgradeConfig(config: Config): boolean {
Expand Down
1 change: 1 addition & 0 deletions src/shared/model/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Config extends BaseConfig, Partial<StoreModel.StoreEntity> {
dbBootstrapping: number;
dbSyncing: number;
webViewApiPing: number;
webViewBlankDOMLoaded: number;
domElementsResolving: number;
defaultApiCall: number;
indexingBootstrap: number;
Expand Down
1 change: 1 addition & 0 deletions src/shared/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function initialConfig(): Config {
dbBootstrapping: ONE_MINUTE_MS * 60 * 12, // 12 hours
dbSyncing: ONE_MINUTE_MS * 30, // 30 minutes
webViewApiPing: ONE_SECOND_MS * 15,
webViewBlankDOMLoaded: ONE_SECOND_MS * 15,
domElementsResolving: ONE_SECOND_MS * 20,
defaultApiCall: DEFAULT_API_CALL_TIMEOUT,
databaseLoading: ONE_MINUTE_MS * 5, // 5 minutes
Expand Down
19 changes: 12 additions & 7 deletions src/web/browser-window/app/_core/core.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import {filter, first, takeUntil} from "rxjs/operators";
import {timer} from "rxjs";

import {AppAction, NAVIGATION_ACTIONS} from "src/web/browser-window/app/store/actions";
import {
ONE_SECOND_MS,
PROVIDER_REPOS,
WEB_CLIENTS_BLANK_HTML_FILE_NAME,
WEB_VIEW_SESSION_STORAGE_KEY_SKIP_LOGIN_DELAYS
} from "src/shared/constants";
import {Config} from "src/shared/model/options";
import {ElectronService} from "src/web/browser-window/app/_core/electron.service";
import {PROVIDER_REPOS, WEB_CLIENTS_BLANK_HTML_FILE_NAME, WEB_VIEW_SESSION_STORAGE_KEY_SKIP_LOGIN_DELAYS} from "src/shared/constants";
import {ProtonClientSession} from "src/shared/model/proton";
import {SETTINGS_OUTLET, SETTINGS_PATH} from "src/web/browser-window/app/app.constants";
import {State} from "src/web/browser-window/app/store/reducers/root";
import {WebAccount} from "src/web/browser-window/app/model";

@Injectable()
export class CoreService {
private webViewBlankDOMLoadedTimeoutMs?: Config["timeouts"]["webViewBlankDOMLoaded"];

constructor(
private electron: ElectronService,
private store: Store<State>,
private zone: NgZone,
) {}
Expand Down Expand Up @@ -57,9 +57,14 @@ export class CoreService {
setWebViewSrc: (src: string) => void,
clientSession?: ProtonClientSession,
) {
if (typeof this.webViewBlankDOMLoadedTimeoutMs === "undefined") {
const config = await this.electron.ipcMainClient()("readConfig")();
this.webViewBlankDOMLoadedTimeoutMs = config.timeouts.webViewBlankDOMLoaded;
}

const loaderId = new UUID(4).format();
const loaderIdParam = "loader-id";
const loaderIdTimeoutMs = ONE_SECOND_MS * 2;
const loaderIdTimeoutMs = this.webViewBlankDOMLoadedTimeoutMs;
const loaderSrcOrigin = new URL(this.parseEntryUrl(accountConfig, repoType).entryUrl).origin;
const loaderSrc = `${loaderSrcOrigin}/${WEB_CLIENTS_BLANK_HTML_FILE_NAME}?${loaderIdParam}=${loaderId}`;
let webView: Electron.WebviewTag | undefined;
Expand Down

0 comments on commit 75e2b5a

Please sign in to comment.