Skip to content

Commit

Permalink
Merge branch 'rm/320643' into 'master'
Browse files Browse the repository at this point in the history
Fix: using channel id passed as props to determine channel stats.

See merge request kchat/webapp!678
  • Loading branch information
antonbuks committed Mar 14, 2024
2 parents 8bc98c5 + a17db96 commit 6bec062
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ const AdvanceTextEditor = ({
className={'AdvancedTextEditor__body'}
disabled={readOnlyChannel}
>
<GuestBanner/>
<GuestBanner channelId={channelId}/>
<div
ref={editorBodyRef}
role='application'
Expand Down
4 changes: 3 additions & 1 deletion webapp/channels/src/components/guest_banner/guest_banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import './guest_banner.scss';

import InfoIconFilled from 'components/widgets/icons/info_icon_filled';

type Props = {
import type {GuestBannerConnectorProps} from '.';

type Props = GuestBannerConnectorProps & {
count: number;
isGuest: boolean;
}
Expand Down
14 changes: 9 additions & 5 deletions webapp/channels/src/components/guest_banner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';
import {withRouter} from 'react-router-dom';

import {getCurrentChannelStats} from 'mattermost-redux/selectors/entities/channels';
import {getAllChannelStats} from 'mattermost-redux/selectors/entities/channels';
import {isCurrentUserGuestUser} from 'mattermost-redux/selectors/entities/users';

import type {GlobalState} from 'types/store/index';

import GuestBanner from './guest_banner';
const EMPTY_CHANNEL_STATS = {member_count: 0, guest_count: 0, pinnedpost_count: 0, files_count: 0};

export type GuestBannerConnectorProps = {
channelId: string;
}

function makeMapStateToProps() {
return function mapStateToProps(state: GlobalState) {
const stats = getCurrentChannelStats(state) || EMPTY_CHANNEL_STATS;
return function mapStateToProps(state: GlobalState, ownProps: GuestBannerConnectorProps) {
const allChannelStats = getAllChannelStats(state);
const stats = allChannelStats?.[ownProps.channelId] || EMPTY_CHANNEL_STATS;
const isGuest = isCurrentUserGuestUser(state);

return {
Expand All @@ -24,4 +28,4 @@ function makeMapStateToProps() {
};
}

export default withRouter(connect(makeMapStateToProps, {})(GuestBanner));
export default connect(makeMapStateToProps, {})(GuestBanner);

0 comments on commit 6bec062

Please sign in to comment.