MM-9647 Replaced usage of preventDoubleTap with wrapWithPreventDoubleTap (#1471)
* MM-9467 Replaced usage of preventDoubleTap with wrapWithPreventDoubleTap * MM-9467 Renamed wrapWithPreventDoubleTap to preventDoubleTap
This commit is contained in:
parent
30f0f6eef3
commit
80c09b588d
32 changed files with 112 additions and 114 deletions
|
|
@ -14,7 +14,7 @@ import {intlShape} from 'react-intl';
|
|||
|
||||
import Badge from 'app/components/badge';
|
||||
import ChannelIcon from 'app/components/channel_icon';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
const {View: AnimatedView} = Animated;
|
||||
|
|
@ -40,7 +40,7 @@ export default class ChannelItem extends PureComponent {
|
|||
intl: intlShape,
|
||||
};
|
||||
|
||||
onPress = wrapWithPreventDoubleTap(() => {
|
||||
onPress = preventDoubleTap(() => {
|
||||
const {channelId, currentChannelId, displayName, fake, onSelectChannel, type} = this.props;
|
||||
requestAnimationFrame(() => {
|
||||
onSelectChannel({id: channelId, display_name: displayName, fake, type}, currentChannelId);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {debounce} from 'mattermost-redux/actions/helpers';
|
|||
import ChannelItem from 'app/components/channel_drawer/channels_list/channel_item';
|
||||
import UnreadIndicator from 'app/components/channel_drawer/channels_list/unread_indicator';
|
||||
import {ListTypes} from 'app/constants';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity} from 'app/utils/theme';
|
||||
|
||||
const VIEWABILITY_CONFIG = {
|
||||
|
|
@ -148,7 +148,7 @@ export default class List extends PureComponent {
|
|||
return sections;
|
||||
};
|
||||
|
||||
goToCreatePrivateChannel = wrapWithPreventDoubleTap(() => {
|
||||
goToCreatePrivateChannel = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
const {intl} = this.context;
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ export default class List extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToDirectMessages = wrapWithPreventDoubleTap(() => {
|
||||
goToDirectMessages = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
const {intl} = this.context;
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ export default class List extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToMoreChannels = wrapWithPreventDoubleTap(() => {
|
||||
goToMoreChannels = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
const {intl} = this.context;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
||||
|
||||
import Badge from 'app/components/badge';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
export default class SwitchTeamsButton extends React.PureComponent {
|
||||
|
|
@ -25,7 +25,7 @@ export default class SwitchTeamsButton extends React.PureComponent {
|
|||
theme: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
showTeams = wrapWithPreventDoubleTap(() => {
|
||||
showTeams = preventDoubleTap(() => {
|
||||
this.props.onShowTeams();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
|||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
import {ListTypes, ViewTypes} from 'app/constants';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import tracker from 'app/utils/time_tracker';
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class TeamsList extends PureComponent {
|
|||
});
|
||||
};
|
||||
|
||||
goToSelectTeam = wrapWithPreventDoubleTap(() => {
|
||||
goToSelectTeam = preventDoubleTap(() => {
|
||||
const {currentUrl, intl, navigator, theme} = this.props;
|
||||
|
||||
navigator.showModal({
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
import IonIcon from 'react-native-vector-icons/Ionicons';
|
||||
|
||||
import Badge from 'app/components/badge';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
export default class TeamsListItem extends React.PureComponent {
|
||||
|
|
@ -26,7 +26,7 @@ export default class TeamsListItem extends React.PureComponent {
|
|||
theme: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
selectTeam = wrapWithPreventDoubleTap(() => {
|
||||
selectTeam = preventDoubleTap(() => {
|
||||
this.props.selectTeam(this.props.teamId);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class ChannelIntro extends PureComponent {
|
|||
return currentChannelMembers.map((member) => (
|
||||
<TouchableOpacity
|
||||
key={member.id}
|
||||
onPress={() => preventDoubleTap(this.goToUserProfile, this, member.id)}
|
||||
onPress={preventDoubleTap(() => this.goToUserProfile(member.id))}
|
||||
style={style.profile}
|
||||
>
|
||||
<ProfilePicture
|
||||
|
|
@ -89,7 +89,7 @@ class ChannelIntro extends PureComponent {
|
|||
return currentChannelMembers.map((member, index) => (
|
||||
<TouchableOpacity
|
||||
key={member.id}
|
||||
onPress={() => preventDoubleTap(this.goToUserProfile, this, member.id)}
|
||||
onPress={preventDoubleTap(() => this.goToUserProfile(member.id))}
|
||||
>
|
||||
<Text style={style.displayName}>
|
||||
{index === currentChannelMembers.length - 1 ? this.getDisplayName(member) : `${this.getDisplayName(member)}, `}
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ export default class FileAttachmentList extends Component {
|
|||
this.props.onPress();
|
||||
};
|
||||
|
||||
handlePreviewPress = (file) => {
|
||||
handlePreviewPress = preventDoubleTap((file) => {
|
||||
this.props.hideOptionsContext();
|
||||
Keyboard.dismiss();
|
||||
preventDoubleTap(this.goToImagePreview, this, this.props.postId, file.id);
|
||||
};
|
||||
this.goToImagePreview(this.props.postId, file.id);
|
||||
});
|
||||
|
||||
handlePressIn = () => {
|
||||
this.props.toggleSelected(true);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {
|
|||
import CustomPropTypes from 'app/constants/custom_prop_types';
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
import {getDisplayNameForLanguage} from 'app/utils/markdown';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import mattermostManaged from 'app/mattermost_managed';
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class MarkdownCodeBlock extends React.PureComponent {
|
|||
language: '',
|
||||
};
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(() => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
|
||||
const languageDisplayName = getDisplayNameForLanguage(this.props.language);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from 'react-native';
|
||||
import LinearGradient from 'react-native-linear-gradient';
|
||||
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
const MAX_HEIGHT = 120;
|
||||
|
|
@ -35,7 +35,7 @@ export default class MarkdownTable extends React.PureComponent {
|
|||
};
|
||||
}
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(() => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
|
||||
navigator.push({
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {intlShape} from 'react-intl';
|
|||
import {Text} from 'react-native';
|
||||
|
||||
import CustomPropTypes from 'app/constants/custom_prop_types';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
|
||||
export default class MarkdownTableImage extends React.PureComponent {
|
||||
static propTypes = {
|
||||
|
|
@ -23,7 +23,7 @@ export default class MarkdownTableImage extends React.PureComponent {
|
|||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(() => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
|
||||
navigator.push({
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import PostHeader from 'app/components/post_header';
|
|||
import PostProfilePicture from 'app/components/post_profile_picture';
|
||||
import {NavigationTypes} from 'app/constants';
|
||||
import {emptyFunction} from 'app/utils/general';
|
||||
import {preventDoubleTap, wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import {getToolTipVisible} from 'app/utils/tooltip';
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ class Post extends PureComponent {
|
|||
this.props.actions.addReaction(post.id, emoji);
|
||||
}
|
||||
|
||||
handleAddReaction = wrapWithPreventDoubleTap(() => {
|
||||
handleAddReaction = preventDoubleTap(() => {
|
||||
const {intl, navigator, post, theme} = this.props;
|
||||
|
||||
MaterialIcon.getImageSource('close', 20, theme.sidebarHeaderTextColor).
|
||||
|
|
@ -258,7 +258,7 @@ class Post extends PureComponent {
|
|||
});
|
||||
};
|
||||
|
||||
handlePress = () => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
const {
|
||||
isSearchResult,
|
||||
onPress,
|
||||
|
|
@ -267,21 +267,21 @@ class Post extends PureComponent {
|
|||
|
||||
if (!getToolTipVisible()) {
|
||||
if (onPress && post.state !== Posts.POST_DELETED && !isSystemMessage(post) && !isPostPendingOrFailed(post)) {
|
||||
preventDoubleTap(onPress, null, post);
|
||||
onPress(post);
|
||||
} else if (!isSearchResult && isPostEphemeral(post)) {
|
||||
preventDoubleTap(this.onRemovePost, this, post);
|
||||
this.onRemovePost(post);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
handleReply = () => {
|
||||
handleReply = preventDoubleTap(() => {
|
||||
const {post, onReply} = this.props;
|
||||
if (!getToolTipVisible() && onReply) {
|
||||
return preventDoubleTap(onReply, null, post);
|
||||
return onReply(post);
|
||||
}
|
||||
|
||||
return this.handlePress();
|
||||
};
|
||||
});
|
||||
|
||||
onRemovePost = (post) => {
|
||||
const {removePost} = this.props.actions;
|
||||
|
|
@ -319,13 +319,13 @@ class Post extends PureComponent {
|
|||
return <View style={replyBarStyle}/>;
|
||||
};
|
||||
|
||||
viewUserProfile = () => {
|
||||
viewUserProfile = preventDoubleTap(() => {
|
||||
const {isSearchResult} = this.props;
|
||||
|
||||
if (!isSearchResult && !getToolTipVisible()) {
|
||||
preventDoubleTap(this.goToUserProfile, this);
|
||||
this.goToUserProfile();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
toggleSelected = (selected) => {
|
||||
if (!getToolTipVisible()) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import SafeAreaView from 'app/components/safe_area_view';
|
|||
import Drawer from 'app/components/drawer';
|
||||
import UserStatus from 'app/components/user_status';
|
||||
import {NavigationTypes} from 'app/constants';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import DrawerItem from './drawer_item';
|
||||
|
|
@ -135,7 +135,7 @@ export default class SettingsDrawer extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
handleSetStatus = wrapWithPreventDoubleTap(() => {
|
||||
handleSetStatus = preventDoubleTap(() => {
|
||||
const items = [{
|
||||
action: () => this.setStatus(General.ONLINE),
|
||||
text: {
|
||||
|
|
@ -179,7 +179,7 @@ export default class SettingsDrawer extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToEditProfile = wrapWithPreventDoubleTap(() => {
|
||||
goToEditProfile = preventDoubleTap(() => {
|
||||
const {currentUser, navigator, theme} = this.props;
|
||||
const {formatMessage} = this.context.intl;
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ export default class SettingsDrawer extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToSettings = wrapWithPreventDoubleTap(() => {
|
||||
goToSettings = preventDoubleTap(() => {
|
||||
const {intl} = this.context;
|
||||
const {navigator, theme} = this.props;
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ export default class SettingsDrawer extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
logout = wrapWithPreventDoubleTap(() => {
|
||||
logout = preventDoubleTap(() => {
|
||||
const {logout} = this.props.actions;
|
||||
this.closeSettingsDrawer();
|
||||
InteractionManager.runAfterInteractions(logout);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {Text} from 'react-native';
|
|||
import PropTypes from 'prop-types';
|
||||
import Button from 'react-native-button';
|
||||
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
export default class InteractiveAction extends PureComponent {
|
||||
|
|
@ -20,7 +20,7 @@ export default class InteractiveAction extends PureComponent {
|
|||
theme: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
handleActionPress = wrapWithPreventDoubleTap(() => {
|
||||
handleActionPress = preventDoubleTap(() => {
|
||||
const {actions, id, postId} = this.props;
|
||||
actions.doPostAction(postId, id);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import OfflineIndicator from 'app/components/offline_indicator';
|
|||
import PostListRetry from 'app/components/post_list_retry';
|
||||
import SafeAreaView from 'app/components/safe_area_view';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import PostTextbox from 'app/components/post_textbox';
|
||||
import networkConnectionListener from 'app/utils/network';
|
||||
|
|
@ -119,7 +119,7 @@ class Channel extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
goToChannelInfo = wrapWithPreventDoubleTap(() => {
|
||||
goToChannelInfo = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
const options = {
|
||||
screen: 'ChannelInfo',
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import Icon from 'react-native-vector-icons/Ionicons';
|
|||
import Badge from 'app/components/badge';
|
||||
import PushNotifications from 'app/push_notifications';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import {getUnreadsInCurrentTeam} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
|
@ -75,7 +75,7 @@ class ChannelDrawerButton extends PureComponent {
|
|||
this.setState({opacity: value > 0 ? 0.1 : 1});
|
||||
};
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(() => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
this.props.openDrawer();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from 'react-native';
|
||||
import AwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
||||
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
const SEARCH = 'search';
|
||||
|
|
@ -27,7 +27,7 @@ export default class ChannelSearchButton extends PureComponent {
|
|||
theme: PropTypes.object,
|
||||
};
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(async () => {
|
||||
handlePress = preventDoubleTap(async () => {
|
||||
const {actions, navigator, theme} = this.props;
|
||||
|
||||
await actions.clearSearch();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
import Icon from 'react-native-vector-icons/Ionicons';
|
||||
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
class SettingDrawerButton extends PureComponent {
|
||||
|
|
@ -25,7 +25,7 @@ class SettingDrawerButton extends PureComponent {
|
|||
theme: {},
|
||||
};
|
||||
|
||||
handlePress = wrapWithPreventDoubleTap(() => {
|
||||
handlePress = preventDoubleTap(() => {
|
||||
this.props.openDrawer();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from 'react-native';
|
||||
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {alertErrorWithFallback} from 'app/utils/general';
|
||||
import {changeOpacity, makeStyleSheetFromTheme, setNavigatorStyles} from 'app/utils/theme';
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class ChannelInfo extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
goToChannelAddMembers = wrapWithPreventDoubleTap(() => {
|
||||
goToChannelAddMembers = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
backButtonTitle: '',
|
||||
|
|
@ -97,7 +97,7 @@ class ChannelInfo extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToChannelMembers = wrapWithPreventDoubleTap(() => {
|
||||
goToChannelMembers = preventDoubleTap(() => {
|
||||
const {canManageUsers, intl, navigator, theme} = this.props;
|
||||
const id = canManageUsers ? 'channel_header.manageMembers' : 'channel_header.viewMembers';
|
||||
const defaultMessage = canManageUsers ? 'Manage Members' : 'View Members';
|
||||
|
|
@ -116,7 +116,7 @@ class ChannelInfo extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
handleChannelEdit = wrapWithPreventDoubleTap(() => {
|
||||
handleChannelEdit = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
const id = 'mobile.channel_info.edit';
|
||||
const defaultMessage = 'Edit Channel';
|
||||
|
|
@ -143,7 +143,7 @@ class ChannelInfo extends PureComponent {
|
|||
this.handleDeleteOrLeave('delete');
|
||||
};
|
||||
|
||||
handleDeleteOrLeave = wrapWithPreventDoubleTap((eventType) => {
|
||||
handleDeleteOrLeave = preventDoubleTap((eventType) => {
|
||||
const {formatMessage} = this.props.intl;
|
||||
const channel = this.props.currentChannel;
|
||||
const term = channel.type === General.OPEN_CHANNEL ?
|
||||
|
|
@ -207,7 +207,7 @@ class ChannelInfo extends PureComponent {
|
|||
);
|
||||
});
|
||||
|
||||
handleClose = wrapWithPreventDoubleTap(() => {
|
||||
handleClose = preventDoubleTap(() => {
|
||||
const {currentChannel, isCurrent, isFavorite} = this.props;
|
||||
const channel = Object.assign({}, currentChannel, {isCurrent}, {isFavorite});
|
||||
const {closeDMChannel, closeGMChannel} = this.props.actions;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import StatusBar from 'app/components/status_bar/index';
|
|||
import ProfilePicture from 'app/components/profile_picture/index';
|
||||
import AttachmentButton from 'app/components/attachment_button';
|
||||
import {emptyFunction} from 'app/utils/general';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import EditProfileItem from './edit_profile_item';
|
||||
|
|
@ -142,7 +142,7 @@ export default class EditProfile extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
submitUser = wrapWithPreventDoubleTap(async () => {
|
||||
submitUser = preventDoubleTap(async () => {
|
||||
this.emitCanUpdateAccount(false);
|
||||
this.setState({error: null, updating: true});
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import FormattedText from 'app/components/formatted_text';
|
|||
import StatusBar from 'app/components/status_bar';
|
||||
import PushNotifications from 'app/push_notifications';
|
||||
import {GlobalStyles} from 'app/styles';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import tracker from 'app/utils/time_tracker';
|
||||
|
||||
import logo from 'assets/images/logo.png';
|
||||
|
|
@ -134,7 +134,7 @@ class Login extends PureComponent {
|
|||
Keyboard.dismiss();
|
||||
};
|
||||
|
||||
preSignIn = wrapWithPreventDoubleTap(() => {
|
||||
preSignIn = preventDoubleTap(() => {
|
||||
this.setState({error: null, isLoading: true});
|
||||
Keyboard.dismiss();
|
||||
InteractionManager.runAfterInteractions(async () => {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class LoginOptions extends PureComponent {
|
|||
Orientation.removeOrientationListener(this.orientationDidChange);
|
||||
}
|
||||
|
||||
goToLogin = () => {
|
||||
goToLogin = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
screen: 'Login',
|
||||
|
|
@ -54,7 +54,7 @@ class LoginOptions extends PureComponent {
|
|||
screenBackgroundColor: theme.centerChannelBg,
|
||||
},
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
goToSSO = (ssoType) => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
|
|
@ -98,7 +98,7 @@ class LoginOptions extends PureComponent {
|
|||
return (
|
||||
<Button
|
||||
key='email'
|
||||
onPress={() => preventDoubleTap(this.goToLogin, this)}
|
||||
onPress={this.goToLogin}
|
||||
containerStyle={[GlobalStyles.signupButton, additionalStyle]}
|
||||
>
|
||||
<FormattedText
|
||||
|
|
@ -149,7 +149,7 @@ class LoginOptions extends PureComponent {
|
|||
return (
|
||||
<Button
|
||||
key='ldap'
|
||||
onPress={() => preventDoubleTap(this.goToLogin, this)}
|
||||
onPress={this.goToLogin}
|
||||
containerStyle={[GlobalStyles.signupButton, additionalStyle]}
|
||||
>
|
||||
{buttonText}
|
||||
|
|
@ -169,7 +169,7 @@ class LoginOptions extends PureComponent {
|
|||
return (
|
||||
<Button
|
||||
key='gitlab'
|
||||
onPress={() => preventDoubleTap(this.goToSSO, this, ViewTypes.GITLAB)}
|
||||
onPress={preventDoubleTap(() => this.goToSSO(ViewTypes.GITLAB))}
|
||||
containerStyle={[GlobalStyles.signupButton, {backgroundColor: '#548'}]}
|
||||
>
|
||||
<Image
|
||||
|
|
@ -208,7 +208,7 @@ class LoginOptions extends PureComponent {
|
|||
return (
|
||||
<Button
|
||||
key='saml'
|
||||
onPress={() => preventDoubleTap(this.goToSSO, this, ViewTypes.SAML)}
|
||||
onPress={preventDoubleTap(() => this.goToSSO(ViewTypes.SAML))}
|
||||
containerStyle={[GlobalStyles.signupButton, additionalStyle]}
|
||||
>
|
||||
<Text
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import FormattedText from 'app/components/formatted_text';
|
|||
import StatusBar from 'app/components/status_bar';
|
||||
import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_localized_placeholder';
|
||||
import {GlobalStyles} from 'app/styles';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
|
||||
import logo from 'assets/images/logo.png';
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ export default class Mfa extends PureComponent {
|
|||
this.textInput.refs.wrappedInstance.blur();
|
||||
};
|
||||
|
||||
submit = wrapWithPreventDoubleTap(() => {
|
||||
submit = preventDoubleTap(() => {
|
||||
Keyboard.dismiss();
|
||||
if (!this.state.token) {
|
||||
this.setState({
|
||||
|
|
|
|||
|
|
@ -20,8 +20,14 @@ export default class OptionsModalList extends PureComponent {
|
|||
onCancelPress: PropTypes.func,
|
||||
};
|
||||
|
||||
handleCancelPress = preventDoubleTap(() => {
|
||||
if (this.props.onCancelPress) {
|
||||
this.props.onCancelPress();
|
||||
}
|
||||
});
|
||||
|
||||
renderOptions = () => {
|
||||
const {items, onCancelPress} = this.props;
|
||||
const {items} = this.props;
|
||||
|
||||
const options = items.map((item, index) => {
|
||||
let textComponent;
|
||||
|
|
@ -39,7 +45,7 @@ export default class OptionsModalList extends PureComponent {
|
|||
return (
|
||||
<TouchableOpacity
|
||||
key={index}
|
||||
onPress={() => preventDoubleTap(item.action, this)}
|
||||
onPress={preventDoubleTap(item.action)}
|
||||
style={[style.option, style.optionBorder]}
|
||||
>
|
||||
{textComponent}
|
||||
|
|
@ -57,7 +63,7 @@ export default class OptionsModalList extends PureComponent {
|
|||
const cancel = (
|
||||
<TouchableOpacity
|
||||
key={items.length}
|
||||
onPress={() => preventDoubleTap(onCancelPress, this)}
|
||||
onPress={this.handleCancelPress}
|
||||
style={style.option}
|
||||
>
|
||||
<FormattedText
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ export default class OptionsModalList extends PureComponent {
|
|||
]),
|
||||
};
|
||||
|
||||
handleCancelPress = preventDoubleTap(() => {
|
||||
if (this.onCancelPress) {
|
||||
this.onCancelPress();
|
||||
}
|
||||
});
|
||||
|
||||
renderOptions = () => {
|
||||
const {items} = this.props;
|
||||
|
||||
|
|
@ -43,7 +49,7 @@ export default class OptionsModalList extends PureComponent {
|
|||
return (
|
||||
<TouchableOpacity
|
||||
key={index}
|
||||
onPress={() => preventDoubleTap(item.action, this)}
|
||||
onPress={preventDoubleTap(item.action)}
|
||||
style={[style.option, (index < items.length - 1 && style.optionBorder)]}
|
||||
>
|
||||
{textComponent}
|
||||
|
|
@ -89,8 +95,6 @@ export default class OptionsModalList extends PureComponent {
|
|||
};
|
||||
|
||||
render() {
|
||||
const {onCancelPress} = this.props;
|
||||
|
||||
return (
|
||||
<View style={style.wrapper}>
|
||||
<View style={style.optionContainer}>
|
||||
|
|
@ -98,7 +102,7 @@ export default class OptionsModalList extends PureComponent {
|
|||
</View>
|
||||
<View style={style.optionContainer}>
|
||||
<TouchableOpacity
|
||||
onPress={() => preventDoubleTap(onCancelPress, this)}
|
||||
onPress={this.handleCancelPress}
|
||||
style={style.option}
|
||||
>
|
||||
<FormattedText
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import SearchBar from 'app/components/search_bar';
|
|||
import SearchPreview from 'app/components/search_preview';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import mattermostManaged from 'app/mattermost_managed';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import ChannelDisplayName from './channel_display_name';
|
||||
|
|
@ -126,7 +126,7 @@ class Search extends PureComponent {
|
|||
this.autocomplete = c;
|
||||
};
|
||||
|
||||
cancelSearch = wrapWithPreventDoubleTap(() => {
|
||||
cancelSearch = preventDoubleTap(() => {
|
||||
const {navigator} = this.props;
|
||||
this.handleTextChanged('', true);
|
||||
navigator.dismissModal({animationType: 'slide-down'});
|
||||
|
|
@ -225,7 +225,7 @@ class Search extends PureComponent {
|
|||
});
|
||||
};
|
||||
|
||||
removeSearchTerms = wrapWithPreventDoubleTap((item) => {
|
||||
removeSearchTerms = preventDoubleTap((item) => {
|
||||
const {actions, currentTeamId} = this.props;
|
||||
actions.removeSearchTerms(currentTeamId, item.terms);
|
||||
});
|
||||
|
|
@ -413,11 +413,11 @@ class Search extends PureComponent {
|
|||
actions.searchPosts(currentTeamId, terms.trim(), isOrSearch);
|
||||
};
|
||||
|
||||
handleSearchButtonPress = wrapWithPreventDoubleTap((text) => {
|
||||
handleSearchButtonPress = preventDoubleTap((text) => {
|
||||
this.search(text);
|
||||
});
|
||||
|
||||
setModifierValue = wrapWithPreventDoubleTap((modifier) => {
|
||||
setModifierValue = preventDoubleTap((modifier) => {
|
||||
const {value} = this.state;
|
||||
let newValue = '';
|
||||
|
||||
|
|
@ -436,7 +436,7 @@ class Search extends PureComponent {
|
|||
}
|
||||
});
|
||||
|
||||
setRecentValue = wrapWithPreventDoubleTap((recent) => {
|
||||
setRecentValue = preventDoubleTap((recent) => {
|
||||
const {terms, isOrSearch} = recent;
|
||||
this.handleTextChanged(terms);
|
||||
this.search(terms, isOrSearch);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import ErrorText from 'app/components/error_text';
|
|||
import FormattedText from 'app/components/formatted_text';
|
||||
import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_localized_placeholder';
|
||||
import {GlobalStyles} from 'app/styles';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {isValidUrl, stripTrailingSlashes} from 'app/utils/url';
|
||||
import {UpgradeTypes} from 'app/constants/view';
|
||||
import checkUpgradeType from 'app/utils/client_upgrade';
|
||||
|
|
@ -183,7 +183,7 @@ class SelectServer extends PureComponent {
|
|||
this.setState({url});
|
||||
};
|
||||
|
||||
onClick = wrapWithPreventDoubleTap(async () => {
|
||||
onClick = preventDoubleTap(async () => {
|
||||
const preUrl = urlParse(this.state.url, true);
|
||||
const url = stripTrailingSlashes(preUrl.protocol + '//' + preUrl.host);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ export default class SelectTeam extends PureComponent {
|
|||
return (
|
||||
<View style={styles.teamWrapper}>
|
||||
<TouchableOpacity
|
||||
onPress={() => preventDoubleTap(this.onSelectTeam, this, item)}
|
||||
onPress={preventDoubleTap(() => this.onSelectTeam(item))}
|
||||
>
|
||||
<View style={styles.teamContainer}>
|
||||
<View style={styles.teamIconContainer}>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {getFormattedFileSize} from 'mattermost-redux/utils/file_utils';
|
|||
import SettingsItem from 'app/screens/settings/settings_item';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import {deleteFileCache, getFileCacheSize} from 'app/utils/file';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import Config from 'assets/config';
|
||||
|
|
@ -42,7 +42,7 @@ class AdvancedSettings extends PureComponent {
|
|||
this.getDownloadCacheSize();
|
||||
}
|
||||
|
||||
clearOfflineCache = wrapWithPreventDoubleTap(() => {
|
||||
clearOfflineCache = preventDoubleTap(() => {
|
||||
const {actions, intl} = this.props;
|
||||
|
||||
Alert.alert(
|
||||
|
|
@ -58,7 +58,7 @@ class AdvancedSettings extends PureComponent {
|
|||
);
|
||||
});
|
||||
|
||||
clearDownloadCache = wrapWithPreventDoubleTap(() => {
|
||||
clearDownloadCache = preventDoubleTap(() => {
|
||||
const {intl} = this.props;
|
||||
const {cacheSize} = this.state;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
|
||||
import SettingsItem from 'app/screens/settings/settings_item';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import ClockDisplay from 'app/screens/clock_display';
|
||||
|
|
@ -30,7 +30,7 @@ export default class DisplaySettings extends PureComponent {
|
|||
showClockDisplaySettings: false,
|
||||
};
|
||||
|
||||
goToClockDisplaySettings = wrapWithPreventDoubleTap(() => {
|
||||
goToClockDisplaySettings = preventDoubleTap(() => {
|
||||
const {navigator, theme} = this.props;
|
||||
const {intl} = this.context;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import DeviceInfo from 'react-native-device-info';
|
|||
|
||||
import SettingsItem from 'app/screens/settings/settings_item';
|
||||
import StatusBar from 'app/components/status_bar';
|
||||
import {wrapWithPreventDoubleTap} from 'app/utils/tap';
|
||||
import {preventDoubleTap} from 'app/utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme, setNavigatorStyles} from 'app/utils/theme';
|
||||
import {isValidUrl} from 'app/utils/url';
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class Settings extends PureComponent {
|
|||
return contents.join('\n');
|
||||
};
|
||||
|
||||
goToAbout = wrapWithPreventDoubleTap(() => {
|
||||
goToAbout = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
screen: 'About',
|
||||
|
|
@ -89,7 +89,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToNotifications = wrapWithPreventDoubleTap(() => {
|
||||
goToNotifications = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
screen: 'NotificationSettings',
|
||||
|
|
@ -105,7 +105,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToDisplaySettings = wrapWithPreventDoubleTap(() => {
|
||||
goToDisplaySettings = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
screen: 'DisplaySettings',
|
||||
|
|
@ -121,7 +121,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToAdvancedSettings = wrapWithPreventDoubleTap(() => {
|
||||
goToAdvancedSettings = preventDoubleTap(() => {
|
||||
const {intl, navigator, theme} = this.props;
|
||||
navigator.push({
|
||||
screen: 'AdvancedSettings',
|
||||
|
|
@ -137,7 +137,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToSelectTeam = wrapWithPreventDoubleTap(() => {
|
||||
goToSelectTeam = preventDoubleTap(() => {
|
||||
const {currentUrl, intl, navigator, theme} = this.props;
|
||||
|
||||
navigator.push({
|
||||
|
|
@ -158,7 +158,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
goToClientUpgrade = wrapWithPreventDoubleTap(() => {
|
||||
goToClientUpgrade = preventDoubleTap(() => {
|
||||
const {intl, theme} = this.props;
|
||||
|
||||
this.props.navigator.push({
|
||||
|
|
@ -188,7 +188,7 @@ class Settings extends PureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
openErrorEmail = wrapWithPreventDoubleTap(() => {
|
||||
openErrorEmail = preventDoubleTap(() => {
|
||||
const {config} = this.props;
|
||||
const recipient = config.SupportEmail;
|
||||
const subject = `Problem with ${config.SiteName} React Native app`;
|
||||
|
|
@ -202,7 +202,7 @@ class Settings extends PureComponent {
|
|||
});
|
||||
});
|
||||
|
||||
openHelp = wrapWithPreventDoubleTap(() => {
|
||||
openHelp = preventDoubleTap(() => {
|
||||
const {config} = this.props;
|
||||
const link = config.HelpLink ? config.HelpLink.toLowerCase() : '';
|
||||
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ class NotificationSettings extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
handlePress = (action) => {
|
||||
preventDoubleTap(action, this);
|
||||
};
|
||||
handlePress = preventDoubleTap((action) => {
|
||||
action();
|
||||
});
|
||||
|
||||
goToNotificationSettingsEmail = () => {
|
||||
if (Platform.OS === 'ios') {
|
||||
|
|
|
|||
|
|
@ -3,19 +3,7 @@
|
|||
|
||||
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) {
|
||||
export function preventDoubleTap(func) {
|
||||
let canPressWrapped = true;
|
||||
|
||||
return (...args) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue