@droppii-org/chat-mobile 0.2.92 → 0.2.94
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/lib/module/hooks/conversation/useGetConversationDetail.js +7 -7
- package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -1
- package/lib/module/hooks/flows/useCurrentConversationFlow.js +2 -2
- package/lib/module/hooks/flows/useCurrentConversationFlow.js.map +1 -1
- package/lib/module/hooks/flows/useFlow.js +4 -4
- package/lib/module/hooks/flows/useFlow.js.map +1 -1
- package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js +2 -2
- package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js.map +1 -1
- package/lib/module/hooks/stickers/useFetchStickerByCategory.js +2 -2
- package/lib/module/hooks/stickers/useFetchStickerByCategory.js.map +1 -1
- package/lib/module/hooks/stickers/useStickerCategories.js +2 -2
- package/lib/module/hooks/stickers/useStickerCategories.js.map +1 -1
- package/lib/module/hooks/stickers/useStickerHistory.js +2 -2
- package/lib/module/hooks/stickers/useStickerHistory.js.map +1 -1
- package/lib/module/hooks/useLinkPreview/useFetchUrlMetadata.js +4 -3
- package/lib/module/hooks/useLinkPreview/useFetchUrlMetadata.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +15 -11
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +3 -2
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/PinnedMessagesSheet.js +1 -0
- package/lib/module/screens/chat-detail/PinnedMessagesSheet.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +9 -4
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
- package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxOverlay.js +16 -9
- package/lib/module/screens/chat-detail/messageToolbox/MessageToolboxOverlay.js.map +1 -1
- package/lib/module/services/apis.js +14 -1
- package/lib/module/services/apis.js.map +1 -1
- package/lib/module/services/resourceCenter.js +5 -4
- package/lib/module/services/resourceCenter.js.map +1 -1
- package/lib/module/store/message.js +9 -5
- package/lib/module/store/message.js.map +1 -1
- package/lib/module/types/events.js +1 -0
- package/lib/module/types/events.js.map +1 -1
- package/lib/typescript/src/hooks/useLinkPreview/useFetchUrlMetadata.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/PinnedMessagesSheet.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +11 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/messageToolbox/MessageToolboxOverlay.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/messageToolbox/types.d.ts +3 -1
- package/lib/typescript/src/screens/chat-detail/messageToolbox/types.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/types.d.ts +2 -2
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/services/apis.d.ts +21 -1
- package/lib/typescript/src/services/apis.d.ts.map +1 -1
- package/lib/typescript/src/services/resourceCenter.d.ts.map +1 -1
- package/lib/typescript/src/store/message.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +2 -1
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/conversation/useGetConversationDetail.ts +7 -7
- package/src/hooks/flows/useCurrentConversationFlow.ts +2 -2
- package/src/hooks/flows/useFlow.ts +4 -4
- package/src/hooks/flows/useGetConversationFlowMainMenu.ts +2 -2
- package/src/hooks/stickers/useFetchStickerByCategory.ts +2 -2
- package/src/hooks/stickers/useStickerCategories.ts +2 -2
- package/src/hooks/stickers/useStickerHistory.ts +2 -2
- package/src/hooks/useLinkPreview/useFetchUrlMetadata.ts +4 -3
- package/src/index.tsx +1 -1
- package/src/screens/chat-detail/ChatDetail.tsx +23 -14
- package/src/screens/chat-detail/ChatListLegend.tsx +3 -2
- package/src/screens/chat-detail/PinnedMessagesSheet.tsx +1 -0
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +20 -4
- package/src/screens/chat-detail/messageToolbox/MessageToolboxOverlay.tsx +26 -7
- package/src/screens/chat-detail/messageToolbox/types.ts +8 -1
- package/src/screens/chat-detail/types.ts +2 -2
- package/src/services/apis.ts +31 -1
- package/src/services/resourceCenter.ts +5 -4
- package/src/store/message.ts +14 -5
- package/src/types/events.ts +1 -0
package/src/services/apis.ts
CHANGED
|
@@ -4,9 +4,26 @@ import { useConversationStore, useUserStore } from '../store';
|
|
|
4
4
|
|
|
5
5
|
export let apiInstance: AxiosInstance | null = null;
|
|
6
6
|
|
|
7
|
+
interface InitApiInstanceOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Set true when the injected instance's response interceptor already
|
|
10
|
+
* strips the outer envelope (statusCode/message/pageable/data) down to
|
|
11
|
+
* just the payload (e.g. Mall's shared axios client). Defaults to false —
|
|
12
|
+
* the instance returns the raw `{ statusCode, message, pageable, data }`
|
|
13
|
+
* envelope untouched (e.g. Biz's axios client).
|
|
14
|
+
*/
|
|
15
|
+
unwrapped?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let responseUnwrapped = false;
|
|
19
|
+
|
|
7
20
|
export namespace ChatAPI {
|
|
8
|
-
export function initApiInstance(
|
|
21
|
+
export function initApiInstance(
|
|
22
|
+
api: AxiosInstance,
|
|
23
|
+
options?: InitApiInstanceOptions
|
|
24
|
+
): void {
|
|
9
25
|
apiInstance = api;
|
|
26
|
+
responseUnwrapped = options?.unwrapped ?? false;
|
|
10
27
|
}
|
|
11
28
|
|
|
12
29
|
export const getLoginStatus = async (operationID?: string) => {
|
|
@@ -19,3 +36,16 @@ export namespace ChatAPI {
|
|
|
19
36
|
return OpenIMSDK.logout(operationID);
|
|
20
37
|
};
|
|
21
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reads the payload out of an apiInstance response, accounting for whichever
|
|
42
|
+
* envelope shape the injected instance produces (see `initApiInstance`'s
|
|
43
|
+
* `unwrapped` option). Consumers should use this instead of reading
|
|
44
|
+
* `res?.data?.data` / `res?.data` directly.
|
|
45
|
+
*/
|
|
46
|
+
export function unwrapEnvelope<T>(res?: { data?: unknown }): T | null {
|
|
47
|
+
const body = res?.data as { data?: T } | T | undefined;
|
|
48
|
+
if (body == null) return null;
|
|
49
|
+
return ((responseUnwrapped ? body : (body as { data?: T }).data) ??
|
|
50
|
+
null) as T | null;
|
|
51
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { apiInstance } from './apis';
|
|
1
|
+
import { apiInstance, unwrapEnvelope } from './apis';
|
|
2
2
|
import { getApiEndpoint } from '../config/api-endpoints';
|
|
3
3
|
import { extractDomain } from '../utils/url';
|
|
4
4
|
import type { BaseResponse } from '../types/auth';
|
|
@@ -186,12 +186,13 @@ export namespace ResourceCenterService {
|
|
|
186
186
|
const res = await apiInstance?.post<
|
|
187
187
|
BaseResponse<DThreadResourceListResponse>
|
|
188
188
|
>(getApiEndpoint('messagesResources'), req);
|
|
189
|
-
const rows = res
|
|
189
|
+
const rows = unwrapEnvelope<DThreadResourceListResponse>(res) ?? [];
|
|
190
190
|
const items = rows.flatMap(parseThreadResourceItem);
|
|
191
191
|
// `pageable.totalPages`/`totalElements` come back as `0` on this endpoint even
|
|
192
192
|
// when rows are present (confirmed against staging) — unreliable, don't use it.
|
|
193
|
-
//
|
|
194
|
-
|
|
193
|
+
// Row-count-vs-pageSize is the trustworthy `hasMore` signal — `items.length` can
|
|
194
|
+
// exceed `rows.length` when a row splits into multiple items (e.g. multi-url).
|
|
195
|
+
const hasMore = rows.length >= req.pageSize;
|
|
195
196
|
return { items, page: req.page, hasMore };
|
|
196
197
|
};
|
|
197
198
|
}
|
package/src/store/message.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
MessageStore,
|
|
13
13
|
} from '../types/chat';
|
|
14
14
|
import { mergeMessages } from '../utils/message';
|
|
15
|
+
import { isMessageRevoked } from '../utils/messageUtils';
|
|
15
16
|
import { useConversationStore } from './conversation';
|
|
16
17
|
|
|
17
18
|
// Smaller than a typical "load more" page size elsewhere in the app on
|
|
@@ -191,12 +192,20 @@ export const useMessageStore = create<MessageStore>()((set, get) => ({
|
|
|
191
192
|
hasMoreNew: !searchNextRes.isEnd,
|
|
192
193
|
initLoading: false,
|
|
193
194
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
|
|
196
|
+
const targetMessage = currentMessages.find(
|
|
197
|
+
(msg) => msg.clientMsgID === startClientMsgId
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
if (!targetMessage || isMessageRevoked(targetMessage)) {
|
|
201
|
+
DeviceEventEmitter.emit(ChatEvent.TargetMessageUnavailable);
|
|
202
|
+
return;
|
|
199
203
|
}
|
|
204
|
+
|
|
205
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
206
|
+
DeviceEventEmitter.emit(ChatEvent.ScrollToMessage, {
|
|
207
|
+
clientMessageId: startClientMsgId,
|
|
208
|
+
});
|
|
200
209
|
}
|
|
201
210
|
} catch (error) {
|
|
202
211
|
console.error('Failed to search messages', error);
|
package/src/types/events.ts
CHANGED
|
@@ -6,6 +6,7 @@ export enum ChatEvent {
|
|
|
6
6
|
MessageRevoked = 'chat:message_revoked',
|
|
7
7
|
GroupPermissionUpdated = 'chat:group_permission_updated',
|
|
8
8
|
GroupRemoved = 'chat:group_removed',
|
|
9
|
+
TargetMessageUnavailable = 'chat:target_message_unavailable',
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export interface ScrollToMessagePayload {
|