|
1 |
| -import { ErrorWithPayload, isObject, isString } from '../../common' |
| 1 | +import { isObject, isString } from '../../common' |
2 | 2 | import { getConfig } from '../../configRegister'
|
3 | 3 | import { shortSwitch } from '../../flow'
|
4 | 4 | import PersistedLog from '../../io/PersistedLog'
|
@@ -113,30 +113,23 @@ const executeTapListener = (() => {
|
113 | 113 | const clickTimer = new Timer()
|
114 | 114 | return (clickMap: ClickMap) => {
|
115 | 115 | clickTimer.timeInterval = getConfig('ON_TAP_CLICK_INTERVAL')
|
116 |
| - const configuredClicks = Object.keys(clickMap).map((numStr) => Number.parseInt(numStr, 10)) |
| 116 | + const maxClicks = Math.max(...Object.keys(clickMap).map((numStr) => Number.parseInt(numStr, 10))) |
117 | 117 | // Every time a tap comes in, restart the timer & increment the counter
|
118 | 118 | tapCount++
|
119 | 119 | clickTimer.invalidate()
|
120 | 120 | const executeFn = async () => {
|
121 |
| - if (configuredClicks.includes(tapCount)) { |
122 |
| - try { |
123 |
| - const action = clickMap[tapCount] |
124 |
| - if (!action) { |
125 |
| - throw new ErrorWithPayload('Action at index not found', { |
126 |
| - tapCount, |
127 |
| - clickKeysPassed: Object.keys(clickMap), |
128 |
| - }) |
129 |
| - } |
130 |
| - await action() |
131 |
| - } catch (e) { |
132 |
| - warnError(e, 'table row') |
133 |
| - } |
| 121 | + try { |
| 122 | + const action = clickMap[tapCount] |
| 123 | + tapCount = 0 |
| 124 | + if (action) await action() |
| 125 | + } catch (e) { |
| 126 | + warnError(e, 'table row') |
134 | 127 | }
|
135 |
| - tapCount = 0 |
136 | 128 | }
|
137 | 129 | // The timer callback will only ever fire if a click timer reaches its full
|
138 | 130 | // duration
|
139 |
| - clickTimer.schedule(executeFn) |
| 131 | + if (maxClicks <= tapCount) executeFn() |
| 132 | + else clickTimer.schedule(executeFn) |
140 | 133 | }
|
141 | 134 | })()
|
142 | 135 |
|
|
0 commit comments