diff options
author | vantezzen <hello@vantezzen.io> | 2019-10-13 13:09:29 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-10-13 13:09:29 +0200 |
commit | 6ae97425b0c0da181a9ec26e52535ceadd1f4e46 (patch) | |
tree | be11b973b3cfc906f9b4ad2e3b043fd61d5bdb37 /src/components/services | |
parent | Improve QuickSwitch design (diff) | |
download | ferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.tar.gz ferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.tar.zst ferdium-app-6ae97425b0c0da181a9ec26e52535ceadd1f4e46.zip |
Add indicator for hibernating services
Diffstat (limited to 'src/components/services')
-rw-r--r-- | src/components/services/content/ServiceView.js | 25 | ||||
-rw-r--r-- | src/components/services/tabs/TabItem.js | 5 |
2 files changed, 29 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'; | |||
15 | import WebControlsScreen from '../../../features/webControls/containers/WebControlsScreen'; | 15 | import WebControlsScreen from '../../../features/webControls/containers/WebControlsScreen'; |
16 | import { CUSTOM_WEBSITE_ID } from '../../../features/webControls/constants'; | 16 | import { CUSTOM_WEBSITE_ID } from '../../../features/webControls/constants'; |
17 | 17 | ||
18 | export default @observer @inject('stores') class ServiceView extends Component { | 18 | export 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({ |
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 8de7dc438..36338a910 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js | |||
@@ -145,6 +145,11 @@ class TabItem extends Component { | |||
145 | • | 145 | • |
146 | </span> | 146 | </span> |
147 | )} | 147 | )} |
148 | {service.isHibernating && ( | ||
149 | <span className="tab-item__message-count hibernating"> | ||
150 | • | ||
151 | </span> | ||
152 | )} | ||
148 | </span> | 153 | </span> |
149 | ); | 154 | ); |
150 | } | 155 | } |