snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
119
apps/meteor/client/cachedStores/RoomsCachedStore.ts
Normal file
119
apps/meteor/client/cachedStores/RoomsCachedStore.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import type { IOmnichannelRoom, IRoom, IRoomWithRetentionPolicy } from '@rocket.chat/core-typings';
|
||||
import { DEFAULT_SLA_CONFIG, isRoomNativeFederated, LivechatPriorityWeight } from '@rocket.chat/core-typings';
|
||||
import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts';
|
||||
|
||||
import { PrivateCachedStore } from '../lib/cachedStores/CachedStore';
|
||||
import { Rooms, Subscriptions } from '../stores';
|
||||
|
||||
class RoomsCachedStore extends PrivateCachedStore<IRoom> {
|
||||
constructor() {
|
||||
super({
|
||||
name: 'rooms',
|
||||
eventType: 'notify-user',
|
||||
store: Rooms.use,
|
||||
});
|
||||
}
|
||||
|
||||
private merge(room: IRoom, sub: SubscriptionWithRoom): SubscriptionWithRoom {
|
||||
return {
|
||||
...sub,
|
||||
encrypted: room.encrypted,
|
||||
description: room.description,
|
||||
cl: room.cl,
|
||||
topic: room.topic,
|
||||
announcement: room.announcement,
|
||||
broadcast: room.broadcast || undefined,
|
||||
archived: room.archived,
|
||||
avatarETag: room.avatarETag,
|
||||
retention: (room as IRoomWithRetentionPolicy | undefined)?.retention,
|
||||
uids: room.uids,
|
||||
usernames: room.usernames,
|
||||
usersCount: room.usersCount,
|
||||
lastMessage: room.lastMessage,
|
||||
teamId: room.teamId,
|
||||
teamMain: room.teamMain,
|
||||
v: (room as IOmnichannelRoom | undefined)?.v,
|
||||
transcriptRequest: (room as IOmnichannelRoom | undefined)?.transcriptRequest,
|
||||
servedBy: (room as IOmnichannelRoom | undefined)?.servedBy,
|
||||
onHold: (room as IOmnichannelRoom | undefined)?.onHold,
|
||||
tags: (room as IOmnichannelRoom | undefined)?.tags,
|
||||
closedAt: (room as IOmnichannelRoom | undefined)?.closedAt,
|
||||
metrics: (room as IOmnichannelRoom | undefined)?.metrics,
|
||||
muted: room.muted,
|
||||
waitingResponse: (room as IOmnichannelRoom | undefined)?.waitingResponse,
|
||||
responseBy: (room as IOmnichannelRoom | undefined)?.responseBy,
|
||||
priorityId: (room as IOmnichannelRoom | undefined)?.priorityId,
|
||||
priorityWeight: (room as IOmnichannelRoom | undefined)?.priorityWeight || LivechatPriorityWeight.NOT_SPECIFIED,
|
||||
estimatedWaitingTimeQueue:
|
||||
(room as IOmnichannelRoom | undefined)?.estimatedWaitingTimeQueue || DEFAULT_SLA_CONFIG.ESTIMATED_WAITING_TIME_QUEUE,
|
||||
slaId: (room as IOmnichannelRoom | undefined)?.slaId,
|
||||
livechatData: (room as IOmnichannelRoom | undefined)?.livechatData,
|
||||
departmentId: (room as IOmnichannelRoom | undefined)?.departmentId,
|
||||
ts: room.ts ?? sub.ts,
|
||||
source: (room as IOmnichannelRoom | undefined)?.source,
|
||||
queuedAt: (room as IOmnichannelRoom | undefined)?.queuedAt,
|
||||
federated: room.federated,
|
||||
abacAttributes: room.abacAttributes,
|
||||
...(isRoomNativeFederated(room) && {
|
||||
federation: room.federation,
|
||||
}),
|
||||
...(() => {
|
||||
const name = room.name || sub.name;
|
||||
const fname = room.fname || sub.fname || name;
|
||||
return {
|
||||
lowerCaseName: String(!room.prid ? name : fname).toLowerCase(),
|
||||
lowerCaseFName: String(fname).toLowerCase(),
|
||||
};
|
||||
})(),
|
||||
lm: (sub.lm?.getTime() ?? -1) < (room.lm?.getTime() ?? -1) ? room.lm : sub.lm,
|
||||
};
|
||||
}
|
||||
|
||||
protected override handleLoadedFromServer(rooms: IRoom[]): void {
|
||||
const indexedSubscriptions = Subscriptions.use.getState().indexBy('rid');
|
||||
|
||||
const subscriptionsWithRoom = rooms.flatMap((room) => {
|
||||
const sub = indexedSubscriptions.get(room._id);
|
||||
|
||||
if (!sub) return [];
|
||||
|
||||
return this.merge(room, sub);
|
||||
});
|
||||
|
||||
Subscriptions.use.getState().storeMany(subscriptionsWithRoom);
|
||||
}
|
||||
|
||||
protected override async handleRecordEvent(action: 'removed' | 'changed', room: IRoom) {
|
||||
await super.handleRecordEvent(action, room);
|
||||
|
||||
if (action === 'removed') return;
|
||||
|
||||
Subscriptions.use.getState().update(
|
||||
(record) => record.rid === room._id,
|
||||
(sub) => this.merge(room, sub),
|
||||
);
|
||||
}
|
||||
|
||||
protected override handleSyncEvent(action: 'removed' | 'changed', room: IRoom): void {
|
||||
if (action === 'removed') return;
|
||||
|
||||
Subscriptions.use.getState().update(
|
||||
(record) => record.rid === room._id,
|
||||
(sub) => this.merge(room, sub),
|
||||
);
|
||||
}
|
||||
|
||||
protected override deserializeFromCache(record: unknown) {
|
||||
const deserialized = super.deserializeFromCache(record);
|
||||
|
||||
if (deserialized?.lastMessage?._updatedAt) {
|
||||
deserialized.lastMessage._updatedAt = new Date(deserialized.lastMessage._updatedAt);
|
||||
}
|
||||
|
||||
return deserialized;
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new RoomsCachedStore();
|
||||
|
||||
export { instance as RoomsCachedStore };
|
||||
Reference in New Issue
Block a user