@droppii-org/chat-mobile 0.2.86 → 0.2.88

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 (61) hide show
  1. package/lib/module/core/useChatListener.js +4 -0
  2. package/lib/module/core/useChatListener.js.map +1 -1
  3. package/lib/module/hooks/contacts/useSearchContacts.js +3 -2
  4. package/lib/module/hooks/contacts/useSearchContacts.js.map +1 -1
  5. package/lib/module/hooks/groups/useDismissGroup.js +6 -0
  6. package/lib/module/hooks/groups/useDismissGroup.js.map +1 -1
  7. package/lib/module/hooks/groups/useFetchPublicGroup.js +3 -2
  8. package/lib/module/hooks/groups/useFetchPublicGroup.js.map +1 -1
  9. package/lib/module/hooks/groups/useGroupAccessGuard.js +6 -0
  10. package/lib/module/hooks/groups/useGroupAccessGuard.js.map +1 -1
  11. package/lib/module/hooks/groups/useLeaveGroup.js +9 -2
  12. package/lib/module/hooks/groups/useLeaveGroup.js.map +1 -1
  13. package/lib/module/hooks/message/useSearchMessage.js +3 -2
  14. package/lib/module/hooks/message/useSearchMessage.js.map +1 -1
  15. package/lib/module/screens/SearchConversation/SearchAllResult.js +29 -22
  16. package/lib/module/screens/SearchConversation/SearchAllResult.js.map +1 -1
  17. package/lib/module/screens/SearchConversation/SearchCommunityResult.js +3 -2
  18. package/lib/module/screens/SearchConversation/SearchCommunityResult.js.map +1 -1
  19. package/lib/module/screens/SearchConversation/SearchContactsResult.js +4 -2
  20. package/lib/module/screens/SearchConversation/SearchContactsResult.js.map +1 -1
  21. package/lib/module/screens/SearchConversation/SearchMessagesResult.js +4 -2
  22. package/lib/module/screens/SearchConversation/SearchMessagesResult.js.map +1 -1
  23. package/lib/module/screens/SearchConversation/TabResult.js +10 -5
  24. package/lib/module/screens/SearchConversation/TabResult.js.map +1 -1
  25. package/lib/module/utils/groupExit.js +25 -0
  26. package/lib/module/utils/groupExit.js.map +1 -0
  27. package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
  28. package/lib/typescript/src/hooks/contacts/useSearchContacts.d.ts +2 -1
  29. package/lib/typescript/src/hooks/contacts/useSearchContacts.d.ts.map +1 -1
  30. package/lib/typescript/src/hooks/groups/useDismissGroup.d.ts.map +1 -1
  31. package/lib/typescript/src/hooks/groups/useFetchPublicGroup.d.ts +1 -1
  32. package/lib/typescript/src/hooks/groups/useFetchPublicGroup.d.ts.map +1 -1
  33. package/lib/typescript/src/hooks/groups/useGroupAccessGuard.d.ts.map +1 -1
  34. package/lib/typescript/src/hooks/groups/useLeaveGroup.d.ts.map +1 -1
  35. package/lib/typescript/src/hooks/message/useSearchMessage.d.ts +2 -1
  36. package/lib/typescript/src/hooks/message/useSearchMessage.d.ts.map +1 -1
  37. package/lib/typescript/src/screens/SearchConversation/SearchAllResult.d.ts +2 -1
  38. package/lib/typescript/src/screens/SearchConversation/SearchAllResult.d.ts.map +1 -1
  39. package/lib/typescript/src/screens/SearchConversation/SearchCommunityResult.d.ts +2 -1
  40. package/lib/typescript/src/screens/SearchConversation/SearchCommunityResult.d.ts.map +1 -1
  41. package/lib/typescript/src/screens/SearchConversation/SearchContactsResult.d.ts +2 -1
  42. package/lib/typescript/src/screens/SearchConversation/SearchContactsResult.d.ts.map +1 -1
  43. package/lib/typescript/src/screens/SearchConversation/SearchMessagesResult.d.ts +2 -1
  44. package/lib/typescript/src/screens/SearchConversation/SearchMessagesResult.d.ts.map +1 -1
  45. package/lib/typescript/src/screens/SearchConversation/TabResult.d.ts.map +1 -1
  46. package/lib/typescript/src/utils/groupExit.d.ts +4 -0
  47. package/lib/typescript/src/utils/groupExit.d.ts.map +1 -0
  48. package/package.json +2 -2
  49. package/src/core/useChatListener.ts +4 -0
  50. package/src/hooks/contacts/useSearchContacts.ts +3 -1
  51. package/src/hooks/groups/useDismissGroup.tsx +8 -0
  52. package/src/hooks/groups/useFetchPublicGroup.ts +2 -1
  53. package/src/hooks/groups/useGroupAccessGuard.ts +6 -0
  54. package/src/hooks/groups/useLeaveGroup.tsx +12 -2
  55. package/src/hooks/message/useSearchMessage.ts +3 -1
  56. package/src/screens/SearchConversation/SearchAllResult.tsx +25 -15
  57. package/src/screens/SearchConversation/SearchCommunityResult.tsx +7 -2
  58. package/src/screens/SearchConversation/SearchContactsResult.tsx +7 -1
  59. package/src/screens/SearchConversation/SearchMessagesResult.tsx +7 -1
  60. package/src/screens/SearchConversation/TabResult.tsx +7 -0
  61. package/src/utils/groupExit.ts +26 -0
@@ -18,6 +18,7 @@ import { SearchConversationTabResultType } from './types';
18
18
  interface ISearchContactsResultProps {
19
19
  searchTerm: string;
20
20
  onPressSearchContact?: (item: IContactSearchItem) => void;
21
+ isActive?: boolean;
21
22
  }
22
23
 
23
24
  const FILTER_ITEMS: KTagsChoiceSlideBarItemProps[] = [
@@ -44,7 +45,11 @@ const FILTER_ITEMS: KTagsChoiceSlideBarItemProps[] = [
44
45
  ];
45
46
 
46
47
  const SearchContactsResult = memo(
47
- ({ searchTerm, onPressSearchContact }: ISearchContactsResultProps) => {
48
+ ({
49
+ searchTerm,
50
+ onPressSearchContact,
51
+ isActive = true,
52
+ }: ISearchContactsResultProps) => {
48
53
  const { applicationType } = useChatContext();
49
54
  const [contactType, setContactType] = useState<
50
55
  ContactCategory | undefined
@@ -62,6 +67,7 @@ const SearchContactsResult = memo(
62
67
  query: searchTerm,
63
68
  applicationType,
64
69
  type: contactType,
70
+ enabled: isActive,
65
71
  });
66
72
 
67
73
  const onFilterChanged = useCallback(
@@ -11,9 +11,14 @@ import { SearchEmpty } from './SearchEmpty';
11
11
  interface ISearchMessagesResultProps {
12
12
  searchTerm: string;
13
13
  onPressItem?: (item: ISearchMessageItem) => void;
14
+ isActive?: boolean;
14
15
  }
15
16
  const SearchMessagesResult = memo(
16
- ({ searchTerm, onPressItem }: ISearchMessagesResultProps) => {
17
+ ({
18
+ searchTerm,
19
+ onPressItem,
20
+ isActive = true,
21
+ }: ISearchMessagesResultProps) => {
17
22
  const { applicationType } = useChatContext();
18
23
  const {
19
24
  dataFlatten,
@@ -26,6 +31,7 @@ const SearchMessagesResult = memo(
26
31
  } = useSearchMessage({
27
32
  query: searchTerm,
28
33
  applicationType,
34
+ enabled: isActive,
29
35
  });
30
36
 
31
37
  const renderItem = useCallback(
@@ -87,6 +87,7 @@ const SearchConversationTabResult = memo(
87
87
 
88
88
  const renderScene = useCallback(
89
89
  ({ route }: { route: TabRoute }) => {
90
+ const isActive = route.key === routes[index]?.key;
90
91
  switch (route.key) {
91
92
  case SearchConversationTabResultType.All:
92
93
  return (
@@ -95,6 +96,7 @@ const SearchConversationTabResult = memo(
95
96
  handleChangeTab={handleChangeTab}
96
97
  onPressItem={onPressItem}
97
98
  onPressSearchContact={onPressSearchContact}
99
+ isActive={isActive}
98
100
  />
99
101
  );
100
102
  case SearchConversationTabResultType.Conversations:
@@ -102,6 +104,7 @@ const SearchConversationTabResult = memo(
102
104
  <SearchContactsResult
103
105
  searchTerm={searchTerm}
104
106
  onPressSearchContact={onPressSearchContact}
107
+ isActive={isActive}
105
108
  />
106
109
  );
107
110
  case SearchConversationTabResultType.Messages:
@@ -109,6 +112,7 @@ const SearchConversationTabResult = memo(
109
112
  <SearchMessagesResult
110
113
  searchTerm={searchTerm}
111
114
  onPressItem={onPressItem}
115
+ isActive={isActive}
112
116
  />
113
117
  );
114
118
  case SearchConversationTabResultType.Community:
@@ -116,6 +120,7 @@ const SearchConversationTabResult = memo(
116
120
  <SearchCommunityResult
117
121
  searchTerm={searchTerm}
118
122
  onPressGroup={onPressGroup}
123
+ isActive={isActive}
119
124
  />
120
125
  );
121
126
  default:
@@ -128,6 +133,8 @@ const SearchConversationTabResult = memo(
128
133
  onPressItem,
129
134
  onPressSearchContact,
130
135
  onPressGroup,
136
+ index,
137
+ routes,
131
138
  ]
132
139
  );
133
140
 
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Groups this user deliberately left or dismissed.
3
+ *
4
+ * Leaving fires the same SDK callbacks as being removed by someone else, and
5
+ * the `reason` on ChatEvent.GroupRemoved cannot tell them apart —
6
+ * OnJoinedGroupDeleted reports a self-initiated quit and a kick identically.
7
+ * The access guard needs the distinction: losing access is worth a modal, but
8
+ * walking out is not — the screen that asked for it is already navigating away,
9
+ * so a modal would land on the inbox the user just arrived at.
10
+ *
11
+ * Cleared on rejoin, so a later involuntary removal of the same group is
12
+ * treated as one. Deliberately not time-based: a timer would make correctness
13
+ * depend on how fast the SDK round-trips.
14
+ */
15
+ const selfExitedGroups = new Set<string>();
16
+
17
+ export const markSelfExitedGroup = (groupID: string): void => {
18
+ if (groupID) selfExitedGroups.add(groupID);
19
+ };
20
+
21
+ export const clearSelfExitedGroup = (groupID: string): void => {
22
+ selfExitedGroups.delete(groupID);
23
+ };
24
+
25
+ export const wasSelfExitedGroup = (groupID: string): boolean =>
26
+ selfExitedGroups.has(groupID);