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

Commit

Permalink
fix Dm name in file preview modal info bar (#9547)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishDhama authored and M-ZubairAhmed committed Dec 25, 2021
1 parent 3c7ecb9 commit 54c47ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports[`components/FilePreviewModalInfo should match snapshot 1`] = `
id="file_preview_modal_info.shared_in"
values={
Object {
"name": "DN",
"name": "name",
}
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {memo} from 'react';
import {FormattedMessage} from 'react-intl';
import {useSelector} from 'react-redux';

import {getChannel as selectChannel} from 'mattermost-redux/selectors/entities/channels';
import {makeGetChannel} from 'mattermost-redux/selectors/entities/channels';
import {
getUser as selectUser,
makeGetDisplayName,
Expand All @@ -31,7 +31,10 @@ const displayNameGetter = makeGetDisplayName();

const FilePreviewModalInfo: React.FC<Props> = (props: Props) => {
const user = useSelector((state: GlobalState) => selectUser(state, props.post?.user_id ?? '')) as UserProfile | undefined;
const channel = useSelector((state: GlobalState) => selectChannel(state, props.post?.channel_id ?? ''));
const channel = useSelector((state: GlobalState) => {
const getChannel = makeGetChannel();
return getChannel(state, {id: props.post?.channel_id ?? ''});
});
const name = useSelector((state: GlobalState) => displayNameGetter(state, props.post?.user_id ?? '', true));

let info;
Expand All @@ -40,7 +43,7 @@ const FilePreviewModalInfo: React.FC<Props> = (props: Props) => {
id='file_preview_modal_info.shared_in'
defaultMessage='Shared in ~{name}'
values={{
name: channel.name,
name: channel.display_name || channel.name,
}}
/>
) : null;
Expand Down

0 comments on commit 54c47ec

Please sign in to comment.