Skip to content

Commit ff1e879

Browse files
committed
fix: use LoadingIndicator instead of LoadingIndicatorIcon
1 parent 0a8d65d commit ff1e879

File tree

4 files changed

+19
-52
lines changed

4 files changed

+19
-52
lines changed

src/components/MediaRecorder/AudioRecorder/AudioRecorderRecordingControls.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CheckSignIcon, LoadingIndicatorIcon } from '../../MessageComposer/icons';
1+
import { CheckSignIcon } from '../../MessageComposer/icons';
22
import { IconDelete, IconPauseFill, IconVoice } from '../../Icons';
33
import React from 'react';
44
import {
@@ -9,6 +9,7 @@ import {
99
import { isRecording } from './recordingStateIdentity';
1010
import { Button } from '../../Button';
1111
import { addNotificationTargetTag, useNotificationTarget } from '../../Notifications';
12+
import { AttachmentUploadProgressIndicator } from '../../MessageComposer/AttachmentPreviewList/AttachmentUploadProgressIndicator';
1213

1314
const ToggleRecordingButton = () => {
1415
const {
@@ -40,6 +41,7 @@ export const AudioRecorderRecordingControls = () => {
4041
const panel = useNotificationTarget();
4142

4243
const isUploadingFile = recording?.localMetadata?.uploadState === 'uploading';
44+
const uploadProgress = recording?.localMetadata?.uploadProgress;
4345

4446
if (!recorder) return null;
4547

@@ -79,7 +81,11 @@ export const AudioRecorderRecordingControls = () => {
7981
size='sm'
8082
variant='primary'
8183
>
82-
{isUploadingFile ? <LoadingIndicatorIcon /> : <CheckSignIcon />}
84+
{isUploadingFile ? (
85+
<AttachmentUploadProgressIndicator uploadProgress={uploadProgress} />
86+
) : (
87+
<CheckSignIcon />
88+
)}
8389
</Button>
8490
</div>
8591
);

src/components/MessageComposer/AttachmentPreviewList/AttachmentUploadProgressIndicator.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import clsx from 'clsx';
2-
import React, { type ReactNode } from 'react';
2+
import React from 'react';
33

4-
import { CircularProgressIndicator as DefaultCircularProgressIndicator } from '../../Loading';
4+
import {
5+
CircularProgressIndicator as DefaultCircularProgressIndicator,
6+
LoadingIndicator as DefaultLoadingIndicator,
7+
} from '../../Loading';
58
import { useComponentContext } from '../../../context';
6-
import { LoadingIndicatorIcon } from '../icons';
79

810
export type AttachmentUploadProgressIndicatorProps = {
911
className?: string;
10-
/** Shown when `uploadProgress` is `undefined` (e.g. progress tracking disabled). */
11-
fallback?: ReactNode;
1212
uploadProgress?: number;
1313
};
1414

1515
export const AttachmentUploadProgressIndicator = ({
1616
className,
17-
fallback,
1817
uploadProgress,
1918
}: AttachmentUploadProgressIndicatorProps) => {
20-
const { CircularProgressIndicator = DefaultCircularProgressIndicator } =
21-
useComponentContext();
19+
const {
20+
CircularProgressIndicator = DefaultCircularProgressIndicator,
21+
LoadingIndicator = DefaultLoadingIndicator,
22+
} = useComponentContext();
2223

2324
if (uploadProgress === undefined) {
24-
return <>{fallback ?? <LoadingIndicatorIcon data-testid='loading-indicator' />}</>;
25+
return <LoadingIndicator data-testid='loading-indicator' />;
2526
}
2627

2728
return (

src/components/MessageComposer/AttachmentPreviewList/MediaAttachmentPreview.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { RemoveAttachmentPreviewButton } from '../RemoveAttachmentPreviewButton'
1919
import { Button } from '../../Button';
2020
import { AttachmentUploadProgressIndicator as DefaultAttachmentUploadProgressIndicator } from './AttachmentUploadProgressIndicator';
2121
import { AttachmentPreviewRoot } from './utils/AttachmentPreviewRoot';
22-
import { LoadingIndicator as DefaultLoadingIndicator } from '../../Loading';
2322

2423
export type MediaAttachmentPreviewProps<CustomLocalMetadata = Record<string, unknown>> =
2524
UploadAttachmentPreviewProps<
@@ -38,7 +37,6 @@ export const MediaAttachmentPreview = ({
3837
const {
3938
AttachmentUploadProgressIndicator = DefaultAttachmentUploadProgressIndicator,
4039
BaseImage = DefaultBaseImage,
41-
LoadingIndicator = DefaultLoadingIndicator,
4240
} = useComponentContext();
4341
const [thumbnailPreviewError, setThumbnailPreviewError] = useState(false);
4442

@@ -100,10 +98,7 @@ export const MediaAttachmentPreview = ({
10098

10199
<div className={clsx('str-chat__attachment-preview-media__overlay')}>
102100
{isUploading && (
103-
<AttachmentUploadProgressIndicator
104-
fallback={<LoadingIndicator data-testid='loading-indicator' />}
105-
uploadProgress={uploadProgress}
106-
/>
101+
<AttachmentUploadProgressIndicator uploadProgress={uploadProgress} />
107102
)}
108103

109104
{isVideoAttachment(attachment) &&

src/components/MessageComposer/icons.tsx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
1-
import React, { useMemo } from 'react';
2-
import { nanoid } from 'nanoid';
3-
41
import { useTranslationContext } from '../../context/TranslationContext';
52

6-
export const LoadingIndicatorIcon = () => {
7-
const id = useMemo(() => nanoid(), []);
8-
9-
return (
10-
<div className='str-chat__loading-indicator'>
11-
<svg
12-
data-testid='loading-indicator'
13-
viewBox='0 0 30 30'
14-
xmlns='http://www.w3.org/2000/svg'
15-
>
16-
<defs>
17-
<linearGradient
18-
id={`${id}-linear-gradient`}
19-
x1='50%'
20-
x2='50%'
21-
y1='0%'
22-
y2='100%'
23-
>
24-
<stop offset='0%' stopColor='#FFF' stopOpacity='0' />
25-
<stop data-testid='stop-color' offset='100%' stopOpacity='1' />
26-
</linearGradient>
27-
</defs>
28-
<path
29-
d='M2.518 23.321l1.664-1.11A12.988 12.988 0 0 0 15 28c7.18 0 13-5.82 13-13S22.18 2 15 2V0c8.284 0 15 6.716 15 15 0 8.284-6.716 15-15 15-5.206 0-9.792-2.652-12.482-6.679z'
30-
fill={`url(#${id}-linear-gradient)`}
31-
fillRule='evenodd'
32-
/>
33-
</svg>
34-
</div>
35-
);
36-
};
37-
383
export const UploadIcon = () => {
394
const { t } = useTranslationContext('UploadIcon');
405
return (

0 commit comments

Comments
 (0)