Skip to content

Commit

Permalink
Merge branch 'develop' into test/decouple-teams
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 27, 2024
2 parents 50e3290 + 957ccf8 commit fe3a9a1
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-maps-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed streams being called when the user is not logged in
12 changes: 6 additions & 6 deletions apps/meteor/client/hooks/useVoipClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export const useVoipClient = (): UseVoipClientResult => {
const isEE = useHasLicenseModule('voip-enterprise');
const voipEnabled = settingVoipEnabled && voipConnectorEnabled;

useEffect(
() =>
subscribeToNotifyLoggedIn(`voip.statuschanged`, (enabled: boolean): void => {
useEffect(() => {
if (user) {
return subscribeToNotifyLoggedIn(`voip.statuschanged`, (enabled: boolean): void => {
setVoipConnectorEnabled(enabled);
}),
[setResult, setVoipConnectorEnabled, subscribeToNotifyLoggedIn],
);
});
}
}, [setResult, setVoipConnectorEnabled, subscribeToNotifyLoggedIn, user]);

useEffect(() => {
const uid = user?._id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { useStream } from '@rocket.chat/ui-contexts';
import { useStream, useUserId } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { updateEmojiCustom, deleteEmojiCustom } from '../../../app/emoji-custom/client/lib/emojiCustom';

export const useUpdateCustomEmoji = () => {
const notify = useStream('notify-logged');
const uid = useUserId();
useEffect(() => {
if (!uid) {
return;
}

const unsubUpdate = notify('updateEmojiCustom', (data) => updateEmojiCustom(data.emojiData));
const unsubDelete = notify('deleteEmojiCustom', (data) => deleteEmojiCustom(data.emojiData));

return () => {
unsubUpdate();
unsubDelete();
};
}, [notify]);
}, [notify, uid]);
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { useStream } from '@rocket.chat/ui-contexts';
import { useStream, useUserId } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { ChatMessage } from '../../../../app/models/client';

export const useDeleteUser = () => {
const notify = useStream('notify-logged');

const uid = useUserId();
useEffect(() => {
if (!uid) {
return;
}
return notify('Users:Deleted', ({ userId, messageErasureType, replaceByUser }) => {
if (messageErasureType === 'Unlink' && replaceByUser) {
return ChatMessage.update(
Expand All @@ -28,5 +32,5 @@ export const useDeleteUser = () => {
'u._id': userId,
});
});
}, [notify]);
}, [notify, uid]);
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { useStream } from '@rocket.chat/ui-contexts';
import { useUserId, useStream } from '@rocket.chat/ui-contexts';
import { Meteor } from 'meteor/meteor';
import { useEffect } from 'react';

export const useUpdateAvatar = () => {
const notify = useStream('notify-logged');
const uid = useUserId();
useEffect(() => {
if (!uid) {
return;
}
return notify('updateAvatar', (data) => {
if ('username' in data) {
const { username, etag } = data;
username && Meteor.users.update({ username }, { $set: { avatarETag: etag } });
}
});
}, [notify]);
}, [notify, uid]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Meteor.startup(() => {
Tracker.autorun(() => {
if (!Meteor.userId() || !settings.get('Outlook_Calendar_Enabled')) {
sdk.stop('notify-user', `${Meteor.userId()}/calendar`);
return;
}

sdk.stream('notify-user', [`${Meteor.userId()}/calendar`], notifyUserCalendar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { test, expect } from '../utils/test';

test.use({ storageState: Users.user1.state });

test.describe('OC - Manual Selection', () => {
test.describe('OC - Manual Selection After Relogin', () => {
let poOmnichannel: HomeOmnichannel;
let agent: Awaited<ReturnType<typeof createAgent>>;

Expand Down

0 comments on commit fe3a9a1

Please sign in to comment.