diff --git a/apps/meteor/client/providers/CustomSoundProvider.tsx b/apps/meteor/client/providers/CustomSoundProvider.tsx index 2b9f4d47e27c..cb2d2933117f 100644 --- a/apps/meteor/client/providers/CustomSoundProvider.tsx +++ b/apps/meteor/client/providers/CustomSoundProvider.tsx @@ -1,9 +1,8 @@ -import { CustomSoundContext, useUserId } from '@rocket.chat/ui-contexts'; +import { CustomSoundContext, useUserId, useStream } from '@rocket.chat/ui-contexts'; import type { FC } from 'react'; import React, { useEffect } from 'react'; import { CustomSounds } from '../../app/custom-sounds/client/lib/CustomSounds'; -import { sdk } from '../../app/utils/client/lib/SDKClient'; const CustomSoundProvider: FC = ({ children }) => { const userId = useUserId(); @@ -14,12 +13,14 @@ const CustomSoundProvider: FC = ({ children }) => { void CustomSounds.fetchCustomSoundList(); }, [userId]); + const streamAll = useStream('notify-all'); + useEffect(() => { if (!userId) { return; } - return sdk.stream('notify-all', ['public-info'], ([key, data]) => { + return streamAll('public-info', ([key, data]) => { switch (key) { case 'updateCustomSound': CustomSounds.update(data[0].soundData); @@ -28,8 +29,8 @@ const CustomSoundProvider: FC = ({ children }) => { CustomSounds.remove(data[0].soundData); break; } - }).stop; - }, [userId]); + }); + }, [userId, streamAll]); return ; };