diff options
author | 2021-07-23 10:04:43 +0100 | |
---|---|---|
committer | 2021-07-23 11:04:43 +0200 | |
commit | 012e55ebf87559f2d782e5400fb885df8b80a445 (patch) | |
tree | 1966e58defe2bcd9541ca9a3f4db67a95a6b4249 /src/components/services/tabs | |
parent | Removed references to 'premium' i18n keys that are no longer used. (diff) | |
download | ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.tar.gz ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.tar.zst ferdium-app-012e55ebf87559f2d782e5400fb885df8b80a445.zip |
Fix hibernation mode (#1486)
* Use hibernation strategy from settings instead of hardcoded 5 minutes
* Fix conditions with isHibernationEnabled, previously disableHibernation
* Make service hibernation obey global setting
Also refactors hibernation to move some hibernation enablement logic
into the Service model
* Remove global hibernation enable switch
Implements option 4 from
https://github.com/getferdi/ferdi/pull/1486#issuecomment-860290992
according to
https://github.com/getferdi/ferdi/pull/1486#issuecomment-876558694
* Implements #865 : Add 'hibernate service' and 'wake up service' in the sidebar context menu.
* Removed 'hibernationEnabled' check on main settings screen
Since this is an (imo) incongruous behavior for the first time user.
They will see a message, but with no ability to choose the hibernation strategy.
* Autogenerated files from conflict fixes
Co-authored-by: Kristóf Marussy <kristof@marussy.com>
Co-authored-by: Vijay A <avijayr@protonmail.com>
Diffstat (limited to 'src/components/services/tabs')
-rw-r--r-- | src/components/services/tabs/TabBarSortableList.js | 6 | ||||
-rw-r--r-- | src/components/services/tabs/TabItem.js | 18 | ||||
-rw-r--r-- | src/components/services/tabs/Tabbar.js | 16 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/components/services/tabs/TabBarSortableList.js b/src/components/services/tabs/TabBarSortableList.js index 489027d57..f12d90602 100644 --- a/src/components/services/tabs/TabBarSortableList.js +++ b/src/components/services/tabs/TabBarSortableList.js | |||
@@ -17,6 +17,8 @@ class TabBarSortableList extends Component { | |||
17 | deleteService: PropTypes.func.isRequired, | 17 | deleteService: PropTypes.func.isRequired, |
18 | disableService: PropTypes.func.isRequired, | 18 | disableService: PropTypes.func.isRequired, |
19 | enableService: PropTypes.func.isRequired, | 19 | enableService: PropTypes.func.isRequired, |
20 | hibernateService: PropTypes.func.isRequired, | ||
21 | wakeUpService: PropTypes.func.isRequired, | ||
20 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | 22 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, |
21 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | 23 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, |
22 | } | 24 | } |
@@ -31,6 +33,8 @@ class TabBarSortableList extends Component { | |||
31 | deleteService, | 33 | deleteService, |
32 | disableService, | 34 | disableService, |
33 | enableService, | 35 | enableService, |
36 | hibernateService, | ||
37 | wakeUpService, | ||
34 | openSettings, | 38 | openSettings, |
35 | showMessageBadgeWhenMutedSetting, | 39 | showMessageBadgeWhenMutedSetting, |
36 | showMessageBadgesEvenWhenMuted, | 40 | showMessageBadgesEvenWhenMuted, |
@@ -53,6 +57,8 @@ class TabBarSortableList extends Component { | |||
53 | deleteService={() => deleteService({ serviceId: service.id })} | 57 | deleteService={() => deleteService({ serviceId: service.id })} |
54 | disableService={() => disableService({ serviceId: service.id })} | 58 | disableService={() => disableService({ serviceId: service.id })} |
55 | enableService={() => enableService({ serviceId: service.id })} | 59 | enableService={() => enableService({ serviceId: service.id })} |
60 | hibernateService={() => hibernateService({ serviceId: service.id })} | ||
61 | wakeUpService={() => wakeUpService({ serviceId: service.id })} | ||
56 | openSettings={openSettings} | 62 | openSettings={openSettings} |
57 | showMessageBadgeWhenMutedSetting={showMessageBadgeWhenMutedSetting} | 63 | showMessageBadgeWhenMutedSetting={showMessageBadgeWhenMutedSetting} |
58 | showMessageBadgesEvenWhenMuted={showMessageBadgesEvenWhenMuted} | 64 | showMessageBadgesEvenWhenMuted={showMessageBadgesEvenWhenMuted} |
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 5c3149a11..ccf3333f8 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js | |||
@@ -49,6 +49,14 @@ const messages = defineMessages({ | |||
49 | id: 'tabs.item.enableService', | 49 | id: 'tabs.item.enableService', |
50 | defaultMessage: '!!!Enable Service', | 50 | defaultMessage: '!!!Enable Service', |
51 | }, | 51 | }, |
52 | hibernateService: { | ||
53 | id: 'tabs.item.hibernateService', | ||
54 | defaultMessage: '!!!Hibernate Service', | ||
55 | }, | ||
56 | wakeUpService: { | ||
57 | id: 'tabs.item.wakeUpService', | ||
58 | defaultMessage: '!!!Wake Up Service', | ||
59 | }, | ||
52 | deleteService: { | 60 | deleteService: { |
53 | id: 'tabs.item.deleteService', | 61 | id: 'tabs.item.deleteService', |
54 | defaultMessage: '!!!Delete Service', | 62 | defaultMessage: '!!!Delete Service', |
@@ -101,6 +109,8 @@ const styles = { | |||
101 | deleteService: PropTypes.func.isRequired, | 109 | deleteService: PropTypes.func.isRequired, |
102 | disableService: PropTypes.func.isRequired, | 110 | disableService: PropTypes.func.isRequired, |
103 | enableService: PropTypes.func.isRequired, | 111 | enableService: PropTypes.func.isRequired, |
112 | hibernateService: PropTypes.func.isRequired, | ||
113 | wakeUpService: PropTypes.func.isRequired, | ||
104 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | 114 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, |
105 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | 115 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, |
106 | }; | 116 | }; |
@@ -145,6 +155,8 @@ const styles = { | |||
145 | deleteService, | 155 | deleteService, |
146 | disableService, | 156 | disableService, |
147 | enableService, | 157 | enableService, |
158 | hibernateService, | ||
159 | wakeUpService, | ||
148 | openSettings, | 160 | openSettings, |
149 | showMessageBadgeWhenMutedSetting, | 161 | showMessageBadgeWhenMutedSetting, |
150 | showMessageBadgesEvenWhenMuted, | 162 | showMessageBadgesEvenWhenMuted, |
@@ -181,6 +193,10 @@ const styles = { | |||
181 | label: intl.formatMessage(service.isEnabled ? messages.disableService : messages.enableService), | 193 | label: intl.formatMessage(service.isEnabled ? messages.disableService : messages.enableService), |
182 | click: () => (service.isEnabled ? disableService() : enableService()), | 194 | click: () => (service.isEnabled ? disableService() : enableService()), |
183 | }, { | 195 | }, { |
196 | label: intl.formatMessage(service.isHibernating ? messages.wakeUpService : messages.hibernateService), | ||
197 | click: () => (service.isHibernating ? wakeUpService() : hibernateService()), | ||
198 | enabled: service.canHibernate, | ||
199 | }, { | ||
184 | type: 'separator', | 200 | type: 'separator', |
185 | }, { | 201 | }, { |
186 | label: intl.formatMessage(messages.deleteService), | 202 | label: intl.formatMessage(messages.deleteService), |
@@ -217,7 +233,7 @@ const styles = { | |||
217 | • | 233 | • |
218 | </span> | 234 | </span> |
219 | )} | 235 | )} |
220 | {service.isHibernating && !service.isHibernationEnabled && ( | 236 | {service.isHibernating && ( |
221 | <span className="tab-item__message-count hibernating"> | 237 | <span className="tab-item__message-count hibernating"> |
222 | • | 238 | • |
223 | </span> | 239 | </span> |
diff --git a/src/components/services/tabs/Tabbar.js b/src/components/services/tabs/Tabbar.js index 5e8260ad0..db7a69bfc 100644 --- a/src/components/services/tabs/Tabbar.js +++ b/src/components/services/tabs/Tabbar.js | |||
@@ -17,6 +17,8 @@ export default @observer class TabBar extends Component { | |||
17 | toggleAudio: PropTypes.func.isRequired, | 17 | toggleAudio: PropTypes.func.isRequired, |
18 | deleteService: PropTypes.func.isRequired, | 18 | deleteService: PropTypes.func.isRequired, |
19 | updateService: PropTypes.func.isRequired, | 19 | updateService: PropTypes.func.isRequired, |
20 | hibernateService: PropTypes.func.isRequired, | ||
21 | wakeUpService: PropTypes.func.isRequired, | ||
20 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | 22 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, |
21 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | 23 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, |
22 | }; | 24 | }; |
@@ -55,6 +57,18 @@ export default @observer class TabBar extends Component { | |||
55 | this.toggleService({ serviceId, isEnabled: true }); | 57 | this.toggleService({ serviceId, isEnabled: true }); |
56 | } | 58 | } |
57 | 59 | ||
60 | hibernateService({ serviceId }) { | ||
61 | if (serviceId) { | ||
62 | this.props.hibernateService({ serviceId }); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | wakeUpService({ serviceId }) { | ||
67 | if (serviceId) { | ||
68 | this.props.wakeUpService({ serviceId }); | ||
69 | } | ||
70 | } | ||
71 | |||
58 | render() { | 72 | render() { |
59 | const { | 73 | const { |
60 | services, | 74 | services, |
@@ -83,6 +97,8 @@ export default @observer class TabBar extends Component { | |||
83 | deleteService={deleteService} | 97 | deleteService={deleteService} |
84 | disableService={args => this.disableService(args)} | 98 | disableService={args => this.disableService(args)} |
85 | enableService={args => this.enableService(args)} | 99 | enableService={args => this.enableService(args)} |
100 | hibernateService={args => this.hibernateService(args)} | ||
101 | wakeUpService={args => this.wakeUpService(args)} | ||
86 | openSettings={openSettings} | 102 | openSettings={openSettings} |
87 | distance={20} | 103 | distance={20} |
88 | axis="y" | 104 | axis="y" |