diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-22 21:26:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-22 21:26:10 +0200 |
commit | 982c97011dec4693d60efc42283cf973ec8b07df (patch) | |
tree | ee24f94c8426948c6360ab3816a732f475c9127f /src | |
parent | Move linux distribution specific dependencies to /docs (diff) | |
parent | Merge branch 'develop' into master (diff) | |
download | ferdium-app-982c97011dec4693d60efc42283cf973ec8b07df.tar.gz ferdium-app-982c97011dec4693d60efc42283cf973ec8b07df.tar.zst ferdium-app-982c97011dec4693d60efc42283cf973ec8b07df.zip |
feature(Shortcuts): Add tab cycling with ctrl[+shift]+tab or ctrl+[pageup|pagedown]
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/service.js | 2 | ||||
-rw-r--r-- | src/stores/AppStore.js | 12 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 24 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/actions/service.js b/src/actions/service.js index 7f429ca32..cdd4bbf16 100644 --- a/src/actions/service.js +++ b/src/actions/service.js | |||
@@ -4,6 +4,8 @@ export default { | |||
4 | setActive: { | 4 | setActive: { |
5 | serviceId: PropTypes.string.isRequired, | 5 | serviceId: PropTypes.string.isRequired, |
6 | }, | 6 | }, |
7 | setActiveNext: {}, | ||
8 | setActivePrev: {}, | ||
7 | showAddServiceInterface: { | 9 | showAddServiceInterface: { |
8 | recipeId: PropTypes.string.isRequired, | 10 | recipeId: PropTypes.string.isRequired, |
9 | }, | 11 | }, |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index a5e0839f2..42ec25204 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -125,6 +125,18 @@ export default class AppStore extends Store { | |||
125 | this.actions.service.openDevToolsForActiveService(); | 125 | this.actions.service.openDevToolsForActiveService(); |
126 | }); | 126 | }); |
127 | 127 | ||
128 | // Set active the next service | ||
129 | key( | ||
130 | '⌘+pagedown, ctrl+pagedown, ⌘+shift+tab, ctrl+shift+tab', () => { | ||
131 | this.actions.service.setActiveNext(); | ||
132 | }); | ||
133 | |||
134 | // Set active the prev service | ||
135 | key( | ||
136 | '⌘+pageup, ctrl+pageup, ⌘+tab, ctrl+tab', () => { | ||
137 | this.actions.service.setActivePrev(); | ||
138 | }); | ||
139 | |||
128 | this.locale = this._getDefaultLocale(); | 140 | this.locale = this._getDefaultLocale(); |
129 | 141 | ||
130 | this._healthCheck(); | 142 | this._healthCheck(); |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 77d2e7da4..19db05494 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -24,6 +24,8 @@ export default class ServicesStore extends Store { | |||
24 | 24 | ||
25 | // Register action handlers | 25 | // Register action handlers |
26 | this.actions.service.setActive.listen(this._setActive.bind(this)); | 26 | this.actions.service.setActive.listen(this._setActive.bind(this)); |
27 | this.actions.service.setActiveNext.listen(this._setActiveNext.bind(this)); | ||
28 | this.actions.service.setActivePrev.listen(this._setActivePrev.bind(this)); | ||
27 | this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this)); | 29 | this.actions.service.showAddServiceInterface.listen(this._showAddServiceInterface.bind(this)); |
28 | this.actions.service.createService.listen(this._createService.bind(this)); | 30 | this.actions.service.createService.listen(this._createService.bind(this)); |
29 | this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this)); | 31 | this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this)); |
@@ -206,6 +208,24 @@ export default class ServicesStore extends Store { | |||
206 | service.isActive = true; | 208 | service.isActive = true; |
207 | } | 209 | } |
208 | 210 | ||
211 | @action _setActiveNext() { | ||
212 | const nextIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), 1, this.enabled.length); | ||
213 | |||
214 | this.all.forEach((s, index) => { | ||
215 | this.all[index].isActive = false; | ||
216 | }); | ||
217 | this.enabled[nextIndex].isActive = true; | ||
218 | } | ||
219 | |||
220 | @action _setActivePrev() { | ||
221 | const prevIndex = this._wrapIndex(this.enabled.findIndex(service => service.isActive), -1, this.enabled.length); | ||
222 | |||
223 | this.all.forEach((s, index) => { | ||
224 | this.all[index].isActive = false; | ||
225 | }); | ||
226 | this.enabled[prevIndex].isActive = true; | ||
227 | } | ||
228 | |||
209 | @action _setUnreadMessageCount({ serviceId, count }) { | 229 | @action _setUnreadMessageCount({ serviceId, count }) { |
210 | const service = this.one(serviceId); | 230 | const service = this.one(serviceId); |
211 | 231 | ||
@@ -500,4 +520,8 @@ export default class ServicesStore extends Store { | |||
500 | _reorderAnalytics = debounce(() => { | 520 | _reorderAnalytics = debounce(() => { |
501 | gaEvent('Service', 'order'); | 521 | gaEvent('Service', 'order'); |
502 | }, 5000); | 522 | }, 5000); |
523 | |||
524 | _wrapIndex(index, delta, size) { | ||
525 | return (((index + delta) % size) + size) % size; | ||
526 | } | ||
503 | } | 527 | } |