Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/custom-emoji-update
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkrin authored Jul 30, 2024
2 parents fb311c4 + 851d60a commit ff62710
Show file tree
Hide file tree
Showing 67 changed files with 824 additions and 339 deletions.
6 changes: 6 additions & 0 deletions .changeset/thirty-dryers-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/livechat": patch
---

Fixed issue where `after-registration-triggers` would show up in a page when the user was not yet registered
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ class CachedCollectionManager extends Emitter<{ reconnect: void; login: string |

private _syncEnabled: boolean;

private logged: boolean;

private step: number;

constructor() {
super();
this.items = [];
this._syncEnabled = false;
this.logged = false;

const { _unstoreLoginToken } = Accounts;
Accounts._unstoreLoginToken = (...args) => {
Expand All @@ -37,6 +40,14 @@ class CachedCollectionManager extends Emitter<{ reconnect: void; login: string |
return connected && this.emit('reconnect');
}
});

Accounts.onLogin(() => {
this.emit('login', Meteor.userId());
});
Tracker.autorun(() => {
const uid = Meteor.userId();
this.logged = uid !== null;
});
}

register(cachedCollection: CachedCollection<any>) {
Expand Down Expand Up @@ -69,7 +80,10 @@ class CachedCollectionManager extends Emitter<{ reconnect: void; login: string |
}

onLogin(cb: () => void) {
Accounts.onLogin(cb);
this.on('login', cb);
if (this.logged) {
cb();
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/app/utils/client/lib/SDKClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ const createStreamManager = () => {

const streams = new Map<string, StreamMapValue>();

Accounts.onLogout(() => {
streams.forEach((stream) => {
stream.unsubList.forEach((stop) => stop());
});
});

Meteor.connection._stream.on('message', (rawMsg: string) => {
const msg = DDPCommon.parseDDP(rawMsg);
if (!isChangedCollectionPayload(msg)) {
Expand Down Expand Up @@ -166,7 +172,6 @@ const createStreamManager = () => {

const stop = (): void => {
streamProxy.off(eventLiteral, proxyCallback);

// If someone is still listening, don't unsubscribe
if (streamProxy.has(eventLiteral)) {
return;
Expand All @@ -179,11 +184,15 @@ const createStreamManager = () => {
};

const stream = streams.get(eventLiteral) || createNewMeteorStream(name, key, args);

stream.unsubList.add(stop);
if (!streams.has(eventLiteral)) {
streams.set(eventLiteral, stream);
}
stream.error(() => stop());

stream.error(() => {
stream.unsubList.forEach((stop) => stop());
});

return {
id: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AutoComplete, Option, Box, Chip, Options } from '@rocket.chat/fuselage';
import { AutoComplete, Option, Box, Chip } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import { UserAvatar } from '@rocket.chat/ui-avatar';
import { useEndpoint } from '@rocket.chat/ui-contexts';
Expand Down Expand Up @@ -46,7 +46,7 @@ const UserAutoComplete = ({ value, onChange, ...props }: UserAutoCompleteProps):
</Chip>
)}
renderItem={({ value, label, ...props }): ReactElement => (
<Option key={value} label={label} avatar={<UserAvatar size={Options.AvatarSize} username={value} />} {...props} />
<Option key={value} label={label} avatar={<UserAvatar size='x20' username={value} />} {...props} />
)}
options={options}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AutoComplete, Box, Option, Options, Chip } from '@rocket.chat/fuselage';
import { AutoComplete, Box, Option, Chip } from '@rocket.chat/fuselage';
import { useDebouncedValue } from '@rocket.chat/fuselage-hooks';
import { RoomAvatar } from '@rocket.chat/ui-avatar';
import { useEndpoint } from '@rocket.chat/ui-contexts';
Expand Down Expand Up @@ -58,7 +58,7 @@ const RoomsAvailableForTeamsAutoComplete = ({ value, onChange, ...props }: Rooms
key={value}
{...props}
label={label.name}
avatar={<RoomAvatar room={{ _id: value, type: label.type, avatarETag: label.avatarETag }} size={Options.AvatarSize} />}
avatar={<RoomAvatar room={{ _id: value, type: label.type, avatarETag: label.avatarETag }} size='x20' />}
/>
)}
options={options}
Expand Down
Loading

0 comments on commit ff62710

Please sign in to comment.