Files
Harrison Healey da3ac93c8f Reorganize post state and make postsInChannel into a sparse array (#2609)
* MM-13957 Reorganize post actions (#2343)

* MM-13957 Reorganize post actions

* Use postDeleted action creator

* Show join/leave messages since combined systed messages have been temporarily removed

* Re-add tests for showFlaggedPosts and showPinnedPosts

* Add temporary fix for permalink view

* Update mattermost-redux

* MM-13958/MM-13959 Make postsInChannel into a sparse array (#2411)

* MM-13958/MM-13959 Make postsInChannel into a sparse array

* Fix unit tests

* Fix being unable to load channels with between 30 and 60 posts

* Fix unit tests

* MM-13960 Re-add support for combined user activity posts  (#2465)

* Add unit tests for PostList

* Remove unnecessary null check

* MM-13960 Re-add support for combined user activity posts

* Fix being deleted combined posts not disappearing for the user who deletes the post

* Fix PostList unit tests

* Fix New Messages Below indicator when PostList takes post IDs

* Update mattermost-redux

* Update mattermost-redux
2019-04-15 17:18:43 -04:00

42 lines
1.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createSelector} from 'reselect';
import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {getBool as getBoolPreference} from 'mattermost-redux/selectors/entities/preferences';
import {getGlobalItem} from 'selectors/storage';
import {Preferences, StoragePrefixes} from 'utils/constants';
export const getEditingPost = createSelector(
(state) => {
if (state.views.posts.editingPost && state.views.posts.editingPost.postId) {
return getPost(state, state.views.posts.editingPost.postId);
}
return null;
},
(state) => state.views.posts.editingPost,
(post, editingPost) => {
return {
...editingPost,
post,
};
}
);
export function isEmbedVisible(state, postId) {
const previewCollapsed = getBoolPreference(
state,
Preferences.CATEGORY_DISPLAY_SETTINGS,
Preferences.COLLAPSE_DISPLAY,
Preferences.COLLAPSE_DISPLAY_DEFAULT !== 'false'
);
return getGlobalItem(state, StoragePrefixes.EMBED_VISIBLE + postId, !previewCollapsed);
}
export function shouldShowJoinLeaveMessages(state) {
return getBoolPreference(state, Preferences.CATEGORY_ADVANCED_SETTINGS, Preferences.ADVANCED_FILTER_JOIN_LEAVE, true);
}