Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Oct 20, 2023
1 parent b3076bb commit d4c8d58
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/meteor/client/providers/CustomSoundProvider.tsx
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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);
Expand All @@ -28,8 +29,8 @@ const CustomSoundProvider: FC = ({ children }) => {
CustomSounds.remove(data[0].soundData);
break;
}
}).stop;
}, [userId]);
});
}, [userId, streamAll]);
return <CustomSoundContext.Provider children={children} value={CustomSounds} />;
};

Expand Down

0 comments on commit d4c8d58

Please sign in to comment.