@droppii-org/chat-mobile 0.2.94 → 0.2.96

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.
Files changed (53) hide show
  1. package/lib/module/config/api-endpoints.js +2 -1
  2. package/lib/module/config/api-endpoints.js.map +1 -1
  3. package/lib/module/hooks/groups/useJoinGroupByInviteLink.js +155 -0
  4. package/lib/module/hooks/groups/useJoinGroupByInviteLink.js.map +1 -0
  5. package/lib/module/hooks/groups/useResolveGroupInviteLink.js +18 -0
  6. package/lib/module/hooks/groups/useResolveGroupInviteLink.js.map +1 -0
  7. package/lib/module/hooks/query-keys.js +2 -1
  8. package/lib/module/hooks/query-keys.js.map +1 -1
  9. package/lib/module/screens/chat-detail/ChatListLegend.js +230 -72
  10. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  11. package/lib/module/screens/inbox/Inbox.js +11 -1
  12. package/lib/module/screens/inbox/Inbox.js.map +1 -1
  13. package/lib/module/services/endpoints.js +2 -1
  14. package/lib/module/services/endpoints.js.map +1 -1
  15. package/lib/module/services/groupInvite.js +12 -0
  16. package/lib/module/services/groupInvite.js.map +1 -0
  17. package/lib/module/translation/resources/i18n.js +6 -1
  18. package/lib/module/translation/resources/i18n.js.map +1 -1
  19. package/lib/module/types/chat.js +2 -0
  20. package/lib/module/types/chat.js.map +1 -1
  21. package/lib/module/utils/messageUtils.js +14 -4
  22. package/lib/module/utils/messageUtils.js.map +1 -1
  23. package/lib/typescript/src/config/api-endpoints.d.ts +1 -0
  24. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -1
  25. package/lib/typescript/src/hooks/groups/useJoinGroupByInviteLink.d.ts +21 -0
  26. package/lib/typescript/src/hooks/groups/useJoinGroupByInviteLink.d.ts.map +1 -0
  27. package/lib/typescript/src/hooks/groups/useResolveGroupInviteLink.d.ts +3 -0
  28. package/lib/typescript/src/hooks/groups/useResolveGroupInviteLink.d.ts.map +1 -0
  29. package/lib/typescript/src/hooks/query-keys.d.ts +1 -0
  30. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  31. package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
  32. package/lib/typescript/src/screens/inbox/Inbox.d.ts +4 -3
  33. package/lib/typescript/src/screens/inbox/Inbox.d.ts.map +1 -1
  34. package/lib/typescript/src/services/endpoints.d.ts +1 -0
  35. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  36. package/lib/typescript/src/services/groupInvite.d.ts +5 -0
  37. package/lib/typescript/src/services/groupInvite.d.ts.map +1 -0
  38. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  39. package/lib/typescript/src/types/chat.d.ts +13 -2
  40. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  41. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/config/api-endpoints.ts +2 -0
  44. package/src/hooks/groups/useJoinGroupByInviteLink.tsx +167 -0
  45. package/src/hooks/groups/useResolveGroupInviteLink.ts +20 -0
  46. package/src/hooks/query-keys.ts +2 -0
  47. package/src/screens/chat-detail/ChatListLegend.tsx +246 -71
  48. package/src/screens/inbox/Inbox.tsx +21 -2
  49. package/src/services/endpoints.ts +2 -0
  50. package/src/services/groupInvite.ts +15 -0
  51. package/src/translation/resources/i18n.ts +6 -0
  52. package/src/types/chat.ts +14 -8
  53. package/src/utils/messageUtils.ts +18 -3
@@ -22,7 +22,8 @@ const DEFAULT_ENDPOINTS = {
22
22
  stickerHistory: '/chat-service/v1/app/stickers/history',
23
23
  messagesResources: '/chat-service/v1/app/messages/resources',
24
24
  messages: '/chat-service/v1/app/messages',
25
- contacts: '/chat-service/v1/app/contacts'
25
+ contacts: '/chat-service/v1/app/contacts',
26
+ groupJoinLink: '/chat-service/v1/app/conversations/join-link'
26
27
  };
27
28
  let endpoints = {
28
29
  ...DEFAULT_ENDPOINTS
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_ENDPOINTS","urlMetadata","conversation","imageUpload","bot","uploadFcmToken","stickerCategories","stickersByCategory","stickerHistory","messagesResources","messages","contacts","endpoints","getApiEndpoint","key","setApiEndpoint","value","setAllApiEndpoints","newEndpoints","resetApiEndpoints","getAllApiEndpoints"],"sourceRoot":"../../../src","sources":["config/api-endpoints.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,MAAMA,iBAA+B,GAAG;EACtCC,WAAW,EAAE,qCAAqC;EAClDC,YAAY,EAAE,oCAAoC;EAClDC,WAAW,EAAE,2CAA2C;EACxDC,GAAG,EAAE,4BAA4B;EACjCC,cAAc,EAAE,sCAAsC;EACtDC,iBAAiB,EAAE,yCAAyC;EAC5DC,kBAAkB,EAAE,yCAAyC;EAC7DC,cAAc,EAAE,uCAAuC;EACvDC,iBAAiB,EAAE,yCAAyC;EAC5DC,QAAQ,EAAE,+BAA+B;EACzCC,QAAQ,EAAE;AACZ,CAAC;AAED,IAAIC,SAAuB,GAAG;EAAE,GAAGZ;AAAkB,CAAC;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMa,cAAc,GACzBC,GAAM,IACc;EACpB,OAAOF,SAAS,CAACE,GAAG,CAAC;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAC5BD,GAAM,EACNE,KAAsB,KACnB;EACHJ,SAAS,CAACE,GAAG,CAAC,GAAGE,KAAK;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,YAAmC,IAAK;EACzEN,SAAS,GAAG;IACV,GAAGA,SAAS;IACZ,GAAGM;EACL,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrCP,SAAS,GAAG;IAAE,GAAGZ;EAAkB,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMoB,kBAAkB,GAAGA,CAAA,MAAqB;EACrD,GAAGR;AACL,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DEFAULT_ENDPOINTS","urlMetadata","conversation","imageUpload","bot","uploadFcmToken","stickerCategories","stickersByCategory","stickerHistory","messagesResources","messages","contacts","groupJoinLink","endpoints","getApiEndpoint","key","setApiEndpoint","value","setAllApiEndpoints","newEndpoints","resetApiEndpoints","getAllApiEndpoints"],"sourceRoot":"../../../src","sources":["config/api-endpoints.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,MAAMA,iBAA+B,GAAG;EACtCC,WAAW,EAAE,qCAAqC;EAClDC,YAAY,EAAE,oCAAoC;EAClDC,WAAW,EAAE,2CAA2C;EACxDC,GAAG,EAAE,4BAA4B;EACjCC,cAAc,EAAE,sCAAsC;EACtDC,iBAAiB,EAAE,yCAAyC;EAC5DC,kBAAkB,EAAE,yCAAyC;EAC7DC,cAAc,EAAE,uCAAuC;EACvDC,iBAAiB,EAAE,yCAAyC;EAC5DC,QAAQ,EAAE,+BAA+B;EACzCC,QAAQ,EAAE,+BAA+B;EACzCC,aAAa,EAAE;AACjB,CAAC;AAED,IAAIC,SAAuB,GAAG;EAAE,GAAGb;AAAkB,CAAC;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMc,cAAc,GACzBC,GAAM,IACc;EACpB,OAAOF,SAAS,CAACE,GAAG,CAAC;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAC5BD,GAAM,EACNE,KAAsB,KACnB;EACHJ,SAAS,CAACE,GAAG,CAAC,GAAGE,KAAK;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,YAAmC,IAAK;EACzEN,SAAS,GAAG;IACV,GAAGA,SAAS;IACZ,GAAGM;EACL,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrCP,SAAS,GAAG;IAAE,GAAGb;EAAkB,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMqB,kBAAkB,GAAGA,CAAA,MAAqB;EACrD,GAAGR;AACL,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ import { memo, useCallback, useEffect, useRef } from 'react';
4
+ import { GroupJoinSource } from '@droppii/openim-rn-client-sdk';
5
+ import { KButton, KColors, KContainer, KLabel } from '@droppii/libs';
6
+ import { Avatar } from "../../components/Avatar/index.js";
7
+ import { UIUtils } from "../../utils/UIUtils.js";
8
+ import { trans } from "../../translation/index.js";
9
+ import { useJoinGroup } from "./useJoinGroup.js";
10
+ import { useResolveGroupInviteLink } from "./useResolveGroupInviteLink.js";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const showGroupInviteLinkUnavailableModal = () => {
13
+ UIUtils.alert.open({
14
+ title: trans('group:invite_link_unavailable_title'),
15
+ message: trans('group:invite_link_unavailable_desc'),
16
+ primaryIndex: 0,
17
+ buttonType: 'horizontal-button',
18
+ buttons: [{
19
+ label: trans('group:access_blocked_button'),
20
+ kind: 'primary'
21
+ }],
22
+ ignoreStack: true
23
+ });
24
+ };
25
+ const JoinGroupConfirmSheetContent = /*#__PURE__*/memo(({
26
+ groupInfo,
27
+ onJoined
28
+ }) => {
29
+ const {
30
+ mutate: joinGroup,
31
+ isPending
32
+ } = useJoinGroup();
33
+ const handleConfirm = useCallback(() => {
34
+ if (isPending) return;
35
+ joinGroup({
36
+ groupID: groupInfo.groupId,
37
+ reqMsg: '',
38
+ joinSource: GroupJoinSource.QrCode,
39
+ groupName: groupInfo.groupName
40
+ }, {
41
+ onSuccess: () => {
42
+ UIUtils.bottomSheet.dismiss();
43
+ onJoined();
44
+ },
45
+ onError: () => {
46
+ UIUtils.toast.open({
47
+ title: trans('chat:generic_error'),
48
+ theme: 'error'
49
+ });
50
+ }
51
+ });
52
+ }, [joinGroup, groupInfo, onJoined, isPending]);
53
+ return /*#__PURE__*/_jsxs(KContainer.View, {
54
+ paddingH: "1rem",
55
+ paddingB: "1rem",
56
+ alignItems: true,
57
+ children: [/*#__PURE__*/_jsx(Avatar, {
58
+ size: "4xlg",
59
+ source: groupInfo.groupAvatar,
60
+ fullName: groupInfo.groupName
61
+ }), /*#__PURE__*/_jsx(KLabel.Text, {
62
+ typo: "TextLgBold",
63
+ color: KColors.black,
64
+ paddingT: "0.75rem",
65
+ numberOfLines: 2,
66
+ textAlign: "center",
67
+ children: groupInfo.groupName
68
+ }), /*#__PURE__*/_jsx(KLabel.Text, {
69
+ typo: "TextMdNormal",
70
+ color: KColors.gray.normal,
71
+ paddingT: "0.25rem",
72
+ children: trans('group:member_count', {
73
+ count: groupInfo.groupTotalMember
74
+ })
75
+ }), /*#__PURE__*/_jsx(KButton.Solid, {
76
+ label: trans('group:join_group_confirm_button'),
77
+ onPress: handleConfirm,
78
+ loading: isPending,
79
+ isLightSolid: true,
80
+ kind: "primary",
81
+ stretch: true,
82
+ marginT: "1rem"
83
+ })]
84
+ });
85
+ });
86
+ const openJoinGroupConfirmSheet = params => {
87
+ UIUtils.bottomSheet.open({
88
+ header: {
89
+ title: {
90
+ text: trans('group:join_group_confirm_title')
91
+ },
92
+ alignment: 'left',
93
+ showCloseButton: true
94
+ },
95
+ touchOutsideToDismiss: true,
96
+ body: {
97
+ renderContent: () => /*#__PURE__*/_jsx(JoinGroupConfirmSheetContent, {
98
+ groupInfo: params.groupInfo,
99
+ onJoined: params.onJoined
100
+ })
101
+ }
102
+ });
103
+ };
104
+ /**
105
+ * Orchestrates the invite-link entry flow: resolves the code via BE, then
106
+ * routes to the right outcome — existing member / public non-member both
107
+ * resolve immediately via `onAllowed` (the group screen's own access guard
108
+ * derives view-only vs full access on its own), a private non-member sees a
109
+ * confirm-join bottom sheet first, and any resolve failure shows the
110
+ * Unavailable Link modal. Settles at most once per `code` — a background
111
+ * refetch of the resolve query must not re-open the sheet or re-fire
112
+ * `onAllowed`.
113
+ */
114
+ export const useJoinGroupByInviteLink = ({
115
+ code,
116
+ onAllowed
117
+ }) => {
118
+ const {
119
+ data,
120
+ isLoading,
121
+ isError
122
+ } = useResolveGroupInviteLink(code);
123
+ const settledCodeRef = useRef(undefined);
124
+ useEffect(() => {
125
+ if (!code || isLoading || settledCodeRef.current === code) return;
126
+ if (isError || !data) {
127
+ settledCodeRef.current = code;
128
+ showGroupInviteLinkUnavailableModal();
129
+ return;
130
+ }
131
+ if (data.isMember) {
132
+ settledCodeRef.current = code;
133
+ onAllowed({
134
+ groupId: data.groupId,
135
+ conversationId: data.conversationId
136
+ });
137
+ return;
138
+ }
139
+ settledCodeRef.current = code;
140
+ UIUtils.bottomSheet.dismiss();
141
+ openJoinGroupConfirmSheet({
142
+ groupInfo: data,
143
+ onJoined: () => {
144
+ onAllowed({
145
+ groupId: data.groupId,
146
+ conversationId: data.conversationId
147
+ });
148
+ }
149
+ });
150
+ // Do not add code as dependency
151
+ // Because data is delayed compared to code -> cause stalling data
152
+ // eslint-disable-next-line react-hooks/exhaustive-deps
153
+ }, [isLoading, isError, data, onAllowed]);
154
+ };
155
+ //# sourceMappingURL=useJoinGroupByInviteLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["memo","useCallback","useEffect","useRef","GroupJoinSource","KButton","KColors","KContainer","KLabel","Avatar","UIUtils","trans","useJoinGroup","useResolveGroupInviteLink","jsx","_jsx","jsxs","_jsxs","showGroupInviteLinkUnavailableModal","alert","open","title","message","primaryIndex","buttonType","buttons","label","kind","ignoreStack","JoinGroupConfirmSheetContent","groupInfo","onJoined","mutate","joinGroup","isPending","handleConfirm","groupID","groupId","reqMsg","joinSource","QrCode","groupName","onSuccess","bottomSheet","dismiss","onError","toast","theme","View","paddingH","paddingB","alignItems","children","size","source","groupAvatar","fullName","Text","typo","color","black","paddingT","numberOfLines","textAlign","gray","normal","count","groupTotalMember","Solid","onPress","loading","isLightSolid","stretch","marginT","openJoinGroupConfirmSheet","params","header","text","alignment","showCloseButton","touchOutsideToDismiss","body","renderContent","useJoinGroupByInviteLink","code","onAllowed","data","isLoading","isError","settledCodeRef","undefined","current","isMember","conversationId"],"sourceRoot":"../../../../src","sources":["hooks/groups/useJoinGroupByInviteLink.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC5D,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,OAAO,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,QAAQ,eAAe;AACpE,SAASC,MAAM,QAAQ,kCAAyB;AAChD,SAASC,OAAO,QAAQ,wBAAqB;AAC7C,SAASC,KAAK,QAAQ,4BAAmB;AAEzC,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,yBAAyB,QAAQ,gCAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExE,MAAMC,mCAAmC,GAAGA,CAAA,KAAM;EAChDR,OAAO,CAACS,KAAK,CAACC,IAAI,CAAC;IACjBC,KAAK,EAAEV,KAAK,CAAC,qCAAqC,CAAC;IACnDW,OAAO,EAAEX,KAAK,CAAC,oCAAoC,CAAC;IACpDY,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,mBAAmB;IAC/BC,OAAO,EAAE,CAAC;MAAEC,KAAK,EAAEf,KAAK,CAAC,6BAA6B,CAAC;MAAEgB,IAAI,EAAE;IAAU,CAAC,CAAC;IAC3EC,WAAW,EAAE;EACf,CAAC,CAAC;AACJ,CAAC;AAOD,MAAMC,4BAA4B,gBAAG7B,IAAI,CACvC,CAAC;EAAE8B,SAAS;EAAEC;AAA4C,CAAC,KAAK;EAC9D,MAAM;IAAEC,MAAM,EAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGtB,YAAY,CAAC,CAAC;EAEvD,MAAMuB,aAAa,GAAGlC,WAAW,CAAC,MAAM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AAI,EAAE;IAE3D,IAAII,OAAO,IAAI,CAACF,IAAI,EAAE;MACpBG,cAAc,CAACE,OAAO,GAAGP,IAAI;MAC7BlE,mCAAmC,CAAC,CAAC;MACrC;IACF;IAEA,IAAIoE,IAAI,CAACM,QAAQ,EAAE;MACjBH,cAAc,CAACE,OAAO,GAAGP,IAAI;MAC7BC,SAAS,CAAC;QAAEhD,OAAO,EAAEiD,IAAI,CAACjD,OAAO;QAAEwD,cAAc,EAAEP,IAAI,CAACO;MAAe,CAAC,CAAC;MACzE;IACF;IAEAJ,cAAc,CAACE,OAAO,GAAGP,IAAI;IAC7B1E,OAAO,CAACiC,WAAW,CAACC,OAAO,CAAC,CAAC;IAC7B8B,yBAAyB,CAAC;MACxB5C,SAAS,EAAEwD,IAAI;MACfvD,QAAQ,EAAEA,CAAA,KAAM;QACdsD,SAAS,CAAC;UACRhD,OAAO,EAAEiD,IAAI,CAACjD,OAAO;UACrBwD,cAAc,EAAEP,IAAI,CAACO;QACvB,CAAC,CAAC;MACJ;IACF,CAAC,CAAC;IACF;IACA;IACA;EACF,CAAC,EAAE,CAACN,SAAS,EAAEC,OAAO,EAAEF,IAAI,EAAED,SAAS,CAAC,CAAC;AAC3C,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ import { useQuery } from '@tanstack/react-query';
4
+ import { groupQueryKeys } from "../query-keys.js";
5
+ import { apiInstance, unwrapEnvelope } from "../../services/apis.js";
6
+ import { ENDPOINTS } from "../../services/endpoints.js";
7
+ export const useResolveGroupInviteLink = code => {
8
+ return useQuery({
9
+ queryKey: groupQueryKeys.inviteInfo(code ?? ''),
10
+ enabled: Boolean(code),
11
+ queryFn: async () => {
12
+ const res = await apiInstance?.get(ENDPOINTS.chatService.groupJoinLink(code));
13
+ return unwrapEnvelope(res);
14
+ },
15
+ refetchOnWindowFocus: false
16
+ });
17
+ };
18
+ //# sourceMappingURL=useResolveGroupInviteLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useQuery","groupQueryKeys","apiInstance","unwrapEnvelope","ENDPOINTS","useResolveGroupInviteLink","code","queryKey","inviteInfo","enabled","Boolean","queryFn","res","get","chatService","groupJoinLink","refetchOnWindowFocus"],"sourceRoot":"../../../../src","sources":["hooks/groups/useResolveGroupInviteLink.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,cAAc,QAAQ,kBAAe;AAE9C,SAASC,WAAW,EAAEC,cAAc,QAAQ,wBAAqB;AAEjE,SAASC,SAAS,QAAQ,6BAA0B;AAEpD,OAAO,MAAMC,yBAAyB,GAAIC,IAAa,IAAK;EAC1D,OAAON,QAAQ,CAAC;IACdO,QAAQ,EAAEN,cAAc,CAACO,UAAU,CAACF,IAAI,IAAI,EAAE,CAAC;IAC/CG,OAAO,EAAEC,OAAO,CAACJ,IAAI,CAAC;IACtBK,OAAO,EAAE,MAAAA,CAAA,KAAY;MACnB,MAAMC,GAAG,GAAG,MAAMV,WAAW,EAAEW,GAAG,CAChCT,SAAS,CAACU,WAAW,CAACC,aAAa,CAACT,IAAK,CAC3C,CAAC;MACD,OAAOH,cAAc,CAAsBS,GAAG,CAAC;IACjD,CAAC;IACDI,oBAAoB,EAAE;EACxB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -54,6 +54,7 @@ export const groupQueryKeys = {
54
54
  public: () => [...groupQueryKeys.all, 'public'],
55
55
  publicSearch: keyword => [...groupQueryKeys.public(), keyword],
56
56
  join: () => [...groupQueryKeys.all, 'join'],
57
- leave: () => [...groupQueryKeys.all, 'leave']
57
+ leave: () => [...groupQueryKeys.all, 'leave'],
58
+ inviteInfo: code => [...groupQueryKeys.all, 'inviteInfo', code]
58
59
  };
59
60
  //# sourceMappingURL=query-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["commonQueryKeys","all","urlMetadata","url","conversationQueryKeys","lists","list","applicationType","details","detail","conversationId","getStatusBot","botId","conversationTarget","flow","flowMainMenu","resetFlow","runFlow","closeSession","detailByBotId","detailBySourceId","sourceId","joinedGroup","groupId","create","userId","groupInfo","usersQueryKeys","userIds","stickerQueryKeys","categories","byCategory","categoryId","recent","resourceCenterQueryKeys","byType","recvID","contentType","messageQueryKeys","search","query","mentionQueryKeys","groupID","keyword","contactQueryKeys","type","groupQueryKeys","public","publicSearch","join","leave"],"sourceRoot":"../../../src","sources":["hooks/query-keys.ts"],"mappings":";;AAAA,OAAO,MAAMA,eAAe,GAAG;EAC7BC,GAAG,EAAE,CAAC,QAAQ,CAAU;EACxBC,WAAW,EAAGC,GAAW,IAAK,CAAC,MAAM,EAAEA,GAAG;AAC5C,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG;EACnCH,GAAG,EAAE,CAAC,eAAe,CAAU;EAC/BI,KAAK,EAAEA,CAAA,KAAM,CAAC,GAAGD,qBAAqB,CAACH,GAAG,EAAE,MAAM,CAAU;EAC5DK,IAAI,EAAGC,eAAuB,IAC5B,CAAC,GAAGH,qBAAqB,CAACC,KAAK,CAAC,CAAC,EAAEE,eAAe,CAAU;EAC9DC,OAAO,EAAEA,CAAA,KAAM,CAAC,GAAGJ,qBAAqB,CAACH,GAAG,EAAE,QAAQ,CAAU;EAChEQ,MAAM,EAAGC,cAAsB,IAC7B,CAAC,GAAGN,qBAAqB,CAACI,OAAO,CAAC,CAAC,EAAEE,cAAc,CAAU;EAC/DC,YAAY,EAAGC,KAAa,IAAK,CAAC,cAAc,EAAEA,KAAK,CAAU;EACjEC,kBAAkB,EAAGH,cAAsB,IACzC,CAAC,oBAAoB,EAAEA,cAAc,CAAU;EACjDI,IAAI,EAAGJ,cAAsB,IAAK,CAAC,kBAAkB,EAAEA,cAAc,CAAC;EACtEK,YAAY,EAAGL,cAAsB,IAAK,CACxC,0BAA0B,EAC1BA,cAAc,CACf;EACDM,SAAS,EAAGN,cAAsB,IAAK,CACrC,uBAAuB,EACvBA,cAAc,CACf;EACDO,OAAO,EAAGP,cAAsB,IAAK,CAAC,qBA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BrC,GAAG,EAAE,CAAC,UAAU,CAAU;EAC1BsC,MAAM,EAAEA,CAACC,KAAa,EAAE9B,cAAuB,KAC7C,CAAC,GAAG4B,gBAAgB,CAACrC,GAAG,EAAE,QAAQ,EAAEuC,KAAK,EAAE9B,cAAc;AAC7D,CAAC;AAED,OAAO,MAAM+B,gBAAgB,GAAG;EAC9BxC,GAAG,EAAE,CAAC,eAAe,CAAU;EAC/BsC,MAAM,EAAEA,CAACG,OAAe,EAAEC,OAAe,KACvC,CAAC,GAAGF,gBAAgB,CAACxC,GAAG,EAAEyC,OAAO,EAAEC,OAAO;AAC9C,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC9B3C,GAAG,EAAE,CAAC,UAAU,CAAU;EAC1BsC,MAAM,EAAEA,CAACC,KAAa,EAAEK,IAAa,KACnC,CAAC,GAAGD,gBAAgB,CAAC3C,GAAG,EAAE,QAAQ,EAAEuC,KAAK,EAAEK,IAAI;AACnD,CAAC;AAED,OAAO,MAAMC,cAAc,GAAG;EAC5B7C,GAAG,EAAE,CAAC,QAAQ,CAAU;EACxB8C,MAAM,EAAEA,CAAA,KAAM,CAAC,GAAGD,cAAc,CAAC7C,GAAG,EAAE,QAAQ,CAAU;EACxD+C,YAAY,EAAGL,OAAe,IAC5B,CAAC,GAAGG,cAAc,CAACC,MAAM,CAAC,CAAC,EAAEJ,OAAO,CAAU;EAChDM,IAAI,EAAEA,CAAA,KAAM,CAAC,GAAGH,cAAc,CAAC7C,GAAG,EAAE,MAAM,CAAU;EACpDiD,KAAK,EAAEA,CAAA,KAAM,CAAC,GAAGJ,cAAc,CAAC7C,GAAG,EAAE,OAAO;AAC9C,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["commonQueryKeys","all","urlMetadata","url","conversationQueryKeys","lists","list","applicationType","details","detail","conversationId","getStatusBot","botId","conversationTarget","flow","flowMainMenu","resetFlow","runFlow","closeSession","detailByBotId","detailBySourceId","sourceId","joinedGroup","groupId","create","userId","groupInfo","usersQueryKeys","userIds","stickerQueryKeys","categories","byCategory","categoryId","recent","resourceCenterQueryKeys","byType","recvID","contentType","messageQueryKeys","search","query","mentionQueryKeys","groupID","keyword","contactQueryKeys","type","groupQueryKeys","public","publicSearch","join","leave","inviteInfo","code"],"sourceRoot":"../../../src","sources":["hooks/query-keys.ts"],"mappings":";;AAAA,OAAO,MAAMA,eAAe,GAAG;EAC7BC,GAAG,EAAE,CAAC,QAAQ,CAAU;EACxBC,WAAW,EAAGC,GAAW,IAAK,CAAC,MAAM,EAAEA,GAAG;AAC5C,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG;EACnCH,GAAG,EAAE,CAAC,eAAe,CAAU;EAC/BI,KAAK,EAAEA,CAAA,KAAM,CAAC,GAAGD,qBAAqB,CAACH,GAAG,EAAE,MAAM,CAAU;EAC5DK,IAAI,EAAGC,eAAuB,IAC5B,CAAC,GAAGH,qBAAqB,CAACC,KAAK,CAAC,CAAC,EAAEE,eAAe,CAAU;EAC9DC,OAAO,EAAEA,CAAA,KAAM,CAAC,GAAGJ,qBAAqB,CAACH,GAAG,EAAE,QAAQ,CAAU;EAChEQ,MAAM,EAAGC,cAAsB,IAC7B,CAAC,GAAGN,qBAAqB,CAACI,OAAO,CAAC,CAAC,EAAEE,cAAc,CAAU;EAC/DC,YAAY,EAAGC,KAAa,IAAK,CAAC,cAAc,EAAEA,KAAK,CAAU;EACjEC,kBAAkB,EAAGH,cAAsB,IACzC,CAAC,oBAAoB,EAAEA,cAAc,CAAU;EACjDI,IAAI,EAAGJ,cAAsB,IAAK,CAAC,kBAAkB,EAAEA,cAAc,CAAC;EACtEK,YAAY,EAAGL,cAAsB,IAAK,CACxC,0BAA0B,EAC1BA,cAAc,CACf;EACDM,SAAS,EAAGN,cAAsB,IAAK,CACrC,uBAAuB,EACvBA,cAAc,CACf;EACDO,OAAO,EAAGP,cAAsB,IAAK,CAAC,qBAAqB,EAAEA,cAAc,CAAC;EAC5EQ,YAAY,EAAGR,cAAsB,IAAK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AACC,KAAa,EAAE9B,cAAuB,KAC7C,CAAC,GAAG4B,gBAAgB,CAACrC,GAAG,EAAE,QAAQ,EAAEuC,KAAK,EAAE9B,cAAc;AAC7D,CAAC;AAED,OAAO,MAAM+B,gBAAgB,GAAG;EAC9BxC,GAAG,EAAE,CAAC,eAAe,CAAU;EAC/BsC,MAAM,EAAEA,CAACG,OAAe,EAAEC,OAAe,KACvC,CAAC,GAAGF,gBAAgB,CAACxC,GAAG,EAAEyC,OAAO,EAAEC,OAAO;AAC9C,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC9B3C,GAAG,EAAE,CAAC,UAAU,CAAU;EAC1BsC,MAAM,EAAEA,CAACC,KAAa,EAAEK,IAAa,KACnC,CAAC,GAAGD,gBAAgB,CAAC3C,GAAG,EAAE,QAAQ,EAAEuC,KAAK,EAAEK,IAAI;AACnD,CAAC;AAED,OAAO,MAAMC,cAAc,GAAG;EAC5B7C,GAAG,EAAE,CAAC,QAAQ,CAAU;EACxB8C,MAAM,EAAEA,CAAA,KAAM,CAAC,GAAGD,cAAc,CAAC7C,GAAG,EAAE,QAAQ,CAAU;EACxD+C,YAAY,EAAGL,OAAe,IAC5B,CAAC,GAAGG,cAAc,CAACC,MAAM,CAAC,CAAC,EAAEJ,OAAO,CAAU;EAChDM,IAAI,EAAEA,CAAA,KAAM,CAAC,GAAGH,cAAc,CAAC7C,GAAG,EAAE,MAAM,CAAU;EACpDiD,KAAK,EAAEA,CAAA,KAAM,CAAC,GAAGJ,cAAc,CAAC7C,GAAG,EAAE,OAAO,CAAU;EACtDkD,UAAU,EAAGC,IAAY,IACvB,CAAC,GAAGN,cAAc,CAAC7C,GAAG,EAAE,YAAY,EAAEmD,IAAI;AAC9C,CAAC","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  import { memo, useCallback, useMemo, useEffect, useRef, useState } from 'react';
4
- import { ActivityIndicator, DeviceEventEmitter, Platform, StyleSheet, useWindowDimensions } from 'react-native';
4
+ import { ActivityIndicator, DeviceEventEmitter, StyleSheet, useWindowDimensions } from 'react-native';
5
5
  import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
6
6
  import { KeyboardAwareLegendList } from '@legendapp/list/keyboard';
7
- import { KeyboardEvents } from 'react-native-keyboard-controller';
7
+ import { KeyboardEvents, useGenericKeyboardHandler } from 'react-native-keyboard-controller';
8
8
  import { KContainer, KColors, KSpacingValue, KLabel, KRadiusValue, KImage } from '@droppii/libs';
9
9
  import { precomputeLegendListData } from "../../utils/legendListMessage.js";
10
10
  import { getMessageRenderId } from "../../utils/message.js";
@@ -39,11 +39,36 @@ const BUTTON_FADE_CONFIG = {
39
39
  duration: 200,
40
40
  easing: Easing.out(Easing.ease)
41
41
  };
42
+ const CONTENT_PADDING_VERTICAL = KSpacingValue['0.75rem'];
42
43
 
43
- // Long enough to swallow Android's willShow→willHide→willShow flapping
44
- // (~1.3s period, measured), short enough that a real keyboard close still
45
- // settles within one animation.
46
- const KEYBOARD_HIDE_DEBOUNCE_MS = 300;
44
+ // How long past the duration the keyboard event reported the following loop
45
+ // keeps waiting for the live height to actually reach its target before giving
46
+ // up and snapping to it. Only a fallback: normally the loop ends the frame the
47
+ // keyboard does.
48
+ const FOLLOW_FALLBACK_MS = 120;
49
+
50
+ // How long the keyboard-following loop keeps claiming the list after its last
51
+ // frame. That frame's `setState` renders, lays out and emits its scroll event
52
+ // after the loop has returned, and that trailing event carries the same
53
+ // half-applied geometry the rest of the transition does.
54
+ const FOLLOW_SETTLE_MS = 200;
55
+
56
+ // Frames the keyboard-following loop keeps pinning after the reserved room has
57
+ // reached its target. The pin in the frame that sets the final padding runs
58
+ // before React has rendered it and before the native layout has applied, so it
59
+ // finds no room to scroll into. On iOS that goes unnoticed — the loop has many
60
+ // frames and a later one does the work — but Android's first loop frame
61
+ // already reports the finished height, so without a tail nothing ever scrolls
62
+ // and the last message stays behind the keyboard.
63
+ const FOLLOW_TAIL_FRAMES = 3;
64
+
65
+ // Passed as the list's `keyboardOffset` to switch KeyboardChatScrollView's own
66
+ // native `contentInset` off while leaving the rest of the component in place.
67
+ // Its `getEffectiveHeight` interpolates the live keyboard height into
68
+ // `[0, max(keyboardHeight - offset, 0)]`, so an offset no keyboard can exceed
69
+ // pins the inset at 0 for every frame of the transition. The keyboard's room is
70
+ // reserved as real content padding instead — see the keyboard effect below.
71
+ const DISABLE_NATIVE_KEYBOARD_INSET = 1_000_000;
47
72
  const getRowMarginBottom = position => position === 'last' || position === 'solo' ? ROW_MARGIN_CLUSTER_END : ROW_MARGIN_IN_CLUSTER;
48
73
  export const ChatListLegend = /*#__PURE__*/memo(({
49
74
  messages = [],
@@ -95,10 +120,36 @@ export const ChatListLegend = /*#__PURE__*/memo(({
95
120
  const buttonOpacity = useSharedValue(0);
96
121
  const isAtBottomRef = useRef(true);
97
122
  const scrollDebounceRef = useRef(undefined);
98
- // Current keyboard height, and the trigger for the re-anchor effect
99
- // below — see the keyboard listener for how each platform uses it.
123
+ // The state drives the content's bottom padding; the ref is the last
124
+ // value acted on, read synchronously inside the keyboard listener to
125
+ // drop Android's repeat events before they reach React.
126
+ const keyboardInsetRef = useRef(0);
100
127
  const [keyboardInset, setKeyboardInset] = useState(0);
101
- const hasSeenFirstKeyboardInsetRef = useRef(false);
128
+ // The keyboard's live height, written on the UI thread and sampled from
129
+ // the JS thread by the tween below, so the content tracks the keyboard's
130
+ // real position instead of a guessed easing curve.
131
+ //
132
+ // `useGenericKeyboardHandler` rather than `useKeyboardHandler` /
133
+ // `useReanimatedKeyboardAnimation`: those call `useResizeMode()`, which
134
+ // reaches in and sets Android's soft input mode — `KeyboardProvider`
135
+ // already owns that here. The worklet only writes a SharedValue; calling
136
+ // `runOnJS` (or anything that reaches JS) from a keyboard worklet
137
+ // reliably crashes Reanimated with a reentrant-lock assertion.
138
+ // True while the keyboard-following loop below is driving the list.
139
+ const isFollowingKeyboardRef = useRef(false);
140
+ const liveKeyboardHeight = useSharedValue(0);
141
+ useGenericKeyboardHandler({
142
+ onMove: e => {
143
+ 'worklet';
144
+
145
+ liveKeyboardHeight.value = e.height;
146
+ },
147
+ onEnd: e => {
148
+ 'worklet';
149
+
150
+ liveKeyboardHeight.value = e.height;
151
+ }
152
+ }, []);
102
153
  const rowRefsMap = useRef(new Map());
103
154
  // Set on a real touch-drag (`onScrollBeginDrag`), before onStartReached/
104
155
  // onEndReached's threshold could fire. `onMomentumScrollBegin` was tried
@@ -341,6 +392,14 @@ export const ChatListLegend = /*#__PURE__*/memo(({
341
392
  hasUserScrolledRef.current = true;
342
393
  }, []);
343
394
  const handleScroll = useCallback(e => {
395
+ // The keyboard-following loop re-pins to the end on every frame, so
396
+ // the list is at the bottom for the whole transition by construction.
397
+ // The intermediate events it produces are not: content size and
398
+ // offset move a frame apart, and a reading taken between them says
399
+ // "not at bottom" and latches the scroll-to-bottom button on. The
400
+ // loop only runs when the list was already at the bottom, so there is
401
+ // nothing here to detect while it does.
402
+ if (isFollowingKeyboardRef.current) return;
344
403
  const {
345
404
  contentOffset,
346
405
  contentSize,
@@ -380,6 +439,13 @@ export const ChatListLegend = /*#__PURE__*/memo(({
380
439
  isAtBottomRef.current = true;
381
440
  setShowBadge(false);
382
441
  }, [hasMoreNew, onLoadMoreOld, scrollMessageToEnd, buttonOpacity]);
442
+
443
+ // `paddingBottom` here replaces the one `styles.content` sets via
444
+ // `paddingVertical`, so the base spacing has to be added back or the last
445
+ // message ends up flush against the composer.
446
+ const contentContainerStyle = useMemo(() => [styles.content, {
447
+ paddingBottom: CONTENT_PADDING_VERTICAL + keyboardInset
448
+ }], [keyboardInset]);
383
449
  const animatedButtonStyle = useAnimatedStyle(() => ({
384
450
  opacity: buttonOpacity.value,
385
451
  pointerEvents: buttonOpacity.value === 0 ? 'none' : 'auto'
@@ -394,71 +460,157 @@ export const ChatListLegend = /*#__PURE__*/memo(({
394
460
  };
395
461
  }, []);
396
462
 
397
- // Tracks the keyboard's height as the trigger for the re-anchor below.
398
- // The `willHide` side is debounced because Android's event stream flaps
399
- // willShow→willHide→willShow roughly every 1.3s for as long as the
400
- // keyboard stays open (measured on device) — without this, every flap
401
- // would fire another scroll. A real close still lands, just one tick
402
- // later. Setting the same height twice is a no-op for the effect below,
403
- // so a stable open only ever re-anchors once.
463
+ // Reserves the keyboard's room on the content and keeps the list pinned
464
+ // to the end for the length of each keyboard transition.
404
465
  //
405
- // JS-thread only (no worklet), so none of the reentrant-lock crash risk
406
- // that reaching into `useKeyboardHandler`'s worklets carries.
466
+ // JS thread only: no worklet, so none of the reentrant-lock crash risk
467
+ // that reaching into `useKeyboardHandler`'s worklets carries. The one
468
+ // worklet involved only writes `liveKeyboardHeight`, which this reads.
407
469
  useEffect(() => {
408
- let pendingHide;
409
- const clearPendingHide = () => {
410
- if (pendingHide) {
411
- clearTimeout(pendingHide);
412
- pendingHide = undefined;
470
+ let pendingSettle;
471
+ let pendingFrame;
472
+ const clearPending = () => {
473
+ if (pendingSettle) {
474
+ clearTimeout(pendingSettle);
475
+ pendingSettle = undefined;
476
+ }
477
+ if (pendingFrame !== undefined) {
478
+ cancelAnimationFrame(pendingFrame);
479
+ pendingFrame = undefined;
413
480
  }
481
+ isFollowingKeyboardRef.current = false;
414
482
  };
415
- const applyInset = nextInset => {
416
- // Android only: the bottom inset the library applies there is a
417
- // synthetic prop that `onScroll` does not report (its own
418
- // `ScrollViewWithBottomPadding` says as much), so LegendList never
419
- // learns about it, `alignItemsAtEndPadding` never shrinks, and the
420
- // re-anchor below has no room to scroll into. Reporting it closes
421
- // that gap. iOS needs none of this — there the inset is real and
422
- // arrives through `onScroll` on its own, and overriding it here
423
- // would double-count.
424
- if (Platform.OS === 'android') {
425
- listRef.current?.reportContentInset(nextInset > 0 ? {
426
- bottom: nextInset
427
- } : null);
483
+
484
+ // Follows the keyboard frame by frame instead of setting the reserved
485
+ // room in one step.
486
+ //
487
+ // Set in one step the layout lift lands in a single frame — measured,
488
+ // 72 of the 302px the content had to travel arrived as an instant jump
489
+ // while only the remaining 230 were animated, and `scrollToEnd`'s own
490
+ // ~324ms curve then finished about 100ms after the keyboard had already
491
+ // stopped. Sampling `liveKeyboardHeight` each frame instead means the
492
+ // padding, and with it the content, is wherever the keyboard actually
493
+ // is — no easing curve to guess at, and the two cannot drift apart.
494
+ //
495
+ // `duration` is only a bound, for a transition whose reported height
496
+ // never quite reaches the event's target.
497
+ const followKeyboard = (to, duration) => {
498
+ const startedAt = Date.now();
499
+ const startedFrom = Math.max(Math.abs(liveKeyboardHeight.value) - keyboardOffset, 0);
500
+ let tailFrames = 0;
501
+ isFollowingKeyboardRef.current = true;
502
+ const step = () => {
503
+ const live = Math.max(Math.abs(liveKeyboardHeight.value) - keyboardOffset, 0);
504
+ // Tracks the keyboard rather than a timer, so the content never
505
+ // keeps travelling after the keyboard has stopped. The elapsed
506
+ // check is only a fallback for a transition whose reported height
507
+ // never quite reaches the target.
508
+ const reached = Math.abs(live - to) <= 1;
509
+ const timedOut = !reached && Date.now() - startedAt >= duration + FOLLOW_FALLBACK_MS;
510
+ // Whether the keyboard moved at all decides what a timeout means. A
511
+ // `keyboardWillHide` the keyboard does not act on leaves the live
512
+ // height exactly where it was, and forcing the target there would
513
+ // collapse the room out from under a keyboard that is still up —
514
+ // which is what the old hide debounce was guarding against, at the
515
+ // cost of the list dropping a beat after the keyboard had gone. A
516
+ // real transition that merely stops a few px short of the height
517
+ // the event reported (iOS, measured ~4px) still has to land exactly
518
+ // on the target.
519
+ const moved = Math.abs(live - startedFrom) > 1;
520
+ if (reached) {
521
+ tailFrames += 1;
522
+ }
523
+ const done = timedOut || tailFrames >= FOLLOW_TAIL_FRAMES;
524
+ const settleTo = reached || timedOut && moved ? to : live;
525
+ setKeyboardInset(settleTo);
526
+ if (settleTo !== to) {
527
+ // Record what the room actually ended up as, or the dedupe in
528
+ // `applyInset` would swallow the next real transition to `to`.
529
+ keyboardInsetRef.current = settleTo;
530
+ }
531
+ // Re-pin every frame. Growing the padding only moves the content on
532
+ // its own while there is `alignItemsAtEndPadding` left to absorb
533
+ // it; once that is gone — any conversation taller than the viewport
534
+ // — the padding just extends the range and nothing moves until
535
+ // something scrolls, and `maintainScrollAtEnd` does not follow a
536
+ // content size change frame by frame (measured: one scroll event,
537
+ // at the very end). Unanimated on purpose: the keyboard is the
538
+ // animation, and an animated scroll here would start a second curve
539
+ // on top of it every frame.
540
+ listRef.current?.scrollToEnd({
541
+ animated: false
542
+ });
543
+ if (done) {
544
+ pendingFrame = undefined;
545
+ // The loop only runs from a list that was at the bottom and it
546
+ // has just pinned it there again, so record that rather than
547
+ // waiting to re-derive it from a scroll event.
548
+ isAtBottomRef.current = true;
549
+ buttonOpacity.value = withTiming(0, BUTTON_FADE_CONFIG);
550
+ setShowBadge(false);
551
+ pendingSettle = setTimeout(() => {
552
+ pendingSettle = undefined;
553
+ isFollowingKeyboardRef.current = false;
554
+ }, FOLLOW_SETTLE_MS);
555
+ return;
556
+ }
557
+ pendingFrame = requestAnimationFrame(step);
558
+ };
559
+ pendingFrame = requestAnimationFrame(step);
560
+ };
561
+ const applyInset = (nextInset, duration) => {
562
+ // Android's event stream flaps willShow -> willHide -> willShow every
563
+ // ~1.3s for as long as the keyboard stays open (measured), so a
564
+ // repeated height must not restart the follow loop.
565
+ if (keyboardInsetRef.current === nextInset) return;
566
+ keyboardInsetRef.current = nextInset;
567
+
568
+ // Reserve the keyboard's room as real bottom padding on the content
569
+ // and let LegendList own it end to end. The native `contentInset` is
570
+ // switched off (see `keyboardOffset` on the list below), so this is
571
+ // the only thing compensating for the keyboard.
572
+ //
573
+ // The point is an invariant, not an offset: the scroll view's
574
+ // maximum content offset has to BE the visually correct position.
575
+ // Otherwise there is a band of legal resting offsets that all look
576
+ // wrong, and a drag settles somewhere inside it — which is the blank
577
+ // gap above the composer.
578
+ //
579
+ // A native inset cannot hold that invariant here. It widens the
580
+ // scroll range by the full keyboard height, but LegendList
581
+ // independently shrinks `alignItemsAtEndPadding` by the same amount
582
+ // and lifts the content through layout as well. Measured on a short
583
+ // conversation: the layout lift covered 258 of the 302 needed, so
584
+ // only 44 of scrolling was left to do while the range still ran to
585
+ // 302 — 258px of pure slack. As content padding the same 302 goes
586
+ // into `contentSize`, so `alignItemsAtEndPadding` falls out to zero,
587
+ // the range is exactly the lift required, and `scrollToEnd` (which
588
+ // reads LegendList's own metrics, and already offsets itself by
589
+ // `stylePaddingBottom`) lands on it.
590
+ //
591
+ // Skipped when the user has scrolled away from the bottom — opening
592
+ // the keyboard shouldn't yank them back down — but the padding still
593
+ // has to change, or the range would be wrong for them too.
594
+ if (!isAtBottomRef.current) {
595
+ setKeyboardInset(nextInset);
596
+ return;
428
597
  }
429
- setKeyboardInset(nextInset);
598
+ followKeyboard(nextInset, duration);
430
599
  };
431
600
  const willShow = KeyboardEvents.addListener('keyboardWillShow', e => {
432
- clearPendingHide();
433
- applyInset(Math.max(e.height - keyboardOffset, 0));
601
+ clearPending();
602
+ applyInset(Math.max(e.height - keyboardOffset, 0), e.duration);
434
603
  });
435
- const willHide = KeyboardEvents.addListener('keyboardWillHide', () => {
436
- clearPendingHide();
437
- pendingHide = setTimeout(() => applyInset(0), KEYBOARD_HIDE_DEBOUNCE_MS);
604
+ const willHide = KeyboardEvents.addListener('keyboardWillHide', e => {
605
+ clearPending();
606
+ applyInset(0, e.duration);
438
607
  });
439
608
  return () => {
440
- clearPendingHide();
609
+ clearPending();
441
610
  willShow.remove();
442
611
  willHide.remove();
443
612
  };
444
- }, [keyboardOffset, listRef]);
445
-
446
- // Re-anchors to the end once the keyboard's inset has landed, which puts
447
- // the last message at exactly the spacing the closed-keyboard layout has
448
- // (verified on device against both a 7-message and a long conversation).
449
- // Skipped when the user has scrolled away from the bottom — opening the
450
- // keyboard shouldn't yank them back down.
451
- useEffect(() => {
452
- if (!hasSeenFirstKeyboardInsetRef.current) {
453
- hasSeenFirstKeyboardInsetRef.current = true;
454
- return;
455
- }
456
- if (!isAtBottomRef.current) return;
457
- scrollMessageToEnd({
458
- animated: true,
459
- closeKeyboard: false
460
- });
461
- }, [keyboardInset, scrollMessageToEnd]);
613
+ }, [buttonOpacity, keyboardOffset, listRef, liveKeyboardHeight]);
462
614
 
463
615
  // This component can stay mounted across a conversationId change (e.g.
464
616
  // navigation.replace reusing the same screen instance), so this ref must
@@ -576,22 +728,28 @@ export const ChatListLegend = /*#__PURE__*/memo(({
576
728
  ,
577
729
  drawDistance: 800,
578
730
  freeze: freeze,
579
- keyboardOffset: keyboardOffset
580
- // The list's own keyboard compensation is off on both platforms —
581
- // measured, it overshoots badly either way. On iOS it scrolls on
582
- // top of React Native's `automaticallyAdjustContentInsets` (which
583
- // already insets the scroll view by the full keyboard height), and
584
- // that double lift is the blank gap. On Android it overshot by
585
- // ~690px against a 128px target. What both platforms do keep from
586
- // the library is the bottom inset it sets, which is the room the
587
- // re-anchor above scrolls into.
731
+ keyboardOffset: DISABLE_NATIVE_KEYBOARD_INSET
732
+ // iOS only. Left on, React Native recomputes and applies its own
733
+ // `contentInset` every time the keyboard moves — measured here as
734
+ // {top: 59, bottom: keyboardHeight}, both wrong. The bottom value
735
+ // over-insets by the safe area, and the phantom top one is worse:
736
+ // iOS rests a scroll view at `-contentInset.top`.
737
+ // That resting offset is what put the content 59pt low and hid the
738
+ // last message behind the composer the moment a touch let UIKit
739
+ // re-clamp. legend-list's own KeyboardAvoidingLegendList disables
740
+ // this for the same reason.
741
+ ,
742
+ automaticallyAdjustContentInsets: false
743
+ // No scroll shift from the library either — the content padding
744
+ // above is the single compensator. Measured with it on: a 302px
745
+ // keyboard produced a 604px lift, exactly double.
588
746
  ,
589
747
  keyboardLiftBehavior: "never",
590
748
  scrollEventThrottle: 16,
591
749
  onScroll: handleScroll,
592
750
  onScrollBeginDrag: handleScrollBeginDrag,
593
751
  onLoad: handleListLoad,
594
- contentContainerStyle: styles.content,
752
+ contentContainerStyle: contentContainerStyle,
595
753
  scrollIndicatorInsets: {
596
754
  right: 1
597
755
  },
@@ -636,7 +794,7 @@ const styles = StyleSheet.create({
636
794
  position: 'relative'
637
795
  },
638
796
  content: {
639
- paddingVertical: KSpacingValue['0.75rem'],
797
+ paddingVertical: CONTENT_PADDING_VERTICAL,
640
798
  flexGrow: 1
641
799
  },
642
800
  scrollToBottomButton: {