Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Add selector to get Posts EmbedVisible flags for RHS.
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheer committed Nov 17, 2017
1 parent 10b7914 commit 2b46507
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions selectors/rhs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import {createSelector} from 'reselect';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';

import {makeGetGlobalItem} from 'selectors/storage';
import {makeGetGlobalItem, makeGetItem} from 'selectors/storage';

import {PostTypes, StoragePrefixes} from 'utils/constants.jsx';

import {PostTypes} from 'utils/constants.jsx';
import {localizeMessage} from 'utils/utils.jsx';

export function getSelectedPostId(state) {
Expand Down Expand Up @@ -46,4 +47,15 @@ export const getSelectedPost = createSelector(
export function makeGetCommentDraft(rootId) {
const defaultValue = {message: '', fileInfos: [], uploadsInProgress: []};
return makeGetGlobalItem(`comment_draft_${rootId}`, defaultValue);
}
}

export const getPostsEmbedVisibleObj = createSelector(
(state) => state,
(state, {posts, previewCollapsed}) => ({posts, previewCollapsed}),
(state, {posts, previewCollapsed}) => {
return posts.reduce((accumulatedEmbedVisibleFlags, post) => ({
...accumulatedEmbedVisibleFlags,
[post.id]: makeGetItem(StoragePrefixes.EMBED_VISIBLE + post.id, previewCollapsed.startsWith('false'))(state)
}), {});
},
);

0 comments on commit 2b46507

Please sign in to comment.