Skip to content

Commit

Permalink
refactor: Move getPrivateMessages to messageSelectors.
Browse files Browse the repository at this point in the history
Before it was in `baseSelectors`, which is not a right place for it.
All selectors related to `message` are present in `messageSelectors`,
so it's better to move it.
  • Loading branch information
jainkuniya authored and gnprice committed Nov 21, 2018
1 parent e7baf88 commit ed13fce
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
10 changes: 0 additions & 10 deletions src/baseSelectors.js

This file was deleted.

14 changes: 13 additions & 1 deletion src/message/messageSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
import { createSelector } from 'reselect';

import type { Narrow, RenderedSectionDescriptor, Selector } from '../types';
import { getFlags, getMute, getSubscriptions } from '../directSelectors';
import {
getAllNarrows,
getFlags,
getMessages,
getMute,
getSubscriptions,
} from '../directSelectors';
import { getShownMessagesForNarrow } from '../chat/narrowsSelectors';
import renderMessages from './renderMessages';
import { findAnchor } from '../utils/message';
import { ALL_PRIVATE_NARROW_STR } from '../utils/narrow';
import { NULL_ARRAY } from '../nullObjects';

export const getPrivateMessages = createSelector(getAllNarrows, getMessages, (narrows, messages) =>
(narrows[ALL_PRIVATE_NARROW_STR] || NULL_ARRAY).map(id => messages[id]),
);

export const getRenderedMessages = (narrow: Narrow): Selector<RenderedSectionDescriptor[]> =>
createSelector(getShownMessagesForNarrow(narrow), messages => renderMessages(messages, narrow));
Expand Down
2 changes: 1 addition & 1 deletion src/pm-conversations/pmConversationsSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { createSelector } from 'reselect';

import type { Message, PmConversationData } from '../types';
import { getPrivateMessages } from '../baseSelectors';
import { getPrivateMessages } from '../message/messageSelectors';
import { getOwnEmail } from '../account/accountsSelectors';
import { getUnreadByPms, getUnreadByHuddles } from '../unread/unreadSelectors';
import { normalizeRecipientsSansMe, getRecipientsIds } from '../utils/recipient';
Expand Down
1 change: 0 additions & 1 deletion src/selectors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* @flow */
export * from './account/accountsSelectors';
export * from './baseSelectors';
export * from './pm-conversations/pmConversationsSelectors';
export * from './caughtup/caughtUpSelectors';
export * from './chat/narrowsSelectors';
Expand Down
2 changes: 1 addition & 1 deletion src/unread/unreadSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
getUnreadHuddles,
getUnreadMentions,
} from '../directSelectors';
import { getPrivateMessages } from '../baseSelectors';
import { getOwnEmail } from '../account/accountsSelectors';
import { getPrivateMessages } from '../message/messageSelectors';
import { getSubscriptionsById } from '../subscriptions/subscriptionSelectors';
import { countUnread } from '../utils/unread';
import { isTopicMuted } from '../utils/message';
Expand Down

0 comments on commit ed13fce

Please sign in to comment.