return (state, ownProps) => { const currentChannel = getCurrentChannel(state) || {}; const getDraft = makeGetGlobalItem(StoragePrefixes.DRAFT + currentChannel.id, { message: '', uploadsInProgress: [], fileInfos: [] }); const recentPostIdInChannel = getMostRecentPostIdInChannel(state, currentChannel.id); const post = getPost(state, recentPostIdInChannel); const getCommentCountForPost = makeGetCommentCountForPost(); const latestReplyablePostId = getLatestReplyablePostId(state); const currentChannelMembersCount = getCurrentChannelStats(state) ? getCurrentChannelStats(state).member_count : 1; return { ...ownProps, currentTeamId: getCurrentTeamId(state), currentChannel, currentChannelMembersCount, currentUserId: getCurrentUserId(state), ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'), fullWidthTextBox: get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_FULL_SCREEN, showTutorialTip: get(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), 999), messageInHistoryItem: makeGetMessageInHistoryItem(Posts.MESSAGE_TYPES.POST)(state), draft: getDraft(state), recentPostIdInChannel, commentCountForPost: getCommentCountForPost(state, {post}), latestReplyablePostId, currentUsersLatestPost: getCurrentUsersLatestPost(state) }; };
return (state, ownProps) => { const config = getConfig(state); const currentChannel = getCurrentChannel(state) || {}; const draft = getPostDraft(state, StoragePrefixes.DRAFT, currentChannel.id); const recentPostIdInChannel = getMostRecentPostIdInChannel(state, currentChannel.id); const post = getPost(state, recentPostIdInChannel); const getCommentCountForPost = makeGetCommentCountForPost(); const latestReplyablePostId = getLatestReplyablePostId(state); const currentChannelMembersCount = getCurrentChannelStats(state) ? getCurrentChannelStats(state).member_count : 1; const enableTutorial = config.EnableTutorial === 'true'; const tutorialStep = getInt(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), TutorialSteps.FINISHED); const enableEmojiPicker = config.EnableEmojiPicker === 'true'; const enableGifPicker = config.EnableGifPicker === 'true'; const enableConfirmNotificationsToChannel = config.EnableConfirmNotificationsToChannel === 'true'; const currentUserId = getCurrentUserId(state); const userIsOutOfOffice = getStatusForUserId(state, currentUserId) === UserStatuses.OUT_OF_OFFICE; const badConnection = connectionErrorCount(state) > 1; const isTimezoneEnabled = config.ExperimentalTimezone === 'true'; return { currentTeamId: getCurrentTeamId(state), currentChannel, currentChannelMembersCount, currentUserId, codeBlockOnCtrlEnter: getBool(state, PreferencesRedux.CATEGORY_ADVANCED_SETTINGS, 'code_block_ctrl_enter', true), ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'), fullWidthTextBox: get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_FULL_SCREEN, showTutorialTip: enableTutorial && tutorialStep === TutorialSteps.POST_POPOVER, messageInHistoryItem: makeGetMessageInHistoryItem(Posts.MESSAGE_TYPES.POST)(state), draft, recentPostIdInChannel, commentCountForPost: getCommentCountForPost(state, {post}), latestReplyablePostId, locale: getCurrentLocale(state), currentUsersLatestPost: getCurrentUsersLatestPost(state), readOnlyChannel: ownProps.readOnlyChannel || (!isCurrentUserSystemAdmin(state) && config.ExperimentalTownSquareIsReadOnly === 'true' && currentChannel.name === Constants.DEFAULT_CHANNEL), canUploadFiles: canUploadFiles(config), enableEmojiPicker, enableGifPicker, enableConfirmNotificationsToChannel, maxPostSize: parseInt(config.MaxPostSize, 10) || Constants.DEFAULT_CHARACTER_LIMIT, userIsOutOfOffice, rhsExpanded: getIsRhsExpanded(state), emojiMap: getEmojiMap(state), badConnection, isTimezoneEnabled, }; };
function mapStateToProps(state) { const searchTerm = state.views.search.modalSearch; let users; if (searchTerm) { users = searchProfilesInCurrentChannel(state, searchTerm); } else { users = getProfilesInCurrentChannel(state); } const stats = getCurrentChannelStats(state) || {member_count: 0}; return { ...getUsersAndActionsToDisplay(state, users), currentTeamId: state.entities.teams.currentTeamId, currentChannelId: state.entities.channels.currentChannelId, searchTerm, totalChannelMembers: stats.member_count, }; }