Skip to content

Commit 0d5b256

Browse files
committed
fix: change withaudioplayback to appropriate provider
1 parent 6307437 commit 0d5b256

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import {
5454
} from '../../contexts';
5555
import {
5656
AudioPlayerContextProps,
57-
WithAudioPlayback,
57+
AudioPlayerProvider,
5858
} from '../../contexts/audioPlayerContext/AudioPlayerContext';
5959
import { ChannelContextValue, ChannelProvider } from '../../contexts/channelContext/ChannelContext';
6060
import type { UseChannelStateValue } from '../../contexts/channelsStateContext/useChannelState';
@@ -1667,13 +1667,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
16671667
}
16681668
});
16691669

1670-
const audioPlayerProviderProps = useMemo<AudioPlayerContextProps>(
1671-
() => ({
1672-
allowConcurrentAudioPlayback,
1673-
}),
1674-
[allowConcurrentAudioPlayback],
1675-
);
1676-
16771670
const attachmentPickerProps = useMemo(
16781671
() => ({
16791672
AttachmentPickerBottomSheetHandle,
@@ -1974,6 +1967,11 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19741967
typing: channelState.typing ?? {},
19751968
});
19761969

1970+
const audioPlayerContext = useMemo<AudioPlayerContextProps>(
1971+
() => ({ allowConcurrentAudioPlayback }),
1972+
[allowConcurrentAudioPlayback],
1973+
);
1974+
19771975
const messageComposerContext = useMemo(
19781976
() => ({ channel, thread, threadInstance }),
19791977
[channel, thread, threadInstance],
@@ -2012,12 +2010,12 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
20122010
<AttachmentPickerProvider value={attachmentPickerContext}>
20132011
<MessageComposerProvider value={messageComposerContext}>
20142012
<MessageInputProvider value={inputMessageInputContext}>
2015-
<WithAudioPlayback props={audioPlayerProviderProps}>
2013+
<AudioPlayerProvider value={audioPlayerContext}>
20162014
<View style={{ height: '100%' }}>{children}</View>
20172015
{!disableAttachmentPicker && (
20182016
<AttachmentPicker ref={bottomSheetRef} {...attachmentPickerProps} />
20192017
)}
2020-
</WithAudioPlayback>
2018+
</AudioPlayerProvider>
20212019
</MessageInputProvider>
20222020
</MessageComposerProvider>
20232021
</AttachmentPickerProvider>

package/src/contexts/audioPlayerContext/AudioPlayerContext.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export const AudioPlayerContext = createContext<AudioPlayerContextValue>(
1616
DEFAULT_BASE_CONTEXT_VALUE as AudioPlayerContextValue,
1717
);
1818

19-
export const WithAudioPlayback = ({
20-
props: { allowConcurrentAudioPlayback },
19+
export const AudioPlayerProvider = ({
20+
value,
2121
children,
22-
}: PropsWithChildren<{ props: AudioPlayerContextProps }>) => {
22+
}: PropsWithChildren<{ value: AudioPlayerContextProps }>) => {
23+
const { allowConcurrentAudioPlayback } = value;
2324
const audioPlayerPool = useMemo(
2425
() => new AudioPlayerPool({ allowConcurrentAudioPlayback }),
2526
[allowConcurrentAudioPlayback],

0 commit comments

Comments
 (0)