mattermost-mobile/app/utils/tap.js
Orjiewuru Kingdom Isaac 102eeb93fe MM-13151 Increase double tap delay for post action buttons (#2406)
* Use app state to disable a button when click to prevent double tap

* remove disable button state after 4000ms

* modify preventDoubleTap to have optional delayTime param

* remove local state use for button control

* remove unused method

* remove app state method to disable a button

* Update tap.js
2019-04-02 10:22:31 -04:00

17 lines
457 B
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export function preventDoubleTap(func, doublePressDelay = 300) {
let canPressWrapped = true;
return (...args) => {
if (canPressWrapped) {
canPressWrapped = false;
func(...args);
setTimeout(() => {
canPressWrapped = true;
}, doublePressDelay);
}
};
}