mattermost-mobile/app/screens/thread_options/index.ts
Anurag Shivarathri 856d8bd05f
MM-34842 global threads options (#5630)
* fixes MM-37294 MM-37296 MM-37297

* Added conditions to check for post & thread existence

* Update app/mm-redux/selectors/entities/threads.ts

Co-authored-by: Kyriakos Z. <3829551+koox00@users.noreply.github.com>

* type fix

* Never disabling Mark All as unread

* Added follow/unfollow message for not yet thread posts

* Test case fix for mark all as unread enabled all the time

* Removed hardcoded condition

* Fixed MM-37509

* Updated snapshot for sidebar

* Global thread actions init

* Added options

* Update post_options.js

* Test cases fix

* Added border bottom for each thread option

* Update test case

* Reverting snapshot

* Updated snapshot

* Moved options to screens & removed redundants translations

* Reusing post_option for thread_option

* Component name changed to PostOption from ThreadOption

* Snapshot updated

* Removed factory

* Update app/screens/thread_options/index.ts

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

* Update app/screens/thread_options/index.ts

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

Co-authored-by: Kyriakos Z. <3829551+koox00@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2021-10-11 13:24:38 +05:30

53 lines
1.9 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators, Dispatch} from 'redux';
import {showPermalink} from '@actions/views/permalink';
import {
flagPost,
setUnreadPost,
unflagPost,
} from '@mm-redux/actions/posts';
import {setThreadFollow, updateThreadRead} from '@mm-redux/actions/threads';
import {getCurrentUserId} from '@mm-redux/selectors/entities/common';
import {getPost} from '@mm-redux/selectors/entities/posts';
import {getMyPreferences, getTheme} from '@mm-redux/selectors/entities/preferences';
import {getCurrentTeam, getCurrentTeamUrl} from '@mm-redux/selectors/entities/teams';
import {getThread} from '@mm-redux/selectors/entities/threads';
import {isPostFlagged} from '@mm-redux/utils/post_utils';
import {getDimensions} from '@selectors/device';
import ThreadOptions, {OwnProps} from './thread_options';
import type {GlobalState} from '@mm-redux/types/store';
export function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
const myPreferences = getMyPreferences(state);
return {
...getDimensions(state),
currentTeamName: getCurrentTeam(state)?.name,
currentTeamUrl: getCurrentTeamUrl(state),
currentUserId: getCurrentUserId(state),
isFlagged: isPostFlagged(ownProps.rootId, myPreferences),
post: getPost(state, ownProps.rootId),
theme: getTheme(state),
thread: getThread(state, ownProps.rootId),
};
}
function mapDispatchToProps(dispatch: Dispatch) {
return {
actions: bindActionCreators({
flagPost,
setThreadFollow,
setUnreadPost,
showPermalink,
unflagPost,
updateThreadRead,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(ThreadOptions);