@corva/chat-core 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -78,7 +78,6 @@ interface AskCorvaData {
78
78
  companyId?: number;
79
79
  isTruncated?: boolean;
80
80
  assetId?: number;
81
- agentName?: string;
82
81
  note?: string;
83
82
  }
84
83
 
@@ -175,7 +174,6 @@ interface AskCorvaWirePayload {
175
174
  cId?: number;
176
175
  trunc?: boolean;
177
176
  assetId?: number;
178
- agentName?: string;
179
177
  n?: string;
180
178
  }
181
179
  /**
@@ -831,7 +829,7 @@ interface ParsedCorvaMessage {
831
829
  /**
832
830
  * Builds the wire-format content string for an AskCorva response.
833
831
  */
834
- declare function buildAskCorvaMessageContent(requestId: string, answer: string, answerRef?: string, isTruncated?: boolean, assetId?: number, agentName?: string, companyId?: number, note?: string): string;
832
+ declare function buildAskCorvaMessageContent(requestId: string, answer: string, answerRef?: string, isTruncated?: boolean, assetId?: number, companyId?: number, note?: string): string;
835
833
  /**
836
834
  * Builds the wire-format content string for a forwarded message.
837
835
  */
@@ -865,16 +863,17 @@ declare const searchRooms: (rooms: (Room | Subscription)[], query: string) => (R
865
863
  declare const searchUsers: (users: User[], query: string) => User[];
866
864
 
867
865
  declare const compareByRecencyDesc: (a: Subscription, b: Subscription) => number;
866
+ declare const compareByUnreadThenRecency: (a: Subscription, b: Subscription) => number;
868
867
 
869
868
  /**
870
869
  * Sorts channels: pinned first (asset chat if set, else General), then by the
871
- * chosen order — alphabetically by name or most recent activity first.
870
+ * chosen order — alphabetically by name, or unread first and then most recent activity.
872
871
  */
873
872
  declare function sortChannels(channels: Subscription[], assetChatId: string | undefined, order?: RoomListOrder): Subscription[];
874
873
 
875
874
  /**
876
875
  * Sorts DMs and group DMs by the chosen order — alphabetically by display name
877
- * or most recent activity first.
876
+ * or unread first and then most recent activity.
878
877
  */
879
878
  declare function sortDMs(dms: Subscription[], order?: RoomListOrder): Subscription[];
880
879
 
@@ -981,6 +980,7 @@ declare function createHttpClient(config: HttpClientConfig): {
981
980
  type HttpClient = ReturnType<typeof createHttpClient>;
982
981
 
983
982
  declare function createRevoltAPI(baseUrl: string, platform: ChatPlatform): {
983
+ getServerMembers: (serverId: string) => Promise<User[]>;
984
984
  getBaseUrl: () => string;
985
985
  seedUserCache: (users: User[]) => void;
986
986
  clearUserCache: () => void;
@@ -992,7 +992,6 @@ declare function createRevoltAPI(baseUrl: string, platform: ChatPlatform): {
992
992
  addUserToGroup: (groupId: string, userId: string) => Promise<boolean>;
993
993
  removeUserFromGroup: (groupId: string, userId: string) => Promise<boolean>;
994
994
  getGroupMembers: (groupId: string) => Promise<User[]>;
995
- getServerMembers: (serverId: string) => Promise<User[]>;
996
995
  getOrCreateDMFromUser: (userId: string) => Promise<{
997
996
  _id: string;
998
997
  }>;
@@ -1025,6 +1024,7 @@ declare function createRevoltAPI(baseUrl: string, platform: ChatPlatform): {
1025
1024
  getUser: (userId: string) => Promise<User | null>;
1026
1025
  getFriends: () => Promise<User[]>;
1027
1026
  searchUsers: (_query: string) => Promise<User[]>;
1027
+ trackDirectoryLoad: <T extends User[]>(load: Promise<T>) => Promise<T>;
1028
1028
  login: (credentials: LoginCredentials) => Promise<{
1029
1029
  token: string;
1030
1030
  me: User;
@@ -1810,4 +1810,4 @@ declare const createSocketEventHandlers: (config: SocketEventHandlersConfig) =>
1810
1810
 
1811
1811
  declare const installUnreadWatcher: () => void;
1812
1812
 
1813
- export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, type AckScheduler, type AlertData, type AlertSeverity, type AlertWirePayload, type AppCommentAttachment, type AppCommentData, type AppCommentWirePayload, type AppStateAdapter, type AskCorvaData, type AskCorvaWirePayload, type AssetChatChannel, type AssetChatSession, type AssetStore, type Attachment, type AuthStore, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_JOIN_MESSAGE_TYPE, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, type ChannelAsset, type ChannelContentFilter, type ChannelContentFilterStore, type ChannelContentFilters, type ChannelNameValidation, type ChannelNotificationPreference, type ChannelNotificationSetting, type ChannelUnread, type ChatAsset, type ChatAssetIdentity, type ChatAssetType, type ChatDates, type ChatHost, type ChatNotifier, type ChatPlatform, type CorvaAPIUser, type CorvaApiAdapter, type CorvaRevoltAuthResponse, type CorvaSystemMessage, type CorvaUser, type CorvaUserService, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, type EditableMentionText, type ExternalChannel, type FavoriteRoomsSettings, type FavoriteRoomsStore, type FeedItemData, type FeedWirePayload, type FileAttachment, type FilterEntityWindow, type ForwardWirePayload, type ForwardedFrom, GENERAL_CHAT_NAME, type HiddenRoomsSettings, type HttpClient, type HttpClientConfig, HttpError, type HttpRequestInit, type HttpResponseLike, type JoinRequired, type JoinWirePayload, type KeyValueStorage, type LocatorContext, type LoginCredentials, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_BOUNDARY_SOURCE, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MENTION_USERNAME_SOURCE, MUTE_PRESET_OPTIONS, type MemberStore, type MentionDisplayResolver, type MentionFormat, type MentionLookupOptions, type MentionSegment, type MentionTextSegment, type MentionUserIds, type Message, type MessageCache, type MessageFormData, type MessageStore, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, type NavigationEntry, type NavigationHistoryStore, type NotificationDestination, type NotificationPreferences, type NotificationSettings, type NotificationStore, type OutgoingMentionOptions, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, type PausePreset, type PausePresetOption, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, type ReadyChannelData, type RevoltAPIInstance, type RevoltChannel, type RevoltIncomingMessagePayload, type RevoltLoginResponse, type RevoltMessage, type RevoltMessageResponse, type RevoltSocketConfig, type RevoltSocketEventHandlers, type RevoltSocketInstance, type RevoltUploadResponse, type RevoltUserResponse, type Room, type RoomListOrder, type RoomStore, type RoomType, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, type SaveSessionParams, type SelectableAssetType, type SessionData, SessionManager, type SharedFile, type SharedRefs, type SidebarSectionKey, type SidebarTabKey, type SocketCloseEventLike, type SocketEventHandlersConfig, type StoredChannelPreference, type Subscription, type TextSegment, type TracesViewportRequest, type TypingManager, type UIStore, type UploadAndSendResult, type UploadFile, type UploadedFile, type User, type UserStatus, type ViewportDeepLink, type ViewportIndexCurve, type ViewportMode, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, type WebSocketLike, type WireSeverity, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, clearLastOpenedThread, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, createChannelSubscription, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, decodeMentionsForEdit, deriveAllowedChatAsset, encodeMentionsForSend, encodeOutgoingMentions, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, findMentionUserById, findMentionUserByUsername, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetChatSession, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getCorvaUserName, getExternalChannel, getHydratedAckedId, getLastOpenedRoom, getLastOpenedThread, getMentionLabel, getMentionSearchHandle, getMentionedUserIds, getMessageTimestamp, getPauseUntil, getPlatformMentionUserIds, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isExternalServerChannel, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnknownMention, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, mapCorvaMessageNote, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, resolveMentionDisplayName, roomStore, saveLastChatActivity, saveLastOpenedRoom, saveLastOpenedThread, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, toEditableMentionText, toReadableMentionText, toReadableText, tokenizeMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
1813
+ export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, type AckScheduler, type AlertData, type AlertSeverity, type AlertWirePayload, type AppCommentAttachment, type AppCommentData, type AppCommentWirePayload, type AppStateAdapter, type AskCorvaData, type AskCorvaWirePayload, type AssetChatChannel, type AssetChatSession, type AssetStore, type Attachment, type AuthStore, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_JOIN_MESSAGE_TYPE, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, type ChannelAsset, type ChannelContentFilter, type ChannelContentFilterStore, type ChannelContentFilters, type ChannelNameValidation, type ChannelNotificationPreference, type ChannelNotificationSetting, type ChannelUnread, type ChatAsset, type ChatAssetIdentity, type ChatAssetType, type ChatDates, type ChatHost, type ChatNotifier, type ChatPlatform, type CorvaAPIUser, type CorvaApiAdapter, type CorvaRevoltAuthResponse, type CorvaSystemMessage, type CorvaUser, type CorvaUserService, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, type EditableMentionText, type ExternalChannel, type FavoriteRoomsSettings, type FavoriteRoomsStore, type FeedItemData, type FeedWirePayload, type FileAttachment, type FilterEntityWindow, type ForwardWirePayload, type ForwardedFrom, GENERAL_CHAT_NAME, type HiddenRoomsSettings, type HttpClient, type HttpClientConfig, HttpError, type HttpRequestInit, type HttpResponseLike, type JoinRequired, type JoinWirePayload, type KeyValueStorage, type LocatorContext, type LoginCredentials, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_BOUNDARY_SOURCE, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MENTION_USERNAME_SOURCE, MUTE_PRESET_OPTIONS, type MemberStore, type MentionDisplayResolver, type MentionFormat, type MentionLookupOptions, type MentionSegment, type MentionTextSegment, type MentionUserIds, type Message, type MessageCache, type MessageFormData, type MessageStore, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, type NavigationEntry, type NavigationHistoryStore, type NotificationDestination, type NotificationPreferences, type NotificationSettings, type NotificationStore, type OutgoingMentionOptions, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, type PausePreset, type PausePresetOption, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, type ReadyChannelData, type RevoltAPIInstance, type RevoltChannel, type RevoltIncomingMessagePayload, type RevoltLoginResponse, type RevoltMessage, type RevoltMessageResponse, type RevoltSocketConfig, type RevoltSocketEventHandlers, type RevoltSocketInstance, type RevoltUploadResponse, type RevoltUserResponse, type Room, type RoomListOrder, type RoomStore, type RoomType, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, type SaveSessionParams, type SelectableAssetType, type SessionData, SessionManager, type SharedFile, type SharedRefs, type SidebarSectionKey, type SidebarTabKey, type SocketCloseEventLike, type SocketEventHandlersConfig, type StoredChannelPreference, type Subscription, type TextSegment, type TracesViewportRequest, type TypingManager, type UIStore, type UploadAndSendResult, type UploadFile, type UploadedFile, type User, type UserStatus, type ViewportDeepLink, type ViewportIndexCurve, type ViewportMode, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, type WebSocketLike, type WireSeverity, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, clearLastOpenedThread, compareByActivity, compareByName, compareByRecencyDesc, compareByUnreadThenRecency, configureChat, configureChatStorage, createAckScheduler, createChannelSubscription, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, decodeMentionsForEdit, deriveAllowedChatAsset, encodeMentionsForSend, encodeOutgoingMentions, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, findMentionUserById, findMentionUserByUsername, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetChatSession, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getCorvaUserName, getExternalChannel, getHydratedAckedId, getLastOpenedRoom, getLastOpenedThread, getMentionLabel, getMentionSearchHandle, getMentionedUserIds, getMessageTimestamp, getPauseUntil, getPlatformMentionUserIds, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isExternalServerChannel, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnknownMention, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, mapCorvaMessageNote, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, resolveMentionDisplayName, roomStore, saveLastChatActivity, saveLastOpenedRoom, saveLastOpenedThread, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, toEditableMentionText, toReadableMentionText, toReadableText, tokenizeMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
package/dist/index.js CHANGED
@@ -517,7 +517,6 @@ function mapAskCorvaPayload(d) {
517
517
  companyId: d.cId,
518
518
  isTruncated: d.trunc,
519
519
  assetId: d.assetId,
520
- agentName: d.agentName,
521
520
  note: d.n || void 0
522
521
  };
523
522
  }
@@ -549,7 +548,7 @@ function mapAppCommentPayload(d) {
549
548
  isTruncated: d.trunc
550
549
  };
551
550
  }
552
- function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated, assetId, agentName, companyId, note) {
551
+ function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated, assetId, companyId, note) {
553
552
  const payload = {
554
553
  id: requestId,
555
554
  a: answerRef ? "" : answer,
@@ -557,7 +556,6 @@ function buildAskCorvaMessageContent(requestId, answer, answerRef, isTruncated,
557
556
  ...answerRef && companyId && { cId: companyId },
558
557
  ...isTruncated && { trunc: true },
559
558
  ...assetId && { assetId },
560
- ...agentName && { agentName },
561
559
  ...note?.trim() && { n: note.trim() }
562
560
  };
563
561
  return `${CORVA_SYS_PREFIX}${JSON.stringify({ t: CORVA_MESSAGE_TYPES.ASK_CORVA, v: 1, d: payload })}`;
@@ -3969,6 +3967,7 @@ function getRecencyMs(sub) {
3969
3967
  return Number.isNaN(created) ? 0 : created;
3970
3968
  }
3971
3969
  var compareByRecencyDesc = (a, b) => getRecencyMs(b) - getRecencyMs(a);
3970
+ var compareByUnreadThenRecency = (a, b) => Number(isUnread(b)) - Number(isUnread(a)) || compareByRecencyDesc(a, b);
3972
3971
 
3973
3972
  // src/utils/sortChannels.ts
3974
3973
  function sortChannels(channels, assetChatId, order = ROOM_LIST_ORDER.ALPHABETICAL) {
@@ -3981,7 +3980,7 @@ function sortChannels(channels, assetChatId, order = ROOM_LIST_ORDER.ALPHABETICA
3981
3980
  const pinned = pinnedIndex >= 0 ? list.splice(pinnedIndex, 1)[0] : null;
3982
3981
  const rest = list;
3983
3982
  rest.sort(
3984
- order === ROOM_LIST_ORDER.RECENT ? compareByRecencyDesc : compareByName(getRoomDisplayName)
3983
+ order === ROOM_LIST_ORDER.RECENT ? compareByUnreadThenRecency : compareByName(getRoomDisplayName)
3985
3984
  );
3986
3985
  return pinned ? [pinned, ...rest] : rest;
3987
3986
  }
@@ -3992,7 +3991,7 @@ function getDisplayName(sub) {
3992
3991
  }
3993
3992
  function sortDMs(dms, order = ROOM_LIST_ORDER.ALPHABETICAL) {
3994
3993
  return [...dms].sort(
3995
- order === ROOM_LIST_ORDER.RECENT ? compareByRecencyDesc : compareByName(getDisplayName)
3994
+ order === ROOM_LIST_ORDER.RECENT ? compareByUnreadThenRecency : compareByName(getDisplayName)
3996
3995
  );
3997
3996
  }
3998
3997
 
@@ -4155,6 +4154,17 @@ function createAuthAPI(http, tokenStore) {
4155
4154
  // src/api/modules/users.ts
4156
4155
  var userCache = {};
4157
4156
  var pendingRequests = {};
4157
+ var DIRECTORY_WAIT_MS = 2e3;
4158
+ var pendingDirectoryLoads = /* @__PURE__ */ new Set();
4159
+ async function waitForDirectoryLoads() {
4160
+ if (pendingDirectoryLoads.size === 0) return;
4161
+ let timer;
4162
+ const timeout = new Promise((resolve) => {
4163
+ timer = setTimeout(resolve, DIRECTORY_WAIT_MS);
4164
+ });
4165
+ await Promise.race([Promise.allSettled([...pendingDirectoryLoads]), timeout]);
4166
+ clearTimeout(timer);
4167
+ }
4158
4168
  function createUsersAPI(http) {
4159
4169
  async function getUser(userId) {
4160
4170
  if (userCache[userId]) {
@@ -4165,6 +4175,8 @@ function createUsersAPI(http) {
4165
4175
  }
4166
4176
  const request = (async () => {
4167
4177
  try {
4178
+ await waitForDirectoryLoads();
4179
+ if (userCache[userId]) return userCache[userId];
4168
4180
  const user = await http.request(`/users/${userId}`);
4169
4181
  const result = {
4170
4182
  _id: user._id,
@@ -4192,9 +4204,23 @@ function createUsersAPI(http) {
4192
4204
  }
4193
4205
  });
4194
4206
  }
4207
+ function trackDirectoryLoad(load) {
4208
+ const seeded = load.then(async (users) => {
4209
+ await new Promise((resolve) => {
4210
+ setTimeout(resolve, 0);
4211
+ });
4212
+ if (pendingDirectoryLoads.has(seeded)) seedUserCache(users);
4213
+ }).catch(() => {
4214
+ }).finally(() => {
4215
+ pendingDirectoryLoads.delete(seeded);
4216
+ });
4217
+ pendingDirectoryLoads.add(seeded);
4218
+ return load;
4219
+ }
4195
4220
  function clearUserCache() {
4196
4221
  Object.keys(userCache).forEach((key) => delete userCache[key]);
4197
4222
  Object.keys(pendingRequests).forEach((key) => delete pendingRequests[key]);
4223
+ pendingDirectoryLoads.clear();
4198
4224
  }
4199
4225
  async function getFriends() {
4200
4226
  try {
@@ -4248,6 +4274,7 @@ function createUsersAPI(http) {
4248
4274
  getFriends,
4249
4275
  searchUsers: searchUsers2,
4250
4276
  seedUserCache,
4277
+ trackDirectoryLoad,
4251
4278
  clearUserCache
4252
4279
  };
4253
4280
  }
@@ -4890,6 +4917,7 @@ function createRevoltAPI(baseUrl, platform) {
4890
4917
  ...attachments,
4891
4918
  ...directMessages,
4892
4919
  ...groups,
4920
+ getServerMembers: (serverId) => users.trackDirectoryLoad(groups.getServerMembers(serverId)),
4893
4921
  getBaseUrl: () => normalizedBaseUrl,
4894
4922
  seedUserCache: users.seedUserCache,
4895
4923
  clearUserCache: users.clearUserCache,
@@ -6293,6 +6321,6 @@ function ensureChatSession(corvaUser) {
6293
6321
  return inFlight;
6294
6322
  }
6295
6323
 
6296
- export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_JOIN_MESSAGE_TYPE, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, GENERAL_CHAT_NAME, HttpError, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_BOUNDARY_SOURCE, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MENTION_USERNAME_SOURCE, MUTE_PRESET_OPTIONS, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, SessionManager, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, clearLastOpenedThread, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, createChannelSubscription, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, decodeMentionsForEdit, deriveAllowedChatAsset, encodeMentionsForSend, encodeOutgoingMentions, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, findMentionUserById, findMentionUserByUsername, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetChatSession, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getCorvaUserName, getExternalChannel, getHydratedAckedId, getLastOpenedRoom, getLastOpenedThread, getMentionLabel, getMentionSearchHandle, getMentionedUserIds, getMessageTimestamp, getPauseUntil, getPlatformMentionUserIds, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isExternalServerChannel, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnknownMention, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, mapCorvaMessageNote, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, resolveMentionDisplayName, roomStore, saveLastChatActivity, saveLastOpenedRoom, saveLastOpenedThread, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, toEditableMentionText, toReadableMentionText, toReadableText, tokenizeMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
6324
+ export { ALERT_SEVERITY, ASSET_API_FIELDS, ASSET_CHAT_PREFIXES, ASSET_NOUN, CHANNEL_NAME_MAX_LENGTH, CHANNEL_TYPES, CORVA_JOIN_MESSAGE_TYPE, CORVA_MESSAGE_TYPES, CORVA_SYS_PREFIX, DATE_SEPARATOR_LABELS, DEFAULT_CHANNEL_CONTENT_FILTER, DEFAULT_CHANNEL_CONTENT_FILTERS, DEFAULT_CHANNEL_PREFERENCE, DEFAULT_FAVORITE_ROOMS_SETTINGS, DEFAULT_HIDDEN_ROOMS_SETTINGS, DEFAULT_NOTIFICATION_PREFERENCES, DEFAULT_NOTIFICATION_SETTINGS, DEFAULT_ROOM_LIST_ORDER, DIRECT_MESSAGE_PLACEHOLDER, GENERAL_CHAT_NAME, HttpError, MAX_ATTACHMENT_SIZE_BYTES, MAX_ATTACHMENT_SIZE_MB, MAX_NAVIGATION_HISTORY, MENTION_BOUNDARY_SOURCE, MENTION_REPLACE_PATTERN, MENTION_SPLIT_PATTERN, MENTION_USERNAME_SOURCE, MUTE_PRESET_OPTIONS, NOTIFICATION_DESTINATIONS, NOTIFICATION_SETTING_ALL, NOTIFICATION_SETTING_MENTIONS, NOTIFICATION_SETTING_NOTHING, PAUSE_INDEFINITELY, PAUSE_PRESETS, PAUSE_PRESET_OPTIONS, REVOLT_SYSTEM_USER_ID, ROOM_LIST_ORDER, SESSION_STORAGE_KEY, SIDEBAR_SECTIONS, SIDEBAR_TABS, SOFT_DELETE_MARKER, SYSTEM_MESSAGE_TEXTS, SessionManager, WEBSOCKET_CONNECTING, WEBSOCKET_OPEN, addMessage, addOrUpdateSubscription, alertMessageAsText, assetStore, authStore, buildAppCommentMessageContent, buildAskCorvaMessageContent, buildFinalMessage, buildForwardMessageContent, buildGroupChannelName, canDeleteMessage, canEditMessage, channelContentFilterStore, channelToAsset, chatToastStore, clearLastOpenedRoom, clearLastOpenedThread, compareByActivity, compareByName, compareByRecencyDesc, compareByUnreadThenRecency, configureChat, configureChatStorage, createAckScheduler, createChannelSubscription, createCorvaUserService, createDMSubscription, createGroupSubscription, createHttpClient, createLatestWinsQueue, createMemoryStorage, createMessageCache, createRevoltAPI, createRevoltSocket, createRoomTaskQueue, createSocketEventHandlers, createSoftDeletedMessage, createTypingManager, decodeMentionsForEdit, deriveAllowedChatAsset, encodeMentionsForSend, encodeOutgoingMentions, enrichWithCorvaData, ensureChatSession, extractTimestampFromULID, failOptimisticMessage, favoriteRoomsStore, findGeneralRoom, findMentionUserById, findMentionUserByUsername, formatAssetChatName, getAppCommentAttachments, getAssetChatChannel, getAssetChatSession, getAssetTypeFromDisplayName, getChatHost, getChatStorage, getCorvaUserFields, getCorvaUserName, getExternalChannel, getHydratedAckedId, getLastOpenedRoom, getLastOpenedThread, getMentionLabel, getMentionSearchHandle, getMentionedUserIds, getMessageTimestamp, getPauseUntil, getPlatformMentionUserIds, getReactionCount, getRoomDisplayName, getSystemMessageWithCorvaNames, getUserDisplayName, getUserSecondaryText, handleUnauthorized, hasReactions, hasUserReacted, initChat, installUnreadWatcher, isAlertMessage, isAppCommentMessage, isAskCorvaMessage, isChannelMuted, isChatAssetTypeAllowed, isChatStorageConfigured, isCurrentRoomSelection, isDeepEqual, isDefaultChannelPreference, isDisallowedAssetChatRoom, isDmGroup, isExternalServerChannel, isForwardedMessage, isGeneralRoom, isNotificationsPaused, isPauseActive, isSoftDeletedMessage, isSystemMessage, isUnknownMention, isUnread, isUserOnline, isValidPausePreset, isVisibleUnread, keepChatUsed, loadUntilFound, mapCorvaMessageNote, memberStore, messageStore, navigationHistoryStore, notificationStore, onChatStorageConfigured, parseCorvaSystemMessage, prepareRoomSelection, removeMessageFromList, removeSubscription, resetAssetStore, resetAuthStore, resetChannelContentFilterStore, resetChatAssetPermissionsSnapshot, resetChatHost, resetFavoriteRoomsStore, resetMemberStore, resetMessageStore, resetNavigationHistoryStore, resetNotificationStore, resetRoomStore, resetUIStore, resolveMentionDisplayName, roomStore, saveLastChatActivity, saveLastOpenedRoom, saveLastOpenedThread, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, toEditableMentionText, toReadableMentionText, toReadableText, tokenizeMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
6297
6325
  //# sourceMappingURL=index.js.map
6298
6326
  //# sourceMappingURL=index.js.map