diff --git a/app/actions/views/permalink.ts b/app/actions/views/permalink.ts
index 1bcc4b6ec..98ed2a23a 100644
--- a/app/actions/views/permalink.ts
+++ b/app/actions/views/permalink.ts
@@ -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();
diff --git a/app/components/post_list/post/index.ts b/app/components/post_list/post/index.ts
index dcd68ffca..62d847b3e 100644
--- a/app/components/post_list/post/index.ts
+++ b/app/components/post_list/post/index.ts
@@ -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);
diff --git a/app/components/post_list/post/post.tsx b/app/components/post_list/post/post.tsx
index f44c1261a..2d8c6a54f 100644
--- a/app/components/post_list/post/post.tsx
+++ b/app/components/post_list/post/post.tsx
@@ -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);
diff --git a/app/components/post_list/post_list.tsx b/app/components/post_list/post_list.tsx
index ac0162c00..c327eb991 100644
--- a/app/components/post_list/post_list.tsx
+++ b/app/components/post_list/post_list.tsx
@@ -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 = (
+ );
+ }
+
return (
<>
{showMoreMessagesButton &&
diff --git a/app/screens/search/search_result_post/__snapshots__/search_result_post.test.js.snap b/app/screens/search/search_result_post/__snapshots__/search_result_post.test.js.snap
index b4a6f9965..da1115edd 100644
--- a/app/screens/search/search_result_post/__snapshots__/search_result_post.test.js.snap
+++ b/app/screens/search/search_result_post/__snapshots__/search_result_post.test.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SearchResultPost should match snapshot 1`] = `
-