Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a less-obstrusive progress bar on top of the Ferdium window #285

Merged
merged 1 commit into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"react-router": "3.2.6",
"react-sortable-hoc": "2.0.0",
"react-tooltip": "4.2.21",
"react-topbar-progress-indicator": "4.1.1",
"route-parser": "0.0.5",
"semver": "7.3.7",
"sqlite3": "5.0.8",
Expand Down
15 changes: 13 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render } from 'react-dom';
import { Provider } from 'mobx-react';
import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';
import { hashHistory } from 'react-router';
import TopBarProgress from 'react-topbar-progress-indicator';

import ServerApi from './api/server/ServerApi';
import LocalApi from './api/server/LocalApi';
Expand Down Expand Up @@ -53,8 +54,8 @@ window.addEventListener('load', () => {
// TODO: send this request to the recipe.js
window.addEventListener('mouseup', e => {
if (e.button === 3 || e.button === 4) {
e.preventDefault()
e.stopPropagation()
e.preventDefault()
e.stopPropagation()
}
});

Expand All @@ -63,3 +64,13 @@ window.addEventListener('dragover', event => event.preventDefault());
window.addEventListener('drop', event => event.preventDefault());
window.addEventListener('dragover', event => event.stopPropagation());
window.addEventListener('drop', event => event.stopPropagation());

TopBarProgress.config({
barThickness: 4,
barColors: {
'0': '#f00',
'0.5': '#0f0',
'1.0': '#00f',
},
shadowBlur: 5
});
6 changes: 5 additions & 1 deletion src/components/services/content/ServiceView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable react/jsx-no-useless-fragment */
import { Component, Fragment } from 'react';
import { Component } from 'react';
import PropTypes from 'prop-types';
import { autorun } from 'mobx';
import { observer, inject } from 'mobx-react';
import classnames from 'classnames';
import TopBarProgress from 'react-topbar-progress-indicator';

import ServiceModel from '../../../models/Service';
import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl';
Expand Down Expand Up @@ -113,6 +114,9 @@ class ServiceView extends Component {
!service.isServiceAccessRestricted && (
<WebviewLoader loaded={false} name={service.name} />
)}
{service.isLoadingPage && !service.isFirstLoad && (
<TopBarProgress />
)}
{service.isError && (
<WebviewErrorHandler
name={service.recipe.name}
Expand Down
12 changes: 12 additions & 0 deletions src/models/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export default class Service {

@observable isLoading = true;

@observable isLoadingPage = true;

@observable isError = false;

@observable errorMessage = '';
Expand Down Expand Up @@ -383,11 +385,20 @@ export default class Service {

this.hasCrashed = false;
this.isLoading = true;
this.isLoadingPage = true;
this.isError = false;
});

this.webview.addEventListener('did-stop-loading', event => {
debug('Did stop load', this.name, event);

this.isLoading = false;
this.isLoadingPage = false;
});

const didLoad = () => {
this.isLoading = false;
this.isLoadingPage = false;

if (!this.isError) {
this.isFirstLoad = false;
Expand All @@ -407,6 +418,7 @@ export default class Service {
this.isError = true;
this.errorMessage = event.errorDescription;
this.isLoading = false;
this.isLoadingPage = false;
}
});

Expand Down