Skip to content

Commit 41ebfa1

Browse files
committed
fix regression with tab handler messing with config screens
1 parent b28b5c3 commit 41ebfa1

File tree

1 file changed

+10
-17
lines changed
  • src/lib/scriptable-utils/UITable/Row

1 file changed

+10
-17
lines changed

src/lib/scriptable-utils/UITable/Row/base.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorWithPayload, isObject, isString } from '../../common'
1+
import { isObject, isString } from '../../common'
22
import { getConfig } from '../../configRegister'
33
import { shortSwitch } from '../../flow'
44
import PersistedLog from '../../io/PersistedLog'
@@ -113,30 +113,23 @@ const executeTapListener = (() => {
113113
const clickTimer = new Timer()
114114
return (clickMap: ClickMap) => {
115115
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)))
117117
// Every time a tap comes in, restart the timer & increment the counter
118118
tapCount++
119119
clickTimer.invalidate()
120120
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')
134127
}
135-
tapCount = 0
136128
}
137129
// The timer callback will only ever fire if a click timer reaches its full
138130
// duration
139-
clickTimer.schedule(executeFn)
131+
if (maxClicks <= tapCount) executeFn()
132+
else clickTimer.schedule(executeFn)
140133
}
141134
})()
142135

0 commit comments

Comments
 (0)