mattermost-mobile/app/components/post_list/index.js
Joseph Baylon f495e1e48d
MM-30289 Detox/E2E - Add e2e tests for MM-T3184 and MM-T3186 (#5133)
* MM-30289 Detox/E2E - Add e2e tests for MM-T3184 and MM-T3186

* Update detox/e2e/support/server_api/preference.js

Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>

* MM-31322: redirect permalink handler (#5136)

* invert loadTeam.error test

* MM-31322: handle _redirect permalinks

In the webapp, [there is support](7c5a2e3bfd/components/root/root.jsx (L345-L352)) for a special `_redirect` team name in certain contexts that simply means, "the current team". It's used in the context of redirecting to the integrations backstage (not relevant for mobile), for also for resolving post permalinks.

This simplifies certain kinds of integrations which no longer have to know a team name to render a permanent link to a post. An example link looks like:

    http://localhost:8065/_redirect/pl/e3sxrxtwh78jmxawsaqfemxoew

This PR adds support for same in mobile, unintentionally missed on the first round of implementation.

Fixes: https://mattermost.atlassian.net/browse/MM-31322

* Apply suggestions from code review

Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>

* linting issues

* Apply suggestions from code review

Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>

* revert showPermalink changes

* Revert "invert loadTeam.error test"

This reverts commit accf6c8fb7c56009a393a6e85084d4702deec9ed.

* support _redirect deeplinks

* Apply suggestions from code review

* Update app/components/post_list/index.js

Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>

Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2021-02-10 13:55:00 -08:00

51 lines
1.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {closePermalink, showPermalink} from '@actions/views/permalink';
import {getConfig, getCurrentUrl} from '@mm-redux/selectors/entities/general';
import {getTheme} from '@mm-redux/selectors/entities/preferences';
import {makePreparePostIdsForPostList, START_OF_NEW_MESSAGES} from '@mm-redux/utils/post_list';
import {getCurrentTeam} from '@mm-redux/selectors/entities/teams';
import {handleSelectChannelByName, refreshChannelWithRetry} from 'app/actions/views/channel';
import {setDeepLinkURL} from 'app/actions/views/root';
import PostList from './post_list';
function makeMapStateToProps() {
const preparePostIds = makePreparePostIdsForPostList();
return (state, ownProps) => {
const postIds = preparePostIds(state, ownProps);
let initialIndex = postIds.indexOf(START_OF_NEW_MESSAGES);
if (ownProps.highlightPostId) {
initialIndex = postIds.indexOf(ownProps.highlightPostId);
}
return {
deepLinkURL: state.views.root.deepLinkURL,
postIds,
initialIndex,
serverURL: getCurrentUrl(state),
siteURL: getConfig(state).SiteURL,
theme: getTheme(state),
currentTeamName: getCurrentTeam(state)?.name,
};
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
closePermalink,
handleSelectChannelByName,
refreshChannelWithRetry,
setDeepLinkURL,
showPermalink,
}, dispatch),
};
}
export default connect(makeMapStateToProps, mapDispatchToProps)(PostList);