mattermost-mobile/app/screens/search/index.js
Martin Kraft 0d0dfb1057 MM-11070: Adds ability to view archived channels. (#1927)
* MM-11070: Adds ability to view archived channels.

* MM-11070: Switches to existing selector.

* MM-11070: Uses boolean prop instead of object.

* MM-11070: Reuses web translations.

* MM-11070: Adds archived message to thread view. Switches to selector for postIDs of archived channels.

* MM-11070: Removed unused import.

* MM-11070: Removes edit and delete options from longpress of archived posts.

* MM-11070: Moves closure variable.

* MM-11070: Switch from hard-coded to theme color.

* MM-11070: Hides actions in header of archived channels.

* MM-11070: Updates Redux.

* MM-11070: Re-adds the 'Leave Channel' option for archived channels.
2018-07-31 15:27:38 -04:00

60 lines
2.2 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 {selectFocusedPostId, selectPost} from 'mattermost-redux/actions/posts';
import {clearSearch, removeSearchTerms, searchPosts} from 'mattermost-redux/actions/search';
import {getCurrentChannelId, filterPostIds} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {loadChannelsByTeamName, loadThreadIfNecessary} from 'app/actions/views/channel';
import {isLandscape} from 'app/selectors/device';
import {makePreparePostIdsForSearchPosts} from 'app/selectors/post_list';
import {handleSearchDraftChanged} from 'app/actions/views/search';
import Search from './search';
function makeMapStateToProps() {
const preparePostIds = makePreparePostIdsForSearchPosts();
const filterPostIdsByDeletedChannels = filterPostIds((c) => c && c.delete_at !== 0);
return (state) => {
const postIds = preparePostIds(state, state.entities.search.results);
const currentTeamId = getCurrentTeamId(state);
const currentChannelId = getCurrentChannelId(state);
const {recent} = state.entities.search;
const {searchPosts: searchRequest} = state.requests.search;
return {
currentTeamId,
currentChannelId,
isLandscape: isLandscape(state),
postIds,
archivedPostIds: filterPostIdsByDeletedChannels(state, postIds),
recent: recent[currentTeamId],
searchingStatus: searchRequest.status,
theme: getTheme(state),
};
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
clearSearch,
handleSearchDraftChanged,
loadChannelsByTeamName,
loadThreadIfNecessary,
removeSearchTerms,
selectFocusedPostId,
searchPosts,
selectPost,
}, dispatch),
};
}
export default connect(makeMapStateToProps, mapDispatchToProps)(Search);