The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/client/lib/settings/PrivateSettingsCachedCollec...

30 lines
873 B

import { CachedCollection } from '../../../app/ui-cached-collection/client';
import { Notifications } from '../../../app/notifications/client';
export class PrivateSettingsCachedCollection extends CachedCollection {
constructor() {
super({
name: 'private-settings',
eventType: 'onLogged',
});
}
async setupListener(): Promise<void> {
Notifications.onLogged(this.eventName, async (t: string, { _id, ...record }: { _id: string }) => {
this.log('record received', t, { _id, ...record });
this.collection.upsert({ _id }, record);
this.sync();
});
}
static instance: PrivateSettingsCachedCollection;
static get(): PrivateSettingsCachedCollection {
if (!PrivateSettingsCachedCollection.instance) {
PrivateSettingsCachedCollection.instance = new PrivateSettingsCachedCollection();
}
return PrivateSettingsCachedCollection.instance;
}
}