diff options
author | 2017-10-19 22:22:10 -0300 | |
---|---|---|
committer | 2017-10-19 22:44:10 -0300 | |
commit | e58f5589edeeedfbd0a4fd9a6e6de94d472be24d (patch) | |
tree | cd0a51ba674cf95f2bbfa55c0494960f24031a1c /src | |
parent | Add build packages suppport for linux: AppImage and deb packages (diff) | |
download | ferdium-app-e58f5589edeeedfbd0a4fd9a6e6de94d472be24d.tar.gz ferdium-app-e58f5589edeeedfbd0a4fd9a6e6de94d472be24d.tar.zst ferdium-app-e58f5589edeeedfbd0a4fd9a6e6de94d472be24d.zip |
Add tab cycling with ctrl[+shift]+tab or ctrl+[pageup|pagedown]
This is related to #35
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..823540076 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.all.findIndex(service => service.isActive), 1, this.all.length); | ||
213 | |||
214 | this.all.forEach((s, index) => { | ||
215 | this.all[index].isActive = false; | ||
216 | }); | ||
217 | this.all[nextIndex].isActive = true; | ||
218 | } | ||
219 | |||
220 | @action _setActivePrev() { | ||
221 | const prevIndex = this._wrapIndex(this.all.findIndex(service => service.isActive), -1, this.all.length); | ||
222 | |||
223 | this.all.forEach((s, index) => { | ||
224 | this.all[index].isActive = false; | ||
225 | }); | ||
226 | this.all[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 | } |