mattermost-mobile/app/utils/tap.js
Harrison Healey a291fdc933 RN-74 Added updated markdown code block view (#855)
* RN-74 Added updated markdown code block view

* Set default channelIsLoading prop to PostList

* RN-74 Fixed uneven line numbers on Android

* RN-74 Prevented double tapping on markdown code blocks
2017-08-21 11:40:42 -03:00

31 lines
755 B
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
const doublePressDelay = 300;
let canPress = true;
export function preventDoubleTap(action, thisArg, ...args) {
if (canPress) {
canPress = false;
Reflect.apply(action, thisArg || null, [...args]);
setTimeout(() => {
canPress = true;
}, doublePressDelay);
}
}
export function wrapWithPreventDoubleTap(func) {
let canPressWrapped = true;
return (...args) => {
if (canPressWrapped) {
canPressWrapped = false;
func(...args);
setTimeout(() => {
canPressWrapped = true;
}, doublePressDelay);
}
};
}