Skip to content

Commit d5a34c5

Browse files
committed
refactor: remove UploadProgressIndicator and AttachmentUploadedSizeIndicator from ComponentContext
1 parent 52f063d commit d5a34c5

File tree

5 files changed

+9
-29
lines changed

5 files changed

+9
-29
lines changed

src/components/MediaRecorder/AudioRecorder/AudioRecorderRecordingControls.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import { IconDelete, IconPauseFill, IconVoice } from '../../Icons';
33
import React from 'react';
44
import {
55
useChatContext,
6-
useComponentContext,
76
useMessageComposerContext,
87
useTranslationContext,
98
} from '../../../context';
109
import { isRecording } from './recordingStateIdentity';
1110
import { Button } from '../../Button';
1211
import { addNotificationTargetTag, useNotificationTarget } from '../../Notifications';
13-
import { UploadProgressIndicator as DefaultUploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
12+
import { UploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
1413

1514
const ToggleRecordingButton = () => {
1615
const {
@@ -36,8 +35,6 @@ const ToggleRecordingButton = () => {
3635
export const AudioRecorderRecordingControls = () => {
3736
const { client } = useChatContext();
3837
const { t } = useTranslationContext();
39-
const { UploadProgressIndicator = DefaultUploadProgressIndicator } =
40-
useComponentContext();
4138
const {
4239
recordingController: { completeRecording, recorder, recording, recordingState },
4340
} = useMessageComposerContext();

src/components/MessageComposer/AttachmentPreviewList/AudioAttachmentPreview.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
type LocalAudioAttachment,
55
type LocalVoiceRecordingAttachment,
66
} from 'stream-chat';
7-
import { useComponentContext, useTranslationContext } from '../../../context';
7+
import { useTranslationContext } from '../../../context';
88
import React, { useEffect } from 'react';
99
import clsx from 'clsx';
10-
import { UploadProgressIndicator as DefaultUploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
10+
import { UploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
1111
import { RemoveAttachmentPreviewButton } from '../RemoveAttachmentPreviewButton';
1212
import { AttachmentPreviewRoot } from './utils/AttachmentPreviewRoot';
1313
import { IconExclamationMark, IconExclamationTriangleFill } from '../../Icons';
@@ -20,7 +20,7 @@ import {
2020
} from '../../AudioPlayback';
2121
import { useAudioPlayer } from '../../AudioPlayback/WithAudioPlayback';
2222
import { useStateStore } from '../../../store';
23-
import { AttachmentUploadedSizeIndicator as DefaultAttachmentUploadedSizeIndicator } from './AttachmentUploadedSizeIndicator';
23+
import { AttachmentUploadedSizeIndicator } from './AttachmentUploadedSizeIndicator';
2424

2525
export type AudioAttachmentPreviewProps<CustomLocalMetadata = Record<string, unknown>> =
2626
UploadAttachmentPreviewProps<
@@ -42,10 +42,6 @@ export const AudioAttachmentPreview = ({
4242
removeAttachments,
4343
}: AudioAttachmentPreviewProps) => {
4444
const { t } = useTranslationContext();
45-
const {
46-
AttachmentUploadedSizeIndicator = DefaultAttachmentUploadedSizeIndicator,
47-
UploadProgressIndicator = DefaultUploadProgressIndicator,
48-
} = useComponentContext();
4945
const { id, previewUri, uploadPermissionCheck, uploadProgress, uploadState } =
5046
attachment.localMetadata ?? {};
5147
const url = attachment.asset_url || previewUri;

src/components/MessageComposer/AttachmentPreviewList/FileAttachmentPreview.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
2-
import { useComponentContext, useTranslationContext } from '../../../context';
2+
import { useTranslationContext } from '../../../context';
33
import { FileIcon } from '../../FileIcon';
4-
import { UploadProgressIndicator as DefaultUploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
5-
import { AttachmentUploadedSizeIndicator as DefaultAttachmentUploadedSizeIndicator } from './AttachmentUploadedSizeIndicator';
4+
import { UploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
5+
import { AttachmentUploadedSizeIndicator } from './AttachmentUploadedSizeIndicator';
66
import type { LocalAudioAttachment, LocalFileAttachment } from 'stream-chat';
77
import type { UploadAttachmentPreviewProps } from './types';
88
import { RemoveAttachmentPreviewButton } from '../RemoveAttachmentPreviewButton';
@@ -20,10 +20,6 @@ export const FileAttachmentPreview = ({
2020
removeAttachments,
2121
}: FileAttachmentPreviewProps) => {
2222
const { t } = useTranslationContext('FilePreview');
23-
const {
24-
AttachmentUploadedSizeIndicator = DefaultAttachmentUploadedSizeIndicator,
25-
UploadProgressIndicator = DefaultUploadProgressIndicator,
26-
} = useComponentContext();
2723
const { id, uploadPermissionCheck, uploadProgress, uploadState } =
2824
attachment.localMetadata ?? {};
2925

src/components/MessageComposer/AttachmentPreviewList/MediaAttachmentPreview.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import clsx from 'clsx';
1717
import { IconExclamationMark, IconRetry, IconVideoFill } from '../../Icons';
1818
import { RemoveAttachmentPreviewButton } from '../RemoveAttachmentPreviewButton';
1919
import { Button } from '../../Button';
20-
import { UploadProgressIndicator as DefaultUploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
20+
import { UploadProgressIndicator } from '../../Loading/UploadProgressIndicator';
2121
import { AttachmentPreviewRoot } from './utils/AttachmentPreviewRoot';
2222

2323
export type MediaAttachmentPreviewProps<CustomLocalMetadata = Record<string, unknown>> =
@@ -34,10 +34,7 @@ export const MediaAttachmentPreview = ({
3434
removeAttachments,
3535
}: MediaAttachmentPreviewProps) => {
3636
const { t } = useTranslationContext();
37-
const {
38-
BaseImage = DefaultBaseImage,
39-
UploadProgressIndicator = DefaultUploadProgressIndicator,
40-
} = useComponentContext();
37+
const { BaseImage = DefaultBaseImage } = useComponentContext();
4138
const [thumbnailPreviewError, setThumbnailPreviewError] = useState(false);
4239

4340
const { id, uploadPermissionCheck, uploadProgress, uploadState } =

src/context/ComponentContext.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ import type { FileIconProps } from '../components/FileIcon/FileIcon';
7676
import type { CommandChipProps } from '../components/MessageComposer/CommandChip';
7777
import type { CircularProgressIndicatorProps } from '../components/Loading/CircularProgressIndicator';
7878
import type { UploadedSizeIndicatorProps } from '../components/Loading/UploadedSizeIndicator';
79-
import type { UploadProgressIndicatorProps } from '../components/Loading/UploadProgressIndicator';
80-
import type { AttachmentUploadedSizeIndicatorProps } from '../components/MessageComposer/AttachmentPreviewList/AttachmentUploadedSizeIndicator';
8179

8280
export type ComponentContextValue = {
8381
/** Custom UI component to display additional message composer action buttons left to the textarea, defaults to and accepts same props as: [AdditionalMessageComposerActions](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageComposer/MessageComposerActions.tsx) */
@@ -90,8 +88,6 @@ export type ComponentContextValue = {
9088
AttachmentPreviewList?: React.ComponentType<AttachmentPreviewListProps>;
9189
/** Custom UI component to control adding attachments to MessageComposer, defaults to and accepts same props as: [AttachmentSelector](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageComposer/AttachmentSelector.tsx) */
9290
AttachmentSelector?: React.ComponentType;
93-
/** Custom UI component for uploaded/total size on attachment previews in MessageComposer, defaults to and accepts same props as: [AttachmentUploadedSizeIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageComposer/AttachmentPreviewList/AttachmentUploadedSizeIndicator.tsx) */
94-
AttachmentUploadedSizeIndicator?: React.ComponentType<AttachmentUploadedSizeIndicatorProps>;
9591
/** Custom UI component for the dedicated voice recording preview slot above composer attachments (REACT-794), defaults to and accepts same props as: [VoiceRecordingPreviewSlot](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageComposer/AttachmentPreviewList/VoiceRecordingPreviewSlot.tsx) */
9692
VoiceRecordingPreviewSlot?: React.ComponentType<VoiceRecordingPreviewSlotProps>;
9793
/** Custom UI component for contents of attachment selector initiation button */
@@ -271,8 +267,6 @@ export type ComponentContextValue = {
271267
UnreadMessagesNotification?: React.ComponentType<UnreadMessagesNotificationProps>;
272268
/** Custom UI component that separates read messages from unread, defaults to and accepts same props as: [UnreadMessagesSeparator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageList/UnreadMessagesSeparator.tsx) */
273269
UnreadMessagesSeparator?: React.ComponentType<UnreadMessagesSeparatorProps>;
274-
/** Custom UI component for upload progress (e.g. attachment previews, audio recording), defaults to and accepts same props as: [UploadProgressIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/UploadProgressIndicator.tsx) */
275-
UploadProgressIndicator?: React.ComponentType<UploadProgressIndicatorProps>;
276270
/** Custom UI component for uploaded vs total byte size during attachment upload (MessageComposer previews), defaults to and accepts same props as: [UploadedSizeIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/UploadedSizeIndicator.tsx) */
277271
UploadedSizeIndicator?: React.ComponentType<UploadedSizeIndicatorProps>;
278272
/** Component used to play video. If not provided, ReactPlayer is used as a default video player. */

0 commit comments

Comments
 (0)