Skip to content

Commit

Permalink
fix trim js error in transcript popover
Browse files Browse the repository at this point in the history
Changelog: fixed
  • Loading branch information
antonbuks committed Jul 18, 2024
1 parent 39a1f4c commit cde3070
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ function VoiceMessageAttachmentPlayer(props: Props) {
const fetchTranscript = async () => {
if (!hasFetchedTranscript) {
setIsLoadingTranscript(true);
const result = await fetchTranscriptData(props.fileId)();
if (!(result as TranscriptData).text) {
const result = await fetchTranscriptData(props.fileId);
if (!result.text) {
setError(
<FormattedMessage
id='vocals.transcript.error'
Expand All @@ -73,8 +73,10 @@ function VoiceMessageAttachmentPlayer(props: Props) {
);
}
setIsLoadingTranscript(false);
setTranscript((result as TranscriptData).text.trim());
setTranscriptDatas((result as TranscriptData));
if (result.text) {
setTranscript(result.text.trim());
}
setTranscriptDatas(result);
setHasFetchedTranscript(true);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
} from '@mattermost/types/channels';
import type {ServerError} from '@mattermost/types/errors';
import type {PreferenceType} from '@mattermost/types/preferences';
import type {TranscriptData} from '@mattermost/types/transcript';

import {ChannelTypes, PreferenceTypes, UserTypes} from 'mattermost-redux/action_types';
import {Client4} from 'mattermost-redux/client';
Expand Down Expand Up @@ -1030,8 +1031,8 @@ export function getChannelsMemberCount(channelIds: string[]): ActionFuncAsync<Re
let channelsMemberCount;

try {
channelsMemberCount = await Client4.getChannelsMemberCount(channelIds);
} catch (error) {
channelsMemberCount = await Client4.getChannelsMemberCount(channelIds);
} catch (error) {
forceLogoutIfNecessary(error, dispatch, getState);
dispatch(logError(error));
return {error};
Expand Down Expand Up @@ -1060,11 +1061,9 @@ export function notifyChannelMember(channelId: string, userIds: string[], postId
};
}

export function fetchTranscriptData(fileId: string) {
return async () => {
const transcript = await Client4.getTranscript(fileId);
return transcript;
};
export async function fetchTranscriptData(fileId: string): Promise<TranscriptData> {
const transcript = await Client4.getTranscript(fileId);
return transcript;
}

export function addChannelMember(channelId: string, userId: string, postRootId = ''): ActionFuncAsync<ChannelMembership> {
Expand Down
2 changes: 1 addition & 1 deletion webapp/platform/types/src/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export type TranscriptData = {
text: string;
start: number;
}>;
text: string;
text?: string;
};

0 comments on commit cde3070

Please sign in to comment.