From 102eeb93fe86ded8de9b012b20d9f1ebaf0eaa2d Mon Sep 17 00:00:00 2001 From: Orjiewuru Kingdom Isaac Date: Tue, 2 Apr 2019 15:22:31 +0100 Subject: [PATCH] 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 --- .../message_attachments/action_button/action_button.js | 2 +- app/utils/tap.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/components/message_attachments/action_button/action_button.js b/app/components/message_attachments/action_button/action_button.js index 52facdfc1..4209dc68a 100644 --- a/app/components/message_attachments/action_button/action_button.js +++ b/app/components/message_attachments/action_button/action_button.js @@ -23,7 +23,7 @@ export default class ActionButton extends PureComponent { handleActionPress = preventDoubleTap(() => { const {actions, id, postId} = this.props; actions.doPostAction(postId, id); - }); + }, 4000); render() { const {name, theme} = this.props; diff --git a/app/utils/tap.js b/app/utils/tap.js index a978b0edc..a8ad69c4d 100644 --- a/app/utils/tap.js +++ b/app/utils/tap.js @@ -1,9 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -const doublePressDelay = 300; - -export function preventDoubleTap(func) { +export function preventDoubleTap(func, doublePressDelay = 300) { let canPressWrapped = true; return (...args) => {