Skip to content

Commit

Permalink
BrowserView: Improvements to loading indicator.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsvipul committed Jul 25, 2019
1 parent a9095d0 commit 6769ed3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions app/main/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class View extends BrowserView {
index: number;
url: string;
zoomFactor: number;
loading: boolean;
customCSS: boolean;

constructor(public props: ViewProps) {
Expand All @@ -32,7 +31,6 @@ export class View extends BrowserView {
this.index = props.index;
this.url = props.url;
this.zoomFactor = 1.0;
this.loading = false;
this.customCSS = ConfigUtil.getConfigItem('customCSS');
this.registerListeners();
}
Expand All @@ -57,19 +55,15 @@ export class View extends BrowserView {
});

this.webContents.addListener('did-start-loading', () => {
const isSettingsPage = this.url.includes('renderer/preference.html');
if (!isSettingsPage) {
this.sendAction('switch-loading', true, this.url);
}
this.switchLoadingIndicator(true);
});

this.webContents.addListener('dom-ready', () => {
this.loading = false;
this.sendAction('switch-loading', false, this.url);
});

this.webContents.addListener('did-stop-loading', () => {
this.sendAction('switch-loading', false, this.url);
this.switchLoadingIndicator(false);
});

this.webContents.addListener('page-title-updated', (e: Event, title: string) => {
Expand Down Expand Up @@ -107,10 +101,17 @@ export class View extends BrowserView {
}

reload(): void {
this.loading = true;
this.switchLoadingIndicator(true);
this.webContents.reload();
}

switchLoadingIndicator(state: boolean): void {
const isSettingsPage = this.url.includes('renderer/preference.html');
if (!isSettingsPage) {
this.sendAction('switch-loading', state, this.url);
}
}

forward(): void {
if (this.webContents.canGoForward()) {
this.webContents.goForward();
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="action-button" id="reload-action" title="Reload">
<i class="material-icons md-48">refresh</i>
</div>
<div class="action-button" id="loading-action" title="Loading">
<div class="action-button disable" id="loading-action" title="Loading">
<i class="refresh material-icons md-48">loop</i>
</div>
<div class="action-button disable" id="back-action" title="Go Back">
Expand Down

0 comments on commit 6769ed3

Please sign in to comment.