forked from Ivasoft/mattermost-mobile
Dismiss keyboard when a post is pressed (#6242)
This commit is contained in:
@@ -128,31 +128,34 @@ const Post = ({
|
||||
return false;
|
||||
}, [isConsecutivePost, post, previousPost, isFirstReply]);
|
||||
|
||||
const handlePostPress = () => {
|
||||
if ([Screens.SAVED_POSTS, Screens.MENTIONS, Screens.SEARCH].includes(location)) {
|
||||
showPermalink(serverUrl, '', post.id, intl);
|
||||
return;
|
||||
}
|
||||
|
||||
const isValidSystemMessage = isAutoResponder || !isSystemPost;
|
||||
if (post.deleteAt === 0 && isValidSystemMessage && !isPendingOrFailed) {
|
||||
if ([Screens.CHANNEL, Screens.PERMALINK].includes(location)) {
|
||||
const rootId = post.rootId || post.id;
|
||||
fetchAndSwitchToThread(serverUrl, rootId);
|
||||
}
|
||||
} else if ((isEphemeral || post.deleteAt > 0)) {
|
||||
removePost(serverUrl, post);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
pressDetected.current = false;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
const handlePress = preventDoubleTap(() => {
|
||||
pressDetected.current = true;
|
||||
|
||||
if (post) {
|
||||
if (location === Screens.THREAD) {
|
||||
Keyboard.dismiss();
|
||||
} else if ([Screens.SAVED_POSTS, Screens.MENTIONS, Screens.SEARCH].includes(location)) {
|
||||
showPermalink(serverUrl, '', post.id, intl);
|
||||
return;
|
||||
}
|
||||
Keyboard.dismiss();
|
||||
|
||||
const isValidSystemMessage = isAutoResponder || !isSystemPost;
|
||||
if (post.deleteAt === 0 && isValidSystemMessage && !isPendingOrFailed) {
|
||||
if ([Screens.CHANNEL, Screens.PERMALINK].includes(location)) {
|
||||
const rootId = post.rootId || post.id;
|
||||
fetchAndSwitchToThread(serverUrl, rootId);
|
||||
}
|
||||
} else if ((isEphemeral || post.deleteAt > 0)) {
|
||||
removePost(serverUrl, post);
|
||||
}
|
||||
|
||||
const pressTimeout = setTimeout(() => {
|
||||
pressDetected.current = false;
|
||||
clearTimeout(pressTimeout);
|
||||
}, 300);
|
||||
setTimeout(handlePostPress, 300);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user