@sublay/core 7.1.1 → 7.3.0
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/cjs/hooks/auth/index.d.ts +2 -0
- package/dist/cjs/hooks/auth/index.js +5 -1
- package/dist/cjs/hooks/auth/index.js.map +1 -1
- package/dist/cjs/hooks/auth/useConfirmAccountDeletion.d.ts +14 -0
- package/dist/cjs/hooks/auth/useConfirmAccountDeletion.js +36 -0
- package/dist/cjs/hooks/auth/useConfirmAccountDeletion.js.map +1 -0
- package/dist/cjs/hooks/auth/useRequestAccountDeletion.d.ts +13 -0
- package/dist/cjs/hooks/auth/useRequestAccountDeletion.js +30 -0
- package/dist/cjs/hooks/auth/useRequestAccountDeletion.js.map +1 -0
- package/dist/cjs/hooks/chat/conversations/useConversations.d.ts +1 -0
- package/dist/cjs/hooks/chat/conversations/useConversations.js.map +1 -1
- package/dist/cjs/hooks/chat/index.d.ts +2 -2
- package/dist/cjs/hooks/chat/index.js +4 -1
- package/dist/cjs/hooks/chat/index.js.map +1 -1
- package/dist/cjs/hooks/chat/messages/index.d.ts +6 -0
- package/dist/cjs/hooks/chat/messages/index.js +10 -1
- package/dist/cjs/hooks/chat/messages/index.js.map +1 -1
- package/dist/cjs/hooks/chat/messages/useChatMessages.d.ts +10 -14
- package/dist/cjs/hooks/chat/messages/useChatMessages.js +7 -136
- package/dist/cjs/hooks/chat/messages/useChatMessages.js.map +1 -1
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessages.d.ts +45 -0
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessages.js +43 -0
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessages.js.map +1 -0
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessagesWrapper.d.ts +35 -0
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessagesWrapper.js +100 -0
- package/dist/cjs/hooks/chat/messages/useFetchManyChatMessagesWrapper.js.map +1 -0
- package/dist/cjs/hooks/chat/messages/useLiveChatMessages.d.ts +26 -0
- package/dist/cjs/hooks/chat/messages/useLiveChatMessages.js +149 -0
- package/dist/cjs/hooks/chat/messages/useLiveChatMessages.js.map +1 -0
- package/dist/cjs/hooks/chat/messages/useMessageThread.js +2 -2
- package/dist/cjs/hooks/chat/messages/useMessageThread.js.map +1 -1
- package/dist/cjs/hooks/chat/useConversationData.js +2 -2
- package/dist/cjs/hooks/chat/useConversationData.js.map +1 -1
- package/dist/cjs/hooks/spaces/index.d.ts +2 -0
- package/dist/cjs/hooks/spaces/index.js +3 -1
- package/dist/cjs/hooks/spaces/index.js.map +1 -1
- package/dist/cjs/hooks/spaces/useFetchMutualSpaces.d.ts +11 -0
- package/dist/cjs/hooks/spaces/useFetchMutualSpaces.js +28 -0
- package/dist/cjs/hooks/spaces/useFetchMutualSpaces.js.map +1 -0
- package/dist/cjs/hooks/tables/index.d.ts +2 -0
- package/dist/cjs/hooks/tables/index.js +10 -0
- package/dist/cjs/hooks/tables/index.js.map +1 -0
- package/dist/cjs/hooks/tables/useTable.d.ts +37 -0
- package/dist/cjs/hooks/tables/useTable.js +115 -0
- package/dist/cjs/hooks/tables/useTable.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -4
- package/dist/cjs/index.js +14 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/models/Conversation.d.ts +2 -0
- package/dist/cjs/interfaces/models/Table.d.ts +29 -0
- package/dist/cjs/interfaces/models/Table.js +8 -0
- package/dist/cjs/interfaces/models/Table.js.map +1 -0
- package/dist/cjs/store/api/appNotificationsApi.d.ts +181 -181
- package/dist/cjs/store/api/baseApi.d.ts +2 -2
- package/dist/cjs/store/api/baseApi.js +1 -0
- package/dist/cjs/store/api/baseApi.js.map +1 -1
- package/dist/cjs/store/api/collectionsApi.d.ts +319 -319
- package/dist/cjs/store/api/entityListsApi.d.ts +107 -107
- package/dist/cjs/store/api/index.d.ts +1 -0
- package/dist/cjs/store/api/index.js +2 -0
- package/dist/cjs/store/api/index.js.map +1 -1
- package/dist/cjs/store/api/spacesApi.d.ts +1021 -1021
- package/dist/cjs/store/api/tablesApi.d.ts +2554 -0
- package/dist/cjs/store/api/tablesApi.js +84 -0
- package/dist/cjs/store/api/tablesApi.js.map +1 -0
- package/dist/cjs/store/api/userApi.d.ts +3 -3
- package/dist/cjs/store/hooks.d.ts +2 -1
- package/dist/cjs/store/index.d.ts +4 -2
- package/dist/cjs/store/rootReducer.d.ts +5 -2
- package/dist/cjs/store/slices/authThunks.d.ts +4 -0
- package/dist/cjs/store/slices/authThunks.js +52 -1
- package/dist/cjs/store/slices/authThunks.js.map +1 -1
- package/dist/cjs/store/slices/tablesSlice.d.ts +113 -0
- package/dist/cjs/store/slices/tablesSlice.js +40 -0
- package/dist/cjs/store/slices/tablesSlice.js.map +1 -0
- package/dist/cjs/store/sublayReducers.d.ts +2 -0
- package/dist/cjs/store/sublayReducers.js +2 -0
- package/dist/cjs/store/sublayReducers.js.map +1 -1
- package/dist/esm/hooks/auth/index.d.ts +2 -0
- package/dist/esm/hooks/auth/index.js +2 -0
- package/dist/esm/hooks/auth/index.js.map +1 -1
- package/dist/esm/hooks/auth/useConfirmAccountDeletion.d.ts +14 -0
- package/dist/esm/hooks/auth/useConfirmAccountDeletion.js +31 -0
- package/dist/esm/hooks/auth/useConfirmAccountDeletion.js.map +1 -0
- package/dist/esm/hooks/auth/useRequestAccountDeletion.d.ts +13 -0
- package/dist/esm/hooks/auth/useRequestAccountDeletion.js +25 -0
- package/dist/esm/hooks/auth/useRequestAccountDeletion.js.map +1 -0
- package/dist/esm/hooks/chat/conversations/useConversations.d.ts +1 -0
- package/dist/esm/hooks/chat/conversations/useConversations.js.map +1 -1
- package/dist/esm/hooks/chat/index.d.ts +2 -2
- package/dist/esm/hooks/chat/index.js +1 -1
- package/dist/esm/hooks/chat/index.js.map +1 -1
- package/dist/esm/hooks/chat/messages/index.d.ts +6 -0
- package/dist/esm/hooks/chat/messages/index.js +6 -0
- package/dist/esm/hooks/chat/messages/index.js.map +1 -1
- package/dist/esm/hooks/chat/messages/useChatMessages.d.ts +10 -14
- package/dist/esm/hooks/chat/messages/useChatMessages.js +7 -136
- package/dist/esm/hooks/chat/messages/useChatMessages.js.map +1 -1
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessages.d.ts +45 -0
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessages.js +38 -0
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessages.js.map +1 -0
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessagesWrapper.d.ts +35 -0
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessagesWrapper.js +95 -0
- package/dist/esm/hooks/chat/messages/useFetchManyChatMessagesWrapper.js.map +1 -0
- package/dist/esm/hooks/chat/messages/useLiveChatMessages.d.ts +26 -0
- package/dist/esm/hooks/chat/messages/useLiveChatMessages.js +144 -0
- package/dist/esm/hooks/chat/messages/useLiveChatMessages.js.map +1 -0
- package/dist/esm/hooks/chat/messages/useMessageThread.js +2 -2
- package/dist/esm/hooks/chat/messages/useMessageThread.js.map +1 -1
- package/dist/esm/hooks/chat/useConversationData.js +2 -2
- package/dist/esm/hooks/chat/useConversationData.js.map +1 -1
- package/dist/esm/hooks/spaces/index.d.ts +2 -0
- package/dist/esm/hooks/spaces/index.js +1 -0
- package/dist/esm/hooks/spaces/index.js.map +1 -1
- package/dist/esm/hooks/spaces/useFetchMutualSpaces.d.ts +11 -0
- package/dist/esm/hooks/spaces/useFetchMutualSpaces.js +23 -0
- package/dist/esm/hooks/spaces/useFetchMutualSpaces.js.map +1 -0
- package/dist/esm/hooks/tables/index.d.ts +2 -0
- package/dist/esm/hooks/tables/index.js +2 -0
- package/dist/esm/hooks/tables/index.js.map +1 -0
- package/dist/esm/hooks/tables/useTable.d.ts +37 -0
- package/dist/esm/hooks/tables/useTable.js +109 -0
- package/dist/esm/hooks/tables/useTable.js.map +1 -0
- package/dist/esm/index.d.ts +6 -4
- package/dist/esm/index.js +5 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/models/Conversation.d.ts +2 -0
- package/dist/esm/interfaces/models/Table.d.ts +29 -0
- package/dist/esm/interfaces/models/Table.js +7 -0
- package/dist/esm/interfaces/models/Table.js.map +1 -0
- package/dist/esm/store/api/appNotificationsApi.d.ts +181 -181
- package/dist/esm/store/api/baseApi.d.ts +2 -2
- package/dist/esm/store/api/baseApi.js +1 -0
- package/dist/esm/store/api/baseApi.js.map +1 -1
- package/dist/esm/store/api/collectionsApi.d.ts +319 -319
- package/dist/esm/store/api/entityListsApi.d.ts +107 -107
- package/dist/esm/store/api/index.d.ts +1 -0
- package/dist/esm/store/api/index.js +2 -0
- package/dist/esm/store/api/index.js.map +1 -1
- package/dist/esm/store/api/spacesApi.d.ts +1021 -1021
- package/dist/esm/store/api/tablesApi.d.ts +2554 -0
- package/dist/esm/store/api/tablesApi.js +80 -0
- package/dist/esm/store/api/tablesApi.js.map +1 -0
- package/dist/esm/store/api/userApi.d.ts +3 -3
- package/dist/esm/store/hooks.d.ts +2 -1
- package/dist/esm/store/index.d.ts +4 -2
- package/dist/esm/store/rootReducer.d.ts +5 -2
- package/dist/esm/store/slices/authThunks.d.ts +4 -0
- package/dist/esm/store/slices/authThunks.js +51 -0
- package/dist/esm/store/slices/authThunks.js.map +1 -1
- package/dist/esm/store/slices/tablesSlice.d.ts +113 -0
- package/dist/esm/store/slices/tablesSlice.js +36 -0
- package/dist/esm/store/slices/tablesSlice.js.map +1 -0
- package/dist/esm/store/sublayReducers.d.ts +2 -0
- package/dist/esm/store/sublayReducers.js +2 -0
- package/dist/esm/store/sublayReducers.js.map +1 -1
- package/package.json +10 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import axios from "../../config/axios";
|
|
3
|
+
import useProject from "../projects/useProject";
|
|
4
|
+
/**
|
|
5
|
+
* Step 1 of self-service account deletion. Emails the signed-in user a one-time
|
|
6
|
+
* confirmation code. Pass that code to `useConfirmAccountDeletion` to
|
|
7
|
+
* permanently delete the account.
|
|
8
|
+
*
|
|
9
|
+
* Requires the account to have an email on file — accounts without one (e.g.
|
|
10
|
+
* anonymous or foreign-id users) must be deleted server-side with a service key
|
|
11
|
+
* via the node SDK.
|
|
12
|
+
*/
|
|
13
|
+
function useRequestAccountDeletion() {
|
|
14
|
+
const { projectId } = useProject();
|
|
15
|
+
const requestAccountDeletion = useCallback(async () => {
|
|
16
|
+
if (!projectId) {
|
|
17
|
+
throw new Error("No projectId available.");
|
|
18
|
+
}
|
|
19
|
+
const response = await axios.post(`/${projectId}/auth/request-account-deletion`, {});
|
|
20
|
+
return response.data;
|
|
21
|
+
}, [projectId]);
|
|
22
|
+
return requestAccountDeletion;
|
|
23
|
+
}
|
|
24
|
+
export default useRequestAccountDeletion;
|
|
25
|
+
//# sourceMappingURL=useRequestAccountDeletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRequestAccountDeletion.js","sourceRoot":"","sources":["../../../../src/hooks/auth/useRequestAccountDeletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD;;;;;;;;GAQG;AACH,SAAS,yBAAyB;IAChC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,CAAC;IAEnC,MAAM,sBAAsB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACpD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAC/B,IAAI,SAAS,gCAAgC,EAC7C,EAAE,CACH,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -11,6 +11,7 @@ export interface UseConversationsValues {
|
|
|
11
11
|
createGroup: (params: {
|
|
12
12
|
name?: string;
|
|
13
13
|
metadata?: Record<string, unknown>;
|
|
14
|
+
memberIds?: string[];
|
|
14
15
|
}) => Promise<ConversationPreview>;
|
|
15
16
|
}
|
|
16
17
|
declare function useConversations({ types, }?: UseConversationsProps): UseConversationsValues;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversations.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/conversations/useConversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"useConversations.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/conversations/useConversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,eAAe,MAAM,iCAAiC,CAAC;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AAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,WAAW,GAAG,WAAW,CAC7B,KAAK,EAAE,MAIN,EAAgC,EAAE;QACjC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAC/B,IAAI,SAAS,qBAAqB,EAClC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAC7B,CAAC;QAEF,MAAM,YAAY,GAAG,QAAQ,CAAC,IAA2B,CAAC;QAE1D,wDAAwD;QACxD,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;QACzC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE1D,OAAO,YAAY,CAAC;IACtB,CAAC,EACD,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAC7B,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAC7E,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { useConversations, useConversation, useFetchConversation, useUpdateConversation, useDeleteConversation, useCreateDirectConversation, useFetchSpaceConversation, useConversationMembers, } from "./conversations";
|
|
2
2
|
export type { UseConversationsProps, UseConversationsValues, UseConversationProps, UseConversationValues, UpdateConversationParams, FetchConversationProps, DeleteConversationProps, CreateDirectConversationProps, UseFetchSpaceConversationProps, UseFetchSpaceConversationValues, UseConversationMembersProps, UseConversationMembersValues, } from "./conversations";
|
|
3
|
-
export { useChatMessages, useSendMessage, useEditMessage, useDeleteMessage, useToggleReaction, useMessageThread, } from "./messages";
|
|
4
|
-
export type { UseChatMessagesProps, UseChatMessagesValues, SendMessageParams, UseSendMessageProps, EditMessageParams, DeleteMessageParams, ToggleReactionParams, ToggleReactionResult, UseMessageThreadProps, UseMessageThreadValues, } from "./messages";
|
|
3
|
+
export { useLiveChatMessages, useChatMessages, useFetchManyChatMessages, useFetchManyChatMessagesWrapper, useSendMessage, useEditMessage, useDeleteMessage, useToggleReaction, useMessageThread, } from "./messages";
|
|
4
|
+
export type { UseLiveChatMessagesProps, UseLiveChatMessagesValues, UseChatMessagesProps, UseChatMessagesValues, FetchManyChatMessagesProps, FetchManyChatMessagesResponse, UseFetchManyChatMessagesWrapperProps, UseFetchManyChatMessagesWrapperValues, MessageFilters, SendMessageParams, UseSendMessageProps, EditMessageParams, DeleteMessageParams, ToggleReactionParams, ToggleReactionResult, UseMessageThreadProps, UseMessageThreadValues, } from "./messages";
|
|
5
5
|
export { default as useTotalUnreadCount } from "./useTotalUnreadCount";
|
|
6
6
|
export { default as useUnreadConversationCount } from "./useUnreadConversationCount";
|
|
7
7
|
export { default as useMarkConversationAsRead } from "./useMarkConversationAsRead";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Conversation hooks
|
|
2
2
|
export { useConversations, useConversation, useFetchConversation, useUpdateConversation, useDeleteConversation, useCreateDirectConversation, useFetchSpaceConversation, useConversationMembers, } from "./conversations";
|
|
3
3
|
// Message hooks
|
|
4
|
-
export { useChatMessages, useSendMessage, useEditMessage, useDeleteMessage, useToggleReaction, useMessageThread, } from "./messages";
|
|
4
|
+
export { useLiveChatMessages, useChatMessages, useFetchManyChatMessages, useFetchManyChatMessagesWrapper, useSendMessage, useEditMessage, useDeleteMessage, useToggleReaction, useMessageThread, } from "./messages";
|
|
5
5
|
// Utility hooks
|
|
6
6
|
export { default as useTotalUnreadCount } from "./useTotalUnreadCount";
|
|
7
7
|
export { default as useUnreadConversationCount } from "./useUnreadConversationCount";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/chat/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAgBzB,gBAAgB;AAChB,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/chat/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAgBzB,gBAAgB;AAChB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,+BAA+B,EAC/B,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAqBpB,gBAAgB;AAChB,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAEnF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAKrE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG3D,mBAAmB;AACnB,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
export { default as useLiveChatMessages } from "./useLiveChatMessages";
|
|
2
|
+
export type { UseLiveChatMessagesProps, UseLiveChatMessagesValues, } from "./useLiveChatMessages";
|
|
1
3
|
export { default as useChatMessages } from "./useChatMessages";
|
|
2
4
|
export type { UseChatMessagesProps, UseChatMessagesValues } from "./useChatMessages";
|
|
5
|
+
export { default as useFetchManyChatMessages } from "./useFetchManyChatMessages";
|
|
6
|
+
export type { FetchManyChatMessagesProps, FetchManyChatMessagesResponse, MessageFilters, } from "./useFetchManyChatMessages";
|
|
7
|
+
export { default as useFetchManyChatMessagesWrapper } from "./useFetchManyChatMessagesWrapper";
|
|
8
|
+
export type { UseFetchManyChatMessagesWrapperProps, UseFetchManyChatMessagesWrapperValues, } from "./useFetchManyChatMessagesWrapper";
|
|
3
9
|
export { default as useSendMessage } from "./useSendMessage";
|
|
4
10
|
export type { SendMessageParams, UseSendMessageProps } from "./useSendMessage";
|
|
5
11
|
export { default as useEditMessage } from "./useEditMessage";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
// Live, store-backed conversation view
|
|
2
|
+
export { default as useLiveChatMessages } from "./useLiveChatMessages";
|
|
3
|
+
// Deprecated alias — use useLiveChatMessages
|
|
1
4
|
export { default as useChatMessages } from "./useChatMessages";
|
|
5
|
+
// Stateless / query message fetchers
|
|
6
|
+
export { default as useFetchManyChatMessages } from "./useFetchManyChatMessages";
|
|
7
|
+
export { default as useFetchManyChatMessagesWrapper } from "./useFetchManyChatMessagesWrapper";
|
|
2
8
|
export { default as useSendMessage } from "./useSendMessage";
|
|
3
9
|
export { default as useEditMessage } from "./useEditMessage";
|
|
4
10
|
export { default as useDeleteMessage } from "./useDeleteMessage";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMnE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAMvE,6CAA6C;AAC7C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG/D,qCAAqC;AACrC,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAOjF,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAM/F,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMnE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
hasMore: boolean;
|
|
12
|
-
loadOlder: () => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
declare function useChatMessages({ conversationId, parentId, limit, includeFiles, }: UseChatMessagesProps): UseChatMessagesValues;
|
|
1
|
+
import { UseLiveChatMessagesProps, UseLiveChatMessagesValues } from "./useLiveChatMessages";
|
|
2
|
+
/** @deprecated Renamed to `UseLiveChatMessagesProps`. */
|
|
3
|
+
export type UseChatMessagesProps = UseLiveChatMessagesProps;
|
|
4
|
+
/** @deprecated Renamed to `UseLiveChatMessagesValues`. */
|
|
5
|
+
export type UseChatMessagesValues = UseLiveChatMessagesValues;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `useLiveChatMessages` instead. This alias forwards to it and
|
|
8
|
+
* will be removed in a future major version.
|
|
9
|
+
*/
|
|
10
|
+
declare function useChatMessages(props: UseChatMessagesProps): UseChatMessagesValues;
|
|
15
11
|
export default useChatMessages;
|
|
@@ -1,139 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const dispatch = useSublayDispatch();
|
|
9
|
-
const { projectId } = useProject();
|
|
10
|
-
const axios = useAxiosPrivate();
|
|
11
|
-
const isThread = Boolean(parentId);
|
|
12
|
-
// Read from the correct Redux bucket
|
|
13
|
-
const mainMessages = useSublaySelector(selectMessages(conversationId));
|
|
14
|
-
const mainLoading = useSublaySelector(selectMessagesLoading(conversationId));
|
|
15
|
-
const mainHasMore = useSublaySelector(selectMessagesHasMore(conversationId));
|
|
16
|
-
const threadMessages = useSublaySelector(selectThreadReplies(parentId ?? ""));
|
|
17
|
-
const threadLoading = useSublaySelector(selectThreadLoading(parentId ?? ""));
|
|
18
|
-
const threadHasMore = useSublaySelector(selectThreadHasMore(parentId ?? ""));
|
|
19
|
-
const messages = isThread ? threadMessages : mainMessages;
|
|
20
|
-
const loading = isThread ? threadLoading : mainLoading;
|
|
21
|
-
const hasMore = isThread ? threadHasMore : mainHasMore;
|
|
22
|
-
// Keep fresh refs to message arrays so loadOlder can read cursors without
|
|
23
|
-
// closing over stale state
|
|
24
|
-
const mainMessagesRef = useRef(mainMessages);
|
|
25
|
-
mainMessagesRef.current = mainMessages;
|
|
26
|
-
const threadMessagesRef = useRef(threadMessages);
|
|
27
|
-
threadMessagesRef.current = threadMessages;
|
|
28
|
-
// Fetch a page of messages.
|
|
29
|
-
// `before` is an ISO 8601 timestamp — the server queries messages created
|
|
30
|
-
// before this point in time (not a UUID cursor).
|
|
31
|
-
const fetchPage = useCallback(async (before) => {
|
|
32
|
-
if (!projectId || !conversationId)
|
|
33
|
-
return;
|
|
34
|
-
const params = {
|
|
35
|
-
limit,
|
|
36
|
-
sort: isThread ? "asc" : "desc",
|
|
37
|
-
};
|
|
38
|
-
if (parentId)
|
|
39
|
-
params.parentId = parentId;
|
|
40
|
-
if (before)
|
|
41
|
-
params.before = before;
|
|
42
|
-
if (includeFiles)
|
|
43
|
-
params.include = "files";
|
|
44
|
-
try {
|
|
45
|
-
const response = await axios.get(`/${projectId}/chat/conversations/${conversationId}/messages`, { params });
|
|
46
|
-
const { messages: items, hasMore: more } = response.data;
|
|
47
|
-
if (isThread) {
|
|
48
|
-
// Thread replies come back ASC — dispatch as-is
|
|
49
|
-
dispatch(setThreadReplies({
|
|
50
|
-
parentMessageId: parentId,
|
|
51
|
-
messages: items,
|
|
52
|
-
hasMore: more,
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// Main stream comes back DESC (newest first for cursor efficiency).
|
|
57
|
-
// Redux stores messages ASC — reverse before dispatching.
|
|
58
|
-
const ascending = [...items].reverse();
|
|
59
|
-
ascending.forEach((msg) => dispatch(upsertMessage(msg)));
|
|
60
|
-
dispatch(setMessagesHasMore({ conversationId, hasMore: more }));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
handleError(err, "Failed to load messages");
|
|
65
|
-
}
|
|
66
|
-
}, [projectId, conversationId, parentId, isThread, limit, includeFiles, axios, dispatch]);
|
|
67
|
-
// Initial fetch on mount
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!projectId || !conversationId)
|
|
70
|
-
return;
|
|
71
|
-
const initialFetch = async () => {
|
|
72
|
-
if (isThread) {
|
|
73
|
-
dispatch(setThreadLoading({ parentMessageId: parentId, loading: true }));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
dispatch(setMessagesLoading({ conversationId, loading: true }));
|
|
77
|
-
}
|
|
78
|
-
await fetchPage(null);
|
|
79
|
-
if (isThread) {
|
|
80
|
-
dispatch(setThreadLoading({ parentMessageId: parentId, loading: false }));
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
dispatch(setMessagesLoading({ conversationId, loading: false }));
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
initialFetch();
|
|
87
|
-
// Only re-run when the conversation/thread identity changes
|
|
88
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
-
}, [projectId, conversationId, parentId]);
|
|
90
|
-
// Load more messages:
|
|
91
|
-
// - Main stream: fetch older messages using `before` cursor (oldest loaded createdAt)
|
|
92
|
-
// - Thread: fetch newer replies using `after` cursor (newest loaded createdAt), append
|
|
93
|
-
const loadOlder = useCallback(async () => {
|
|
94
|
-
if (loading || !hasMore)
|
|
95
|
-
return;
|
|
96
|
-
if (isThread) {
|
|
97
|
-
const currentItems = threadMessagesRef.current;
|
|
98
|
-
const newest = currentItems[currentItems.length - 1];
|
|
99
|
-
if (!newest || !parentId || !projectId || !conversationId)
|
|
100
|
-
return;
|
|
101
|
-
const after = new Date(newest.createdAt).toISOString();
|
|
102
|
-
dispatch(setThreadLoading({ parentMessageId: parentId, loading: true }));
|
|
103
|
-
try {
|
|
104
|
-
const response = await axios.get(`/${projectId}/chat/conversations/${conversationId}/messages`, {
|
|
105
|
-
params: {
|
|
106
|
-
parentId,
|
|
107
|
-
after,
|
|
108
|
-
limit,
|
|
109
|
-
sort: "asc",
|
|
110
|
-
...(includeFiles ? { include: "files" } : {}),
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
const { messages: newItems, hasMore: more } = response.data;
|
|
114
|
-
dispatch(setThreadReplies({
|
|
115
|
-
parentMessageId: parentId,
|
|
116
|
-
messages: [...currentItems, ...newItems],
|
|
117
|
-
hasMore: more,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
catch (err) {
|
|
121
|
-
handleError(err, "Failed to load more thread replies");
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
dispatch(setThreadLoading({ parentMessageId: parentId, loading: false }));
|
|
125
|
-
}
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const oldest = mainMessagesRef.current[0];
|
|
129
|
-
if (!oldest)
|
|
130
|
-
return;
|
|
131
|
-
const before = new Date(oldest.createdAt).toISOString();
|
|
132
|
-
dispatch(setMessagesLoading({ conversationId, loading: true }));
|
|
133
|
-
await fetchPage(before);
|
|
134
|
-
dispatch(setMessagesLoading({ conversationId, loading: false }));
|
|
135
|
-
}, [loading, hasMore, isThread, parentId, projectId, conversationId, limit, includeFiles, axios, dispatch, fetchPage]);
|
|
136
|
-
return { messages, loading, hasMore, loadOlder };
|
|
1
|
+
import useLiveChatMessages from "./useLiveChatMessages";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `useLiveChatMessages` instead. This alias forwards to it and
|
|
4
|
+
* will be removed in a future major version.
|
|
5
|
+
*/
|
|
6
|
+
function useChatMessages(props) {
|
|
7
|
+
return useLiveChatMessages(props);
|
|
137
8
|
}
|
|
138
9
|
export default useChatMessages;
|
|
139
10
|
//# sourceMappingURL=useChatMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/useChatMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/useChatMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,mBAGN,MAAM,uBAAuB,CAAC;AAO/B;;;GAGG;AACH,SAAS,eAAe,CACtB,KAA2B;IAE3B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ChatMessage } from "../../../interfaces/models/ChatMessage";
|
|
2
|
+
export interface MessageFilters {
|
|
3
|
+
/**
|
|
4
|
+
* Filter to messages that have thread replies (not quotings). `true` returns
|
|
5
|
+
* only messages with at least one thread reply; `false` returns only messages
|
|
6
|
+
* with none. Omit for no reply-count filtering.
|
|
7
|
+
*/
|
|
8
|
+
hasReplies?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface FetchManyChatMessagesProps {
|
|
11
|
+
conversationId: string;
|
|
12
|
+
/** Restrict to replies of this message (thread view). */
|
|
13
|
+
parentId?: string | null;
|
|
14
|
+
/** Keyset cursor (ISO timestamp): messages created before this. Mutually exclusive with `after`. */
|
|
15
|
+
before?: string | null;
|
|
16
|
+
/** Keyset cursor (ISO timestamp): messages created after this. Mutually exclusive with `before`. */
|
|
17
|
+
after?: string | null;
|
|
18
|
+
/** Page size (1–100, defaults to 50 server-side). */
|
|
19
|
+
limit?: number;
|
|
20
|
+
sort?: "asc" | "desc";
|
|
21
|
+
/** When `true`, the server populates the `files` field on each message. */
|
|
22
|
+
includeFiles?: boolean;
|
|
23
|
+
filters?: MessageFilters;
|
|
24
|
+
}
|
|
25
|
+
export interface FetchManyChatMessagesResponse {
|
|
26
|
+
messages: ChatMessage[];
|
|
27
|
+
hasMore: boolean;
|
|
28
|
+
oldestCreatedAt: string | null;
|
|
29
|
+
newestCreatedAt: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Present only when a filter combination can't return results — e.g.
|
|
32
|
+
* `hasReplies: true` together with `parentId` (thread replies are one level
|
|
33
|
+
* deep and never have their own replies).
|
|
34
|
+
*/
|
|
35
|
+
notice?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Low-level, stateless fetcher for conversation messages. Returns a promise of
|
|
39
|
+
* a single page — no Redux, no socket subscription. This is the single owner of
|
|
40
|
+
* the messages endpoint URL and its query params; both the live store hook
|
|
41
|
+
* (`useLiveChatMessages`) and the query hook (`useFetchManyChatMessagesWrapper`)
|
|
42
|
+
* build on it.
|
|
43
|
+
*/
|
|
44
|
+
declare function useFetchManyChatMessages(): (props: FetchManyChatMessagesProps) => Promise<FetchManyChatMessagesResponse>;
|
|
45
|
+
export default useFetchManyChatMessages;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import useAxiosPrivate from "../../../config/useAxiosPrivate";
|
|
3
|
+
import useProject from "../../projects/useProject";
|
|
4
|
+
/**
|
|
5
|
+
* Low-level, stateless fetcher for conversation messages. Returns a promise of
|
|
6
|
+
* a single page — no Redux, no socket subscription. This is the single owner of
|
|
7
|
+
* the messages endpoint URL and its query params; both the live store hook
|
|
8
|
+
* (`useLiveChatMessages`) and the query hook (`useFetchManyChatMessagesWrapper`)
|
|
9
|
+
* build on it.
|
|
10
|
+
*/
|
|
11
|
+
function useFetchManyChatMessages() {
|
|
12
|
+
const { projectId } = useProject();
|
|
13
|
+
const axios = useAxiosPrivate();
|
|
14
|
+
return useCallback(async (props) => {
|
|
15
|
+
const { conversationId, parentId, before, after, limit = 50, sort, includeFiles, filters, } = props;
|
|
16
|
+
if (!projectId)
|
|
17
|
+
throw new Error("No project specified");
|
|
18
|
+
if (!conversationId)
|
|
19
|
+
throw new Error("No conversation specified");
|
|
20
|
+
const params = { limit };
|
|
21
|
+
if (sort)
|
|
22
|
+
params.sort = sort;
|
|
23
|
+
if (parentId)
|
|
24
|
+
params.parentId = parentId;
|
|
25
|
+
if (before)
|
|
26
|
+
params.before = before;
|
|
27
|
+
if (after)
|
|
28
|
+
params.after = after;
|
|
29
|
+
if (includeFiles)
|
|
30
|
+
params.include = "files";
|
|
31
|
+
if (filters)
|
|
32
|
+
params.filters = filters;
|
|
33
|
+
const response = await axios.get(`/${projectId}/chat/conversations/${conversationId}/messages`, { params });
|
|
34
|
+
return response.data;
|
|
35
|
+
}, [projectId, axios]);
|
|
36
|
+
}
|
|
37
|
+
export default useFetchManyChatMessages;
|
|
38
|
+
//# sourceMappingURL=useFetchManyChatMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchManyChatMessages.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/useFetchManyChatMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,UAAU,MAAM,2BAA2B,CAAC;AAwCnD;;;;;;GAMG;AACH,SAAS,wBAAwB;IAG/B,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAEhC,OAAO,WAAW,CAChB,KAAK,EAAE,KAAiC,EAAE,EAAE;QAC1C,MAAM,EACJ,cAAc,EACd,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,GAAG,EAAE,EACV,IAAI,EACJ,YAAY,EACZ,OAAO,GACR,GAAG,KAAK,CAAC;QAEV,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACxD,IAAI,CAAC,cAAc;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAElE,MAAM,MAAM,GAAwB,EAAE,KAAK,EAAE,CAAC;QAC9C,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QAC7B,IAAI,QAAQ;YAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzC,IAAI,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACnC,IAAI,KAAK;YAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAChC,IAAI,YAAY;YAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3C,IAAI,OAAO;YAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAC9B,IAAI,SAAS,uBAAuB,cAAc,WAAW,EAC7D,EAAE,MAAM,EAAE,CACX,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC,EACD,CAAC,SAAS,EAAE,KAAK,CAAC,CACnB,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChatMessage } from "../../../interfaces/models/ChatMessage";
|
|
2
|
+
import { MessageFilters } from "./useFetchManyChatMessages";
|
|
3
|
+
export interface UseFetchManyChatMessagesWrapperProps {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
/** Restrict to replies of this message (thread view). */
|
|
6
|
+
parentId?: string | null;
|
|
7
|
+
/** Page size. Defaults to `50`. */
|
|
8
|
+
limit?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Sort direction by creation time. Defaults to `"desc"` (newest first);
|
|
11
|
+
* `loadMore` then fetches older messages. With `"asc"`, `loadMore` fetches
|
|
12
|
+
* newer messages.
|
|
13
|
+
*/
|
|
14
|
+
sort?: "asc" | "desc";
|
|
15
|
+
/** When `true`, the server populates the `files` field on each message. */
|
|
16
|
+
includeFiles?: boolean;
|
|
17
|
+
filters?: MessageFilters;
|
|
18
|
+
}
|
|
19
|
+
export interface UseFetchManyChatMessagesWrapperValues {
|
|
20
|
+
messages: ChatMessage[];
|
|
21
|
+
loading: boolean;
|
|
22
|
+
hasMore: boolean;
|
|
23
|
+
loadMore: () => void;
|
|
24
|
+
/** Re-fetch the first page from scratch (e.g. to pick up new matches). */
|
|
25
|
+
refetch: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Batteries-included, self-contained list of conversation messages with
|
|
29
|
+
* cursor pagination — keeps results in local component state, NOT Redux, and
|
|
30
|
+
* does NOT subscribe to socket updates. Use this for read-only / filtered
|
|
31
|
+
* queries (e.g. "messages that have replies"). For the live canonical
|
|
32
|
+
* conversation stream, use `useLiveChatMessages` instead.
|
|
33
|
+
*/
|
|
34
|
+
declare function useFetchManyChatMessagesWrapper(props: UseFetchManyChatMessagesWrapperProps): UseFetchManyChatMessagesWrapperValues;
|
|
35
|
+
export default useFetchManyChatMessagesWrapper;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { handleError } from "../../../utils/handleError";
|
|
3
|
+
import useFetchManyChatMessages from "./useFetchManyChatMessages";
|
|
4
|
+
/**
|
|
5
|
+
* Batteries-included, self-contained list of conversation messages with
|
|
6
|
+
* cursor pagination — keeps results in local component state, NOT Redux, and
|
|
7
|
+
* does NOT subscribe to socket updates. Use this for read-only / filtered
|
|
8
|
+
* queries (e.g. "messages that have replies"). For the live canonical
|
|
9
|
+
* conversation stream, use `useLiveChatMessages` instead.
|
|
10
|
+
*/
|
|
11
|
+
function useFetchManyChatMessagesWrapper(props) {
|
|
12
|
+
const { conversationId, parentId, limit = 50, sort = "desc", includeFiles, filters, } = props;
|
|
13
|
+
const fetchMany = useFetchManyChatMessages();
|
|
14
|
+
const [messages, setMessages] = useState([]);
|
|
15
|
+
const [loading, setLoading] = useState(true);
|
|
16
|
+
const [hasMore, setHasMore] = useState(true);
|
|
17
|
+
// Cursor for the next page, in the direction of travel: the oldest loaded
|
|
18
|
+
// timestamp for "desc", the newest for "asc".
|
|
19
|
+
const cursorRef = useRef(null);
|
|
20
|
+
const loadingRef = useRef(false);
|
|
21
|
+
const hasMoreRef = useRef(true);
|
|
22
|
+
// Stable primitive for dependency arrays — `filters` is a fresh object each
|
|
23
|
+
// render unless the caller memoizes it.
|
|
24
|
+
const filtersKey = JSON.stringify(filters ?? {});
|
|
25
|
+
const advanceCursor = useCallback((res) => {
|
|
26
|
+
cursorRef.current = sort === "asc" ? res.newestCreatedAt : res.oldestCreatedAt;
|
|
27
|
+
}, [sort]);
|
|
28
|
+
const refetch = useCallback(async () => {
|
|
29
|
+
if (!conversationId)
|
|
30
|
+
return;
|
|
31
|
+
loadingRef.current = true;
|
|
32
|
+
setLoading(true);
|
|
33
|
+
hasMoreRef.current = true;
|
|
34
|
+
setHasMore(true);
|
|
35
|
+
try {
|
|
36
|
+
const res = await fetchMany({
|
|
37
|
+
conversationId,
|
|
38
|
+
parentId,
|
|
39
|
+
limit,
|
|
40
|
+
sort,
|
|
41
|
+
includeFiles,
|
|
42
|
+
filters,
|
|
43
|
+
});
|
|
44
|
+
setMessages(res.messages);
|
|
45
|
+
hasMoreRef.current = res.hasMore;
|
|
46
|
+
setHasMore(res.hasMore);
|
|
47
|
+
advanceCursor(res);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
handleError(err, "Failed to fetch messages");
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
loadingRef.current = false;
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, [fetchMany, conversationId, parentId, limit, sort, includeFiles, filtersKey, advanceCursor]);
|
|
58
|
+
const loadMore = useCallback(async () => {
|
|
59
|
+
if (loadingRef.current || !hasMoreRef.current || !cursorRef.current)
|
|
60
|
+
return;
|
|
61
|
+
loadingRef.current = true;
|
|
62
|
+
setLoading(true);
|
|
63
|
+
try {
|
|
64
|
+
const res = await fetchMany({
|
|
65
|
+
conversationId,
|
|
66
|
+
parentId,
|
|
67
|
+
limit,
|
|
68
|
+
sort,
|
|
69
|
+
includeFiles,
|
|
70
|
+
filters,
|
|
71
|
+
...(sort === "asc"
|
|
72
|
+
? { after: cursorRef.current }
|
|
73
|
+
: { before: cursorRef.current }),
|
|
74
|
+
});
|
|
75
|
+
setMessages((prev) => [...prev, ...res.messages]);
|
|
76
|
+
hasMoreRef.current = res.hasMore;
|
|
77
|
+
setHasMore(res.hasMore);
|
|
78
|
+
advanceCursor(res);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
handleError(err, "Failed to load more messages");
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
loadingRef.current = false;
|
|
85
|
+
setLoading(false);
|
|
86
|
+
}
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, [fetchMany, conversationId, parentId, limit, sort, includeFiles, filtersKey, advanceCursor]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
refetch();
|
|
91
|
+
}, [refetch]);
|
|
92
|
+
return { messages, loading, hasMore, loadMore, refetch };
|
|
93
|
+
}
|
|
94
|
+
export default useFetchManyChatMessagesWrapper;
|
|
95
|
+
//# sourceMappingURL=useFetchManyChatMessagesWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchManyChatMessagesWrapper.js","sourceRoot":"","sources":["../../../../../src/hooks/chat/messages/useFetchManyChatMessagesWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,wBAEN,MAAM,4BAA4B,CAAC;AA4BpC;;;;;;GAMG;AACH,SAAS,+BAA+B,CACtC,KAA2C;IAE3C,MAAM,EACJ,cAAc,EACd,QAAQ,EACR,KAAK,GAAG,EAAE,EACV,IAAI,GAAG,MAAM,EACb,YAAY,EACZ,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAAG,wBAAwB,EAAE,CAAC;IAE7C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,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a,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,EAAE,8BAA8B,CAAC,CAAC;QACnD,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;YAC3B,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAEhG,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC3D,CAAC;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChatMessage } from "../../../interfaces/models/ChatMessage";
|
|
2
|
+
export interface UseLiveChatMessagesProps {
|
|
3
|
+
conversationId: string;
|
|
4
|
+
parentId?: string | null;
|
|
5
|
+
limit?: number;
|
|
6
|
+
includeFiles?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseLiveChatMessagesValues {
|
|
9
|
+
messages: ChatMessage[];
|
|
10
|
+
loading: boolean;
|
|
11
|
+
hasMore: boolean;
|
|
12
|
+
loadOlder: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Live, store-backed view of a conversation's messages. Reads from the shared
|
|
16
|
+
* Redux bucket that `ChatProvider` keeps in sync via socket events, so new
|
|
17
|
+
* messages, edits, reactions and reply-count changes appear in real time, and
|
|
18
|
+
* state is shared with `useSendMessage` (optimistic inserts), unread tracking
|
|
19
|
+
* and reconnect catch-up.
|
|
20
|
+
*
|
|
21
|
+
* This is the canonical conversation surface. For a read-only / filtered query
|
|
22
|
+
* that should NOT be polluted by live traffic, use
|
|
23
|
+
* `useFetchManyChatMessagesWrapper` instead.
|
|
24
|
+
*/
|
|
25
|
+
declare function useLiveChatMessages({ conversationId, parentId, limit, includeFiles, }: UseLiveChatMessagesProps): UseLiveChatMessagesValues;
|
|
26
|
+
export default useLiveChatMessages;
|