@corva/chat-core 0.1.14 → 0.1.16
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 +9 -1
- package/dist/index.js +101 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -514,6 +514,7 @@ interface ReadyChannelData {
|
|
|
514
514
|
channel_type: string;
|
|
515
515
|
last_message_id?: string;
|
|
516
516
|
name?: string;
|
|
517
|
+
server?: string;
|
|
517
518
|
}
|
|
518
519
|
interface ChannelUnread {
|
|
519
520
|
_id: {
|
|
@@ -538,6 +539,7 @@ interface RevoltSocketEventHandlers {
|
|
|
538
539
|
onRoomChange?: (roomId: string, change: unknown) => void;
|
|
539
540
|
onChannelAck?: (channelId: string, messageId: string) => void;
|
|
540
541
|
onServerMembersChange?: (serverId: string) => void;
|
|
542
|
+
onServerJoined?: (channels: ReadyChannelData[]) => void;
|
|
541
543
|
onError?: (error: unknown) => void;
|
|
542
544
|
}
|
|
543
545
|
|
|
@@ -1110,6 +1112,10 @@ declare class SessionManager {
|
|
|
1110
1112
|
declare function saveLastOpenedRoom(roomId: string, userId: string): void;
|
|
1111
1113
|
declare function getLastOpenedRoom(userId: string): string | null;
|
|
1112
1114
|
declare function clearLastOpenedRoom(userId: string): void;
|
|
1115
|
+
declare function saveLastOpenedThread(roomId: string, threadId: string, userId: string): void;
|
|
1116
|
+
/** The thread the user last had open in this room, if they didn't close it. */
|
|
1117
|
+
declare function getLastOpenedThread(userId: string, roomId: string): string | null;
|
|
1118
|
+
declare function clearLastOpenedThread(userId: string): void;
|
|
1113
1119
|
declare function saveLastChatActivity(userId: string): void;
|
|
1114
1120
|
declare function wasRecentlyActive(userId: string, thresholdDays?: number): boolean;
|
|
1115
1121
|
|
|
@@ -1173,6 +1179,7 @@ declare const createGroupSubscription: (groupId: string, name: string, owner: {
|
|
|
1173
1179
|
_id: string;
|
|
1174
1180
|
username: string;
|
|
1175
1181
|
}, recipientIds: string[]) => Subscription;
|
|
1182
|
+
declare const createChannelSubscription: (channelId: string, name: string, lastMessageId?: string) => Subscription;
|
|
1176
1183
|
declare const createDMSubscription: (roomId: string, recipient?: User) => Subscription;
|
|
1177
1184
|
declare const addOrUpdateSubscription: (subscriptions: Subscription[], newSubscription: Subscription) => Subscription[];
|
|
1178
1185
|
declare const removeSubscription: (subscriptions: Subscription[], roomId: string) => Subscription[];
|
|
@@ -1780,6 +1787,7 @@ declare const createSocketEventHandlers: (config: SocketEventHandlersConfig) =>
|
|
|
1780
1787
|
onAuthenticated: () => void;
|
|
1781
1788
|
onDisconnected: () => void;
|
|
1782
1789
|
onReady: (channels: ReadyChannelData[], channelUnreads?: ChannelUnread[]) => void;
|
|
1790
|
+
onServerJoined: (channels: ReadyChannelData[]) => void;
|
|
1783
1791
|
onChannelAck: (channelId: string, messageId: string) => void;
|
|
1784
1792
|
onMessage: (message: Message) => void;
|
|
1785
1793
|
onRoomChange: (roomId: string, change: unknown) => void;
|
|
@@ -1802,4 +1810,4 @@ declare const createSocketEventHandlers: (config: SocketEventHandlersConfig) =>
|
|
|
1802
1810
|
|
|
1803
1811
|
declare const installUnreadWatcher: () => void;
|
|
1804
1812
|
|
|
1805
|
-
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, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, 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, 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, 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, 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
|
@@ -1119,6 +1119,7 @@ var removeMessageFromList = (messages, messageId) => {
|
|
|
1119
1119
|
|
|
1120
1120
|
// src/store/services/lastRoomTracker.ts
|
|
1121
1121
|
var STORAGE_KEY_PREFIX = "corva_chat_last_room";
|
|
1122
|
+
var THREAD_KEY_PREFIX = "corva_chat_last_thread";
|
|
1122
1123
|
var ACTIVITY_KEY_PREFIX = "corva_chat_last_activity";
|
|
1123
1124
|
var DEFAULT_ACTIVITY_THRESHOLD_DAYS = 3;
|
|
1124
1125
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1149,6 +1150,34 @@ function clearLastOpenedRoom(userId) {
|
|
|
1149
1150
|
console.error("Failed to clear last opened room");
|
|
1150
1151
|
}
|
|
1151
1152
|
}
|
|
1153
|
+
function getThreadKey(userId) {
|
|
1154
|
+
return `${THREAD_KEY_PREFIX}_${userId}`;
|
|
1155
|
+
}
|
|
1156
|
+
function saveLastOpenedThread(roomId, threadId, userId) {
|
|
1157
|
+
try {
|
|
1158
|
+
const thread = { roomId, threadId };
|
|
1159
|
+
getChatStorage().setItem(getThreadKey(userId), JSON.stringify(thread));
|
|
1160
|
+
} catch {
|
|
1161
|
+
console.error("Failed to save last opened thread");
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function getLastOpenedThread(userId, roomId) {
|
|
1165
|
+
try {
|
|
1166
|
+
const stored = getChatStorage().getItem(getThreadKey(userId));
|
|
1167
|
+
if (!stored) return null;
|
|
1168
|
+
const thread = JSON.parse(stored);
|
|
1169
|
+
return thread.roomId === roomId && typeof thread.threadId === "string" ? thread.threadId : null;
|
|
1170
|
+
} catch {
|
|
1171
|
+
return null;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
function clearLastOpenedThread(userId) {
|
|
1175
|
+
try {
|
|
1176
|
+
getChatStorage().removeItem(getThreadKey(userId));
|
|
1177
|
+
} catch {
|
|
1178
|
+
console.error("Failed to clear last opened thread");
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1152
1181
|
function saveLastChatActivity(userId) {
|
|
1153
1182
|
try {
|
|
1154
1183
|
getChatStorage().setItem(getActivityKey(userId), String(Date.now()));
|
|
@@ -1333,6 +1362,19 @@ var createGroupSubscription = (groupId, name, owner, recipientIds) => ({
|
|
|
1333
1362
|
groupMentions: 0,
|
|
1334
1363
|
recipients: recipientIds
|
|
1335
1364
|
});
|
|
1365
|
+
var createChannelSubscription = (channelId, name, lastMessageId) => ({
|
|
1366
|
+
_id: channelId,
|
|
1367
|
+
rid: channelId,
|
|
1368
|
+
name,
|
|
1369
|
+
t: "c",
|
|
1370
|
+
u: { _id: "", username: "" },
|
|
1371
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1372
|
+
open: true,
|
|
1373
|
+
alert: false,
|
|
1374
|
+
userMentions: 0,
|
|
1375
|
+
groupMentions: 0,
|
|
1376
|
+
last_message_id: lastMessageId
|
|
1377
|
+
});
|
|
1336
1378
|
var createDMSubscription = (roomId, recipient) => {
|
|
1337
1379
|
const displayName = recipient?.username || DIRECT_MESSAGE_PLACEHOLDER;
|
|
1338
1380
|
return {
|
|
@@ -2963,6 +3005,15 @@ var messageStore = createStore()((set, get) => ({
|
|
|
2963
3005
|
}));
|
|
2964
3006
|
var resetMessageStore = () => messageStore.setState(getInitialState5());
|
|
2965
3007
|
|
|
3008
|
+
// src/utils/getTimeZone.ts
|
|
3009
|
+
var getTimeZone = () => {
|
|
3010
|
+
try {
|
|
3011
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
|
|
3012
|
+
} catch {
|
|
3013
|
+
return void 0;
|
|
3014
|
+
}
|
|
3015
|
+
};
|
|
3016
|
+
|
|
2966
3017
|
// src/utils/isDeepEqual.ts
|
|
2967
3018
|
function isDeepEqual(a, b) {
|
|
2968
3019
|
if (Object.is(a, b)) return true;
|
|
@@ -3275,9 +3326,10 @@ var authStore = createStore()((set, get) => ({
|
|
|
3275
3326
|
setChatError2(null);
|
|
3276
3327
|
set({ isConnected: false });
|
|
3277
3328
|
try {
|
|
3329
|
+
const timeZone = getTimeZone();
|
|
3278
3330
|
const revoltSession = await getChatHost().corvaApi.post(
|
|
3279
3331
|
"/v2/integration/revolt_chat_sessions",
|
|
3280
|
-
{}
|
|
3332
|
+
timeZone ? { time_zone: timeZone } : {}
|
|
3281
3333
|
);
|
|
3282
3334
|
if (!revoltSession?.revolt_session_token) {
|
|
3283
3335
|
throw new Error("No valid session token received from Corva backend");
|
|
@@ -5301,7 +5353,8 @@ function createEventRouter(userCache2, sessionToken, autumnUrl, handlers, getMem
|
|
|
5301
5353
|
channel_type: message.channel_type,
|
|
5302
5354
|
name: message.name,
|
|
5303
5355
|
recipients: message.recipients,
|
|
5304
|
-
owner: message.owner
|
|
5356
|
+
owner: message.owner,
|
|
5357
|
+
server: message.server
|
|
5305
5358
|
};
|
|
5306
5359
|
handlers.onRoomChange?.(message._id, payload);
|
|
5307
5360
|
break;
|
|
@@ -5321,6 +5374,9 @@ function createEventRouter(userCache2, sessionToken, autumnUrl, handlers, getMem
|
|
|
5321
5374
|
case "ServerMemberLeave":
|
|
5322
5375
|
if (typeof message.id === "string") handlers.onServerMembersChange?.(message.id);
|
|
5323
5376
|
break;
|
|
5377
|
+
case "ServerCreate":
|
|
5378
|
+
if (Array.isArray(message.channels)) handlers.onServerJoined?.(message.channels);
|
|
5379
|
+
break;
|
|
5324
5380
|
case "ServerMemberUpdate":
|
|
5325
5381
|
if (message.id?.server) handlers.onServerMembersChange?.(message.id.server);
|
|
5326
5382
|
break;
|
|
@@ -5553,6 +5609,21 @@ var createSocketEventHandlers = (config) => {
|
|
|
5553
5609
|
const getHidden = () => roomStore.getState();
|
|
5554
5610
|
const scheduleAck = (channelId, messageId) => sharedRefs.ackChannel?.(channelId, messageId);
|
|
5555
5611
|
const enqueueRoomTask = createRoomTaskQueue();
|
|
5612
|
+
const registerExternalServer = (channelId, serverId) => {
|
|
5613
|
+
if (!getExternalChannel(channelId)) {
|
|
5614
|
+
authStore.getState().setChannelServer(channelId, serverId, null);
|
|
5615
|
+
}
|
|
5616
|
+
};
|
|
5617
|
+
const isOnOtherServer = (serverId) => {
|
|
5618
|
+
const ownServerId = authStore.getState().serverId;
|
|
5619
|
+
return !!serverId && !!ownServerId && serverId !== ownServerId;
|
|
5620
|
+
};
|
|
5621
|
+
const isOtherServerChat = (ch) => ch.channel_type === CHANNEL_TYPES.TEXT_CHANNEL && !!ch.name && isOnOtherServer(ch.server) && !isGeneralRoom(ch);
|
|
5622
|
+
const getExternalServerChannels = (channels) => channels.filter(isOtherServerChat);
|
|
5623
|
+
const toMissingSubscriptions = (subs, channels) => {
|
|
5624
|
+
const listedRids = new Set(subs.map((sub) => sub.rid));
|
|
5625
|
+
return channels.filter((ch) => !listedRids.has(ch._id)).map((ch) => createChannelSubscription(ch._id, ch.name, ch.last_message_id));
|
|
5626
|
+
};
|
|
5556
5627
|
let hasAuthenticated = false;
|
|
5557
5628
|
return {
|
|
5558
5629
|
onConnected: () => {
|
|
@@ -5572,6 +5643,8 @@ var createSocketEventHandlers = (config) => {
|
|
|
5572
5643
|
},
|
|
5573
5644
|
onReady: (channels, channelUnreads) => {
|
|
5574
5645
|
if (!authStore.getState().user?._id) return;
|
|
5646
|
+
const externalChannels = getExternalServerChannels(channels);
|
|
5647
|
+
externalChannels.forEach((ch) => registerExternalServer(ch._id, ch.server));
|
|
5575
5648
|
const channelLastMsg = /* @__PURE__ */ new Map();
|
|
5576
5649
|
channels.forEach((ch) => {
|
|
5577
5650
|
if (ch.last_message_id) {
|
|
@@ -5579,8 +5652,12 @@ var createSocketEventHandlers = (config) => {
|
|
|
5579
5652
|
}
|
|
5580
5653
|
});
|
|
5581
5654
|
const applyUnreads = (ackedMap) => {
|
|
5582
|
-
const
|
|
5583
|
-
const
|
|
5655
|
+
const currentSubs = getRoom().subscriptions;
|
|
5656
|
+
const listedSubs = [
|
|
5657
|
+
...currentSubs,
|
|
5658
|
+
...toMissingSubscriptions(currentSubs, externalChannels)
|
|
5659
|
+
];
|
|
5660
|
+
const subs = listedSubs.map((sub) => {
|
|
5584
5661
|
const lastMsg = channelLastMsg.get(sub.rid) || sub.last_message_id;
|
|
5585
5662
|
const lastAcked = ackedMap.get(sub.rid);
|
|
5586
5663
|
const acked = getHydratedAckedId(
|
|
@@ -5620,6 +5697,17 @@ var createSocketEventHandlers = (config) => {
|
|
|
5620
5697
|
});
|
|
5621
5698
|
}
|
|
5622
5699
|
},
|
|
5700
|
+
onServerJoined: (channels) => {
|
|
5701
|
+
const externalChannels = getExternalServerChannels(channels);
|
|
5702
|
+
externalChannels.forEach((ch) => registerExternalServer(ch._id, ch.server));
|
|
5703
|
+
const currentSubs = getRoom().subscriptions;
|
|
5704
|
+
const joinedSubs = toMissingSubscriptions(currentSubs, externalChannels).map((sub) => ({
|
|
5705
|
+
...sub,
|
|
5706
|
+
last_acked_message_id: getHydratedAckedId(sub.rid, sub.last_message_id)
|
|
5707
|
+
}));
|
|
5708
|
+
if (!joinedSubs.length) return;
|
|
5709
|
+
roomStore.getState().setSubscriptions([...currentSubs, ...joinedSubs]);
|
|
5710
|
+
},
|
|
5623
5711
|
onChannelAck: (channelId, messageId) => {
|
|
5624
5712
|
const state = getRoom();
|
|
5625
5713
|
const updatedSubs = state.subscriptions.map(
|
|
@@ -5746,6 +5834,14 @@ var createSocketEventHandlers = (config) => {
|
|
|
5746
5834
|
try {
|
|
5747
5835
|
const payload = change;
|
|
5748
5836
|
if (payload?.event === "create" && (payload?.channel_type === CHANNEL_TYPES.GROUP || payload?.channel_type === CHANNEL_TYPES.TEXT_CHANNEL || payload?.channel_type === CHANNEL_TYPES.DIRECT_MESSAGE)) {
|
|
5837
|
+
const created = {
|
|
5838
|
+
_id: roomId,
|
|
5839
|
+
channel_type: payload.channel_type,
|
|
5840
|
+
name: payload.name,
|
|
5841
|
+
server: payload.server
|
|
5842
|
+
};
|
|
5843
|
+
if (isOtherServerChat(created)) registerExternalServer(roomId, created.server);
|
|
5844
|
+
else if (isOnOtherServer(payload.server)) return;
|
|
5749
5845
|
enqueueRoomTask(roomId, async () => {
|
|
5750
5846
|
const currentSubs = getRoom().subscriptions;
|
|
5751
5847
|
let subType = "c";
|
|
@@ -6197,6 +6293,6 @@ function ensureChatSession(corvaUser) {
|
|
|
6197
6293
|
return inFlight;
|
|
6198
6294
|
}
|
|
6199
6295
|
|
|
6200
|
-
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, compareByActivity, compareByName, compareByRecencyDesc, configureChat, configureChatStorage, createAckScheduler, 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, 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, searchMessages, searchRooms, searchUsers, selectCanGoBack, selectCanGoForward, setAllowedChatAssetTypes, settleOptimisticMessage, sharedRefs, sortChannels, sortDMs, sortMessagesByTime, sortUsersByStatus, stripPlatformMentions, toEditableMentionText, toReadableMentionText, toReadableText, tokenizeMentions, uiStore, updateMessageInList, uploadAndSend, validateChannelName, waitForNextPaint, wasRecentlyActive, withChannelPreferenceDefaults };
|
|
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 };
|
|
6201
6297
|
//# sourceMappingURL=index.js.map
|
|
6202
6298
|
//# sourceMappingURL=index.js.map
|