* 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
17 lines
457 B
JavaScript
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);
|
|
}
|
|
};
|
|
}
|