diff --git a/actions/notification_actions.jsx b/actions/notification_actions.jsx index 8e77992b55db..273425b24dea 100644 --- a/actions/notification_actions.jsx +++ b/actions/notification_actions.jsx @@ -4,7 +4,7 @@ import semver from 'semver'; import {logError} from 'mattermost-redux/actions/errors'; import {getProfilesByIds} from 'mattermost-redux/actions/users'; -import {getChannel, getCurrentChannel, getMyChannelMember} from 'mattermost-redux/selectors/entities/channels'; +import {getCurrentChannel, getMyChannelMember, makeGetChannel} from 'mattermost-redux/selectors/entities/channels'; import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentUserId, getCurrentUser, getStatusForUserId, getUser} from 'mattermost-redux/selectors/entities/users'; @@ -48,7 +48,7 @@ export function sendDesktopNotification(post, msgProps) { } const teamId = msgProps.team_id; - let channel = getChannel(state, post.channel_id); + let channel = makeGetChannel()(state, post.channel_id); const user = getCurrentUser(state); const userStatus = getStatusForUserId(state, user.id); const member = getMyChannelMember(state, post.channel_id); diff --git a/components/post_view/index.js b/components/post_view/index.js index a248df99bd4d..3d23de6fc458 100644 --- a/components/post_view/index.js +++ b/components/post_view/index.js @@ -53,7 +53,6 @@ function makeMapStateToProps() { return { lastViewedAt, channelLoading, - channel, }; }; } diff --git a/components/rhs_root_post/index.js b/components/rhs_root_post/index.js index f5327d31e761..28e4856646e4 100644 --- a/components/rhs_root_post/index.js +++ b/components/rhs_root_post/index.js @@ -29,7 +29,7 @@ function mapStateToProps(state, ownProps) { const enableEmojiPicker = config.EnableEmojiPicker === 'true'; const enablePostUsernameOverride = config.EnablePostUsernameOverride === 'true'; const teamId = ownProps.teamId || getCurrentTeamId(state); - const channel = getChannel(state, ownProps.post.channel_id) || {}; + const channel = getChannel(state, ownProps.post.channel_id); const emojiMap = getEmojiMap(state); const shortcutReactToLastPostEmittedFrom = getShortcutReactToLastPostEmittedFrom(state); diff --git a/components/rhs_thread/index.ts b/components/rhs_thread/index.ts index 84234106ed9a..74427e89810a 100644 --- a/components/rhs_thread/index.ts +++ b/components/rhs_thread/index.ts @@ -3,7 +3,6 @@ import {connect} from 'react-redux'; import {bindActionCreators, Dispatch} from 'redux'; -import {getChannel} from 'mattermost-redux/selectors/entities/channels'; import {makeGetPostsForThread} from 'mattermost-redux/selectors/entities/posts'; import {get, getBool} from 'mattermost-redux/selectors/entities/preferences'; import {removePost, getPostThread} from 'mattermost-redux/actions/posts'; @@ -13,7 +12,7 @@ import {UserProfile} from 'mattermost-redux/src/types/users'; import {Preferences} from 'utils/constants'; import {getDirectTeammate} from 'utils/utils.jsx'; -import {getSelectedPost} from 'selectors/rhs'; +import {getSelectedChannel, getSelectedPost} from 'selectors/rhs'; import {getSocketStatus} from 'selectors/views/websocket'; import {selectPostCard} from 'actions/views/rhs'; import {GlobalState} from 'types/store'; @@ -27,11 +26,10 @@ function makeMapStateToProps() { const selected = getSelectedPost(state); const socketStatus = getSocketStatus(state); - let channel = null; + const channel = getSelectedChannel(state); let posts: Post[] = []; if (selected) { posts = getPostsForThread(state, {rootId: selected.id}); - channel = getChannel(state, selected.channel_id); } const previewCollapsed = get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSE_DISPLAY, Preferences.COLLAPSE_DISPLAY_DEFAULT); diff --git a/components/sidebar_right/index.js b/components/sidebar_right/index.js index 25dc810189ec..94fb0b071912 100644 --- a/components/sidebar_right/index.js +++ b/components/sidebar_right/index.js @@ -4,19 +4,16 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; -import { - getChannel, - getCurrentChannel, -} from 'mattermost-redux/selectors/entities/channels'; +import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; import {setRhsExpanded, showPinnedPosts, openRHSSearch, closeRightHandSide, openAtPrevious, updateSearchTerms} from 'actions/views/rhs'; import { getIsRhsExpanded, getIsRhsOpen, getRhsState, + getSelectedChannel, getSelectedPostId, getSelectedPostCardId, - getSelectedChannelId, getPreviousRhsState, } from 'selectors/rhs'; import {RHSStates} from 'utils/constants'; @@ -26,12 +23,6 @@ import SidebarRight from './sidebar_right.jsx'; function mapStateToProps(state) { const rhsState = getRhsState(state); const channel = getCurrentChannel(state); - const channelId = getSelectedChannelId(state); - - let rhsChannel = null; - if (channelId) { - rhsChannel = getChannel(state, channelId); - } const selectedPostId = getSelectedPostId(state); const selectedPostCardId = getSelectedPostCardId(state); @@ -49,7 +40,7 @@ function mapStateToProps(state) { isFlaggedPosts: rhsState === RHSStates.FLAG, isPinnedPosts: rhsState === RHSStates.PIN, isPluginView: rhsState === RHSStates.PLUGIN, - rhsChannel, + rhsChannel: getSelectedChannel(state), selectedPostId, selectedPostCardId, }; diff --git a/package-lock.json b/package-lock.json index ce8d954f3fc2..e738a0d6404e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12582,12 +12582,8 @@ "resolved": "https://registry.npmjs.org/full-icu/-/full-icu-1.3.1.tgz", "integrity": "sha512-VMtK//85QJomhk3cXOCksNwOYaw1KWnYTS37GYGgyf7A3ajdBoPGhaJuJWAH2S2kq8GZeXkdKn+3Mfmgy11cVw==", "dev": true, - "dependencies": { - "icu4c-data": { - "version": "0.64.2", - "resolved": "https://registry.npmjs.org/icu4c-data/-/icu4c-data-0.64.2.tgz", - "integrity": "sha512-BPuTfkRTkplmK1pNrqgyOLJ0qB2UcQ12EotVLwiWh4ErtZR1tEYoRZk/LBLmlDfK5v574/lQYLB4jT9vApBiBQ==" - } + "requires": { + "icu4c-data": "0.63.2" } }, "function-bind": { @@ -13487,6 +13483,12 @@ "postcss": "^7.0.14" } }, + "icu4c-data": { + "version": "0.63.2", + "resolved": "https://registry.npmjs.org/icu4c-data/-/icu4c-data-0.63.2.tgz", + "integrity": "sha512-vT6/47CcBzDemlhRzkL7dZLoNvuUWjjiuKZHMt5T4dbkKAqLBh7ZQ33GU13ecC/aIcMlIdBOqtF4uIYTgWML4Q==", + "dev": true + }, "identity-obj-proxy": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz", @@ -17897,8 +17899,8 @@ "integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==" }, "mattermost-redux": { - "version": "github:mattermost/mattermost-redux#fdf8fa87579f6457d55f8999301fe52068ac67d6", - "from": "github:mattermost/mattermost-redux#fdf8fa87579f6457d55f8999301fe52068ac67d6", + "version": "github:mattermost/mattermost-redux#aba4df6b300ad4aaf8e0adb734ff549bf236d110", + "from": "github:mattermost/mattermost-redux#aba4df6b300ad4aaf8e0adb734ff549bf236d110", "requires": { "core-js": "3.6.5", "form-data": "3.0.0", diff --git a/package.json b/package.json index 40b36cd63f88..0412b88f80d0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "localforage-observable": "2.0.1", "mark.js": "8.11.1", "marked": "github:mattermost/marked#87769262aa02e1784570f61f4f962050e07cc335", - "mattermost-redux": "github:mattermost/mattermost-redux#fdf8fa87579f6457d55f8999301fe52068ac67d6", + "mattermost-redux": "github:mattermost/mattermost-redux#aba4df6b300ad4aaf8e0adb734ff549bf236d110", "moment-timezone": "0.5.31", "p-queue": "6.6.1", "pdfjs-dist": "2.1.266", diff --git a/selectors/rhs.ts b/selectors/rhs.ts index 6f9c6378519e..265afae5d707 100644 --- a/selectors/rhs.ts +++ b/selectors/rhs.ts @@ -2,8 +2,10 @@ // See LICENSE.txt for license information. import {createSelector} from 'reselect'; -import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; + +import {makeGetChannel} from 'mattermost-redux/selectors/entities/channels'; import {Post, PostType} from 'mattermost-redux/types/posts'; +import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {Channel} from 'mattermost-redux/types/channels'; import {$ID} from 'mattermost-redux/types/utilities'; @@ -33,6 +35,16 @@ export function getSelectedChannelId(state: GlobalState) { return state.views.rhs.selectedChannelId; } +export const getSelectedChannel = (() => { + const getChannel = makeGetChannel(); + + return (state: GlobalState) => { + const channelId = getSelectedChannelId(state); + + return getChannel(state, {id: channelId}); + }; +})(); + export function getPluggableId(state: GlobalState) { return state.views.rhs.pluggableId; }