MM-36640 Bring back permalink view on search/recent mentions/pinned and saved posts (#5482)

* Downgrade RNN to avoid bug that cuts off permalink view on iOS

* Bring back permalink view on search/recent mentions/pinned and saved posts

* fix test snapshot
This commit is contained in:
Elias Nahum 2021-06-24 12:46:02 -04:00
parent 2119cb4f85
commit 3c034ae3c4
No known key found for this signature in database
GPG key ID: E038DB71E0B61702
9 changed files with 47 additions and 17 deletions

View file

@ -7,16 +7,22 @@ import {Keyboard} from 'react-native';
import {dismissAllModals, showModalOverCurrentContext} from '@actions/navigation';
import {loadChannelsByTeamName} from '@actions/views/channel';
import {selectFocusedPostId} from '@mm-redux/actions/posts';
import {getCurrentTeam} from '@mm-redux/selectors/entities/teams';
import {permalinkBadTeam} from '@utils/general';
import {changeOpacity} from '@utils/theme';
import type {DispatchFunc} from '@mm-redux/types/actions';
import type {DispatchFunc, GetStateFunc} from '@mm-redux/types/actions';
let showingPermalink = false;
export function showPermalink(intl: typeof intlShape, teamName: string, postId: string, openAsPermalink = true) {
return async (dispatch: DispatchFunc) => {
const loadTeam = await dispatch(loadChannelsByTeamName(teamName, permalinkBadTeam.bind(null, intl)));
return async (dispatch: DispatchFunc, getState: GetStateFunc) => {
let name = teamName;
if (!name) {
name = getCurrentTeam(getState()).name;
}
const loadTeam = await dispatch(loadChannelsByTeamName(name, permalinkBadTeam.bind(null, intl)));
if (!loadTeam.error) {
Keyboard.dismiss();

View file

@ -3,6 +3,7 @@
import {connect} from 'react-redux';
import {showPermalink} from '@actions/views/permalink';
import {removePost} from '@mm-redux/actions/posts';
import {getChannel} from '@mm-redux/selectors/entities/channels';
import {getConfig} from '@mm-redux/selectors/entities/general';
@ -21,10 +22,12 @@ import type {GlobalState} from '@mm-redux/types/store';
import Post from './post';
type OwnProps = {
highlight?: boolean;
postId: string;
post?: PostType;
previousPostId?: string;
nextPostId?: string;
testID: string;
theme: Theme;
}
@ -83,6 +86,7 @@ function mapSateToProps(state: GlobalState, ownProps: OwnProps) {
const mapDispatchToProps = {
removePost,
showPermalink,
};
export default connect(mapSateToProps, mapDispatchToProps)(Post);

View file

@ -3,6 +3,7 @@
import React, {ReactNode, useRef} from 'react';
import {Keyboard, StyleProp, View, ViewStyle} from 'react-native';
import {injectIntl, intlShape} from 'react-intl';
import {showModalOverCurrentContext} from '@actions/navigation';
import SystemHeader from '@components/post_list/system_header';
@ -28,6 +29,7 @@ type PostProps = {
enablePostUsernameOverride: boolean;
highlight?: boolean;
highlightPinnedOrFlagged?: boolean;
intl: typeof intlShape;
isConsecutivePost?: boolean;
isFirstReply?: boolean;
isFlagged?: boolean;
@ -38,6 +40,7 @@ type PostProps = {
rootPostAuthor?: string;
shouldRenderReplyButton?: boolean;
showAddReaction?: boolean;
showPermalink: (intl: typeof intlShape, teamName: string, postId: string) => null;
skipFlaggedHeader?: boolean;
skipPinnedHeader?: boolean;
teammateNameDisplay: string;
@ -86,8 +89,8 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
});
const Post = ({
canDelete, enablePostUsernameOverride, highlight, highlightPinnedOrFlagged = true, isConsecutivePost, isFirstReply, isFlagged, isLastReply,
location, post, removePost, rootPostAuthor, shouldRenderReplyButton, skipFlaggedHeader, skipPinnedHeader, showAddReaction = true,
canDelete, enablePostUsernameOverride, highlight, highlightPinnedOrFlagged = true, intl, isConsecutivePost, isFirstReply, isFlagged, isLastReply,
location, post, removePost, rootPostAuthor, shouldRenderReplyButton, skipFlaggedHeader, skipPinnedHeader, showAddReaction = true, showPermalink,
teammateNameDisplay, testID, theme,
}: PostProps) => {
const pressDetected = useRef(false);
@ -99,11 +102,14 @@ const Post = ({
if (post) {
if (location === Screens.THREAD) {
Keyboard.dismiss();
} else if (location === Screens.SEARCH) {
showPermalink(intl, '', post.id);
return;
}
const isValidSystemMessage = fromAutoResponder(post) || !isSystemMessage(post);
if (post.state !== Posts.POST_DELETED && isValidSystemMessage && !isPostPendingOrFailed(post)) {
if ([Screens.CHANNEL, Screens.PERMALINK, Screens.SEARCH].includes(location)) {
if ([Screens.CHANNEL, Screens.PERMALINK].includes(location)) {
EventEmitter.emit('goToThread', post);
}
} else if ((isPostEphemeral(post) || post.state === Posts.POST_DELETED)) {
@ -257,4 +263,4 @@ const Post = ({
);
};
export default Post;
export default injectIntl(Post);

View file

@ -3,9 +3,10 @@
import React, {ReactElement, useCallback, useEffect, useLayoutEffect, useRef} from 'react';
import {injectIntl, intlShape} from 'react-intl';
import {DeviceEventEmitter, FlatList, Platform, StyleSheet, ViewToken} from 'react-native';
import {DeviceEventEmitter, FlatList, Platform, RefreshControl, StyleSheet, ViewToken} from 'react-native';
import {DeepLinkTypes, NavigationTypes} from '@constants';
import * as Screens from '@constants/screen';
import {useResetNativeScrollView} from '@hooks';
import {Posts} from '@mm-redux/constants';
import EventEmitter from '@mm-redux/utils/event_emitter';
@ -281,6 +282,18 @@ const PostList = ({
}
}, [initialIndex, highlightPostId]);
let refreshControl;
if (location === Screens.PERMALINK) {
// Hack so that the scrolling the permalink does not dismisses the modal screens
refreshControl = (
<RefreshControl
refreshing={false}
enabled={Platform.OS === 'ios'}
colors={[theme.centerChannelColor]}
tintColor={theme.centerChannelColor}
/>);
}
return (
<>
<FlatList
@ -309,6 +322,7 @@ const PostList = ({
windowSize={Posts.POST_CHUNK_SIZE / 2}
viewabilityConfig={VIEWABILITY_CONFIG}
onViewableItemsChanged={onViewableItemsChanged}
refreshControl={refreshControl}
testID={testID}
/>
{showMoreMessagesButton &&

View file

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SearchResultPost should match snapshot 1`] = `
<Connect(Post)
<Connect(InjectIntl(Post))
highlightPinnedOrFlagged={false}
isSearchResult={true}
location="Search"

View file

@ -336,12 +336,12 @@ PODS:
- React-Core
- ReactNativeKeyboardTrackingView (5.7.0):
- React
- ReactNativeNavigation (7.13.0):
- ReactNativeNavigation (7.11.3):
- React-Core
- React-RCTImage
- React-RCTText
- ReactNativeNavigation/Core (= 7.13.0)
- ReactNativeNavigation/Core (7.13.0):
- ReactNativeNavigation/Core (= 7.11.3)
- ReactNativeNavigation/Core (7.11.3):
- React-Core
- React-RCTImage
- React-RCTText
@ -738,7 +738,7 @@ SPEC CHECKSUMS:
ReactCommon: bedc99ed4dae329c4fcf128d0c31b9115e5365ca
ReactNativeExceptionHandler: b11ff67c78802b2f62eed0e10e75cb1ef7947c60
ReactNativeKeyboardTrackingView: 02137fac3b2ebd330d74fa54ead48b14750a2306
ReactNativeNavigation: 4c4ca87edc0da4ee818158a62cb6188088454e5c
ReactNativeNavigation: 906b631a6847c26cacf5cb3791566f1fe205c65c
rn-fetch-blob: 17961aec08caae68bb8fc0e5b40f93b3acfa6932
RNCAsyncStorage: cb9a623793918c6699586281f0b51cbc38f046f9
RNCClipboard: 5e299c6df8e0c98f3d7416b86ae563d3a9f768a3

6
package-lock.json generated
View file

@ -21489,9 +21489,9 @@
}
},
"react-native-navigation": {
"version": "7.13.0",
"resolved": "https://registry.npmjs.org/react-native-navigation/-/react-native-navigation-7.13.0.tgz",
"integrity": "sha512-/mdNuTlz9YVplJRB7Rv3g5cDgHCtw4RyG6ATdvrIJvMJOCU57ivCHuZkZDI/YQv7Txm48XD/EUkNahFFUATFZg==",
"version": "7.11.3",
"resolved": "https://registry.npmjs.org/react-native-navigation/-/react-native-navigation-7.11.3.tgz",
"integrity": "sha512-3cCtHwa2Tqc5Uk4QFSfocfOgOSKcRgfVlZ1m40oFUGV8yx9TaqA9BlPyQnWtaaPz8lHgKA3pkUmXQpFq0zOQzw==",
"requires": {
"hoist-non-react-statics": "3.x.x",
"lodash": "4.17.x",

View file

@ -55,7 +55,7 @@
"react-native-local-auth": "1.6.0",
"react-native-localize": "2.0.3",
"react-native-mmkv-storage": "0.4.4",
"react-native-navigation": "7.13.0",
"react-native-navigation": "7.11.3",
"react-native-notifications": "3.4.2",
"react-native-passcode-status": "1.1.2",
"react-native-permissions": "3.0.3",