You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
feat(session): snapshot getters for IgnoredUsersManager + GroupInformationManager
Extends the v2.1.0 React-friendly snapshot pattern (originally on SessionDataManager / RoomSessionManager) to two more session-state holders the React client reads frequently: - IgnoredUsersManager.getIgnoredUsersSnapshot(): ReadonlyArray<string> - GroupInformationManager.getGroupBadgesSnapshot(): ReadonlyMap<number, string> Both follow the same shape: lazy-frozen snapshot, cached until the underlying state mutates, then invalidated and a dispatched event lets the React client rebuild via useSyncExternalStore. Two new NitroEventType members carry the invalidation signal: - IGNORED_USERS_UPDATED — dispatched by IgnoredUsersManager whenever the list changes (initial load, add, remove, queue-truncate case 2). - GROUP_BADGES_UPDATED — dispatched by GroupInformationManager only when the incoming HabboGroupBadges payload contains at least one new or changed mapping (no-op refresh stays quiet). This lets the user-info popup, profile page, friend/guild filtering, and any other consumer share a single read through useSyncExternalStore instead of each subscribing to the underlying message events independently. API additions are interface-respecting and backwards-compatible — the existing `isIgnored(name)` / `getGroupBadge(groupId)` accessors stay untouched.
This commit is contained in:
@@ -2,4 +2,13 @@ export interface IGroupInformationManager
|
||||
{
|
||||
init(): void;
|
||||
getGroupBadge(groupId: number): string;
|
||||
|
||||
/**
|
||||
* Returns the current `groupId -> badgeId` map as a frozen,
|
||||
* referentially stable ReadonlyMap. The same reference is returned
|
||||
* across reads until the underlying badges change; mutations
|
||||
* dispatch `NitroEventType.GROUP_BADGES_UPDATED` to signal
|
||||
* invalidation.
|
||||
*/
|
||||
getGroupBadgesSnapshot(): ReadonlyMap<number, string>;
|
||||
}
|
||||
|
||||
@@ -6,4 +6,14 @@ export interface IIgnoredUsersManager
|
||||
ignoreUser(name: string): void;
|
||||
unignoreUser(name: string): void;
|
||||
isIgnored(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns the current ignored-users list as a frozen, referentially
|
||||
* stable array. The same reference is returned across reads until
|
||||
* the list is mutated; mutations dispatch
|
||||
* `NitroEventType.IGNORED_USERS_UPDATED` to signal invalidation.
|
||||
*
|
||||
* Pairs with `useSyncExternalStore` on the React client.
|
||||
*/
|
||||
getIgnoredUsersSnapshot(): ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user