aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/actions/service.js4
-rw-r--r--src/components/services/content/ServiceView.js25
-rw-r--r--src/components/services/tabs/TabItem.js5
-rw-r--r--src/features/quickSwitch/Component.js1
-rw-r--r--src/models/Service.js2
-rw-r--r--src/stores/ServicesStore.js6
-rw-r--r--src/styles/tabs.scss7
7 files changed, 48 insertions, 2 deletions
diff --git a/src/actions/service.js b/src/actions/service.js
index 68c62d594..99f4b3610 100644
--- a/src/actions/service.js
+++ b/src/actions/service.js
@@ -91,4 +91,8 @@ export default {
91 serviceId: PropTypes.string.isRequired, 91 serviceId: PropTypes.string.isRequired,
92 }, 92 },
93 openDevToolsForActiveService: {}, 93 openDevToolsForActiveService: {},
94 setHibernation: {
95 serviceId: PropTypes.string.isRequired,
96 hibernating: PropTypes.bool.isRequired,
97 },
94}; 98};
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({
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 }
diff --git a/src/features/quickSwitch/Component.js b/src/features/quickSwitch/Component.js
index 39e90cb95..797589e9b 100644
--- a/src/features/quickSwitch/Component.js
+++ b/src/features/quickSwitch/Component.js
@@ -43,7 +43,6 @@ const styles = theme => ({
43 services: { 43 services: {
44 width: '100%', 44 width: '100%',
45 maxHeight: '50vh', 45 maxHeight: '50vh',
46 marginTop: 30,
47 overflow: 'scroll', 46 overflow: 'scroll',
48 }, 47 },
49 service: { 48 service: {
diff --git a/src/models/Service.js b/src/models/Service.js
index ddc169d47..10b54602f 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -36,6 +36,8 @@ export default class Service {
36 36
37 @observable isMuted = false; 37 @observable isMuted = false;
38 38
39 @observable isHibernating = false;
40
39 @observable team = ''; 41 @observable team = '';
40 42
41 @observable customUrl = ''; 43 @observable customUrl = '';
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 6120ae023..1bf32af9f 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -75,6 +75,7 @@ export default class ServicesStore extends Store {
75 this.actions.service.toggleAudio.listen(this._toggleAudio.bind(this)); 75 this.actions.service.toggleAudio.listen(this._toggleAudio.bind(this));
76 this.actions.service.openDevTools.listen(this._openDevTools.bind(this)); 76 this.actions.service.openDevTools.listen(this._openDevTools.bind(this));
77 this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this)); 77 this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this));
78 this.actions.service.setHibernation.listen(this._setHibernation.bind(this));
78 79
79 this.registerReactions([ 80 this.registerReactions([
80 this._focusServiceReaction.bind(this), 81 this._focusServiceReaction.bind(this),
@@ -648,6 +649,11 @@ export default class ServicesStore extends Store {
648 } 649 }
649 } 650 }
650 651
652 @action _setHibernation({ serviceId, hibernating }) {
653 const service = this.one(serviceId);
654 service.isHibernating = hibernating;
655 }
656
651 // Reactions 657 // Reactions
652 _focusServiceReaction() { 658 _focusServiceReaction() {
653 const service = this.active; 659 const service = this.active;
diff --git a/src/styles/tabs.scss b/src/styles/tabs.scss
index cbd833f04..ee0858687 100644
--- a/src/styles/tabs.scss
+++ b/src/styles/tabs.scss
@@ -64,6 +64,13 @@
64 right: 8px; 64 right: 8px;
65 65
66 &.is-indirect { padding-top: 0; } 66 &.is-indirect { padding-top: 0; }
67 &.hibernating {
68 padding-top: 0;
69 background: $theme-gray;
70 font-size: 0px;
71 min-height: 10px;
72 min-width: 10px;
73 }
67 } 74 }
68 75
69 .tab-item__info-badge { 76 .tab-item__info-badge {