aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/services/content
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-10-13 13:09:29 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-10-13 13:09:29 +0200
commit6ae97425b0c0da181a9ec26e52535ceadd1f4e46 (patch)
treebe11b973b3cfc906f9b4ad2e3b043fd61d5bdb37 /src/components/services/content
parentImprove QuickSwitch design (diff)
downloadferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.tar.gz
ferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.tar.zst
ferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.zip
Add indicator for hibernating services
Diffstat (limited to 'src/components/services/content')
-rw-r--r--src/components/services/content/ServiceView.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/components/services/content/ServiceView.js b/src/components/services/content/ServiceView.js
index 041e9941d..664a494c1 100644
--- a/src/components/services/content/ServiceView.js
+++ b/src/components/services/content/ServiceView.js
@@ -15,7 +15,7 @@ import SettingsStore from '../../../stores/SettingsStore';
15import WebControlsScreen from '../../../features/webControls/containers/WebControlsScreen'; 15import WebControlsScreen from '../../../features/webControls/containers/WebControlsScreen';
16import { CUSTOM_WEBSITE_ID } from '../../../features/webControls/constants'; 16import { CUSTOM_WEBSITE_ID } from '../../../features/webControls/constants';
17 17
18export default @observer @inject('stores') class ServiceView extends Component { 18export default @observer @inject('stores', 'actions') class ServiceView extends Component {
19 static propTypes = { 19 static propTypes = {
20 service: PropTypes.instanceOf(ServiceModel).isRequired, 20 service: PropTypes.instanceOf(ServiceModel).isRequired,
21 setWebviewReference: PropTypes.func.isRequired, 21 setWebviewReference: PropTypes.func.isRequired,
@@ -27,6 +27,11 @@ export default @observer @inject('stores') class ServiceView extends Component {
27 stores: PropTypes.shape({ 27 stores: PropTypes.shape({
28 settings: PropTypes.instanceOf(SettingsStore).isRequired, 28 settings: PropTypes.instanceOf(SettingsStore).isRequired,
29 }).isRequired, 29 }).isRequired,
30 actions: PropTypes.shape({
31 service: PropTypes.shape({
32 setHibernation: PropTypes.func.isRequired,
33 }).isRequired,
34 }).isRequired,
30 }; 35 };
31 36
32 static defaultProps = { 37 static defaultProps = {
@@ -77,10 +82,24 @@ export default @observer @inject('stores') class ServiceView extends Component {
77 this.setState({ 82 this.setState({
78 hibernate: false, 83 hibernate: false,
79 }); 84 });
85 this.props.actions.service.setHibernation({
86 serviceId: this.props.service.id,
87 hibernating: false,
88 });
80 } 89 }
81 }, 90 },
82 ); 91 );
83 92
93 // Store hibernation status to state, otherwise the webview won't get unloaded correctly
94 reaction(
95 () => this.props.service.isHibernating,
96 () => {
97 this.setState({
98 hibernate: this.props.service.isHibernating,
99 });
100 },
101 );
102
84 // Start hibernation counter if we are in background 103 // Start hibernation counter if we are in background
85 if (!this.props.service.isActive && this.props.stores.settings.all.app.hibernate) { 104 if (!this.props.service.isActive && this.props.stores.settings.all.app.hibernate) {
86 this.startHibernationTimer(); 105 this.startHibernationTimer();
@@ -110,6 +129,10 @@ export default @observer @inject('stores') class ServiceView extends Component {
110 this.setState({ 129 this.setState({
111 hibernate: true, 130 hibernate: true,
112 }); 131 });
132 this.props.actions.service.setHibernation({
133 serviceId: this.props.service.id,
134 hibernating: true,
135 });
113 }, timerDuration); 136 }, timerDuration);
114 137
115 this.setState({ 138 this.setState({