@droppii-org/chat-mobile 0.2.75 → 0.2.76
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/components/GroupPermissionGate/GroupPermissionGate.js +33 -0
- package/lib/module/components/GroupPermissionGate/GroupPermissionGate.js.map +1 -0
- package/lib/module/components/GroupPermissionGate/index.js +4 -0
- package/lib/module/components/GroupPermissionGate/index.js.map +1 -0
- package/lib/module/context/ChatDetailContext.js +15 -11
- package/lib/module/context/ChatDetailContext.js.map +1 -1
- package/lib/module/core/useChatListener.js +13 -7
- package/lib/module/core/useChatListener.js.map +1 -1
- package/lib/module/hooks/groups/useDismissGroup.js +79 -0
- package/lib/module/hooks/groups/useDismissGroup.js.map +1 -0
- package/lib/module/hooks/groups/useJoinGroup.js +1 -3
- package/lib/module/hooks/groups/useJoinGroup.js.map +1 -1
- package/lib/module/hooks/useGroupPermission.js +4 -3
- package/lib/module/hooks/useGroupPermission.js.map +1 -1
- package/lib/module/screens/ChatInfo/ChatInfo.js +6 -3
- package/lib/module/screens/ChatInfo/ChatInfo.js.map +1 -1
- package/lib/module/screens/ChatInfo/ChatInfoActions.js +48 -6
- package/lib/module/screens/ChatInfo/ChatInfoActions.js.map +1 -1
- package/lib/module/translation/resources/i18n.js +7 -1
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/typescript/src/components/GroupPermissionGate/GroupPermissionGate.d.ts +19 -0
- package/lib/typescript/src/components/GroupPermissionGate/GroupPermissionGate.d.ts.map +1 -0
- package/lib/typescript/src/components/GroupPermissionGate/index.d.ts +3 -0
- package/lib/typescript/src/components/GroupPermissionGate/index.d.ts.map +1 -0
- package/lib/typescript/src/context/ChatDetailContext.d.ts.map +1 -1
- package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
- package/lib/typescript/src/hooks/groups/useDismissGroup.d.ts +8 -0
- package/lib/typescript/src/hooks/groups/useDismissGroup.d.ts.map +1 -0
- package/lib/typescript/src/hooks/groups/useJoinGroup.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useGroupPermission.d.ts.map +1 -1
- package/lib/typescript/src/screens/ChatInfo/ChatInfo.d.ts +2 -2
- package/lib/typescript/src/screens/ChatInfo/ChatInfo.d.ts.map +1 -1
- package/lib/typescript/src/screens/ChatInfo/ChatInfoActions.d.ts +3 -2
- package/lib/typescript/src/screens/ChatInfo/ChatInfoActions.d.ts.map +1 -1
- package/lib/typescript/src/screens/ChatInfo/types.d.ts +1 -0
- package/lib/typescript/src/screens/ChatInfo/types.d.ts.map +1 -1
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/chat.d.ts +2 -2
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +2 -4
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/GroupPermissionGate/GroupPermissionGate.tsx +51 -0
- package/src/components/GroupPermissionGate/index.ts +5 -0
- package/src/context/ChatDetailContext.tsx +17 -11
- package/src/core/useChatListener.ts +13 -7
- package/src/hooks/groups/useDismissGroup.tsx +80 -0
- package/src/hooks/groups/useJoinGroup.ts +1 -3
- package/src/hooks/useGroupPermission.ts +5 -4
- package/src/screens/ChatInfo/ChatInfo.tsx +4 -1
- package/src/screens/ChatInfo/ChatInfoActions.tsx +79 -32
- package/src/screens/ChatInfo/types.ts +1 -0
- package/src/translation/resources/i18n.ts +7 -0
- package/src/types/chat.ts +2 -2
- package/src/types/events.ts +2 -4
|
@@ -6,9 +6,14 @@ import {
|
|
|
6
6
|
type KListItemBaseItemProps,
|
|
7
7
|
KLabel,
|
|
8
8
|
} from '@droppii/libs';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
GroupMemberRole,
|
|
11
|
+
type ConversationItem,
|
|
12
|
+
} from '@droppii/openim-rn-client-sdk';
|
|
10
13
|
import { usePinConversation } from '../../hooks/usePinConversation';
|
|
11
14
|
import { trans } from '../../translation';
|
|
15
|
+
import { useChatDetailContext } from '../../context';
|
|
16
|
+
import { useDismissGroup } from '../../hooks/groups/useDismissGroup';
|
|
12
17
|
|
|
13
18
|
interface ChatInfoActionsProps {
|
|
14
19
|
conversation?: ConversationItem;
|
|
@@ -18,6 +23,7 @@ interface ChatInfoActionsProps {
|
|
|
18
23
|
onPressCreateGroup?: () => void;
|
|
19
24
|
onPressAddToGroup?: () => void;
|
|
20
25
|
onPressLeaveGroup?: () => void;
|
|
26
|
+
onDismissGroup?: () => void;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
const ChatInfoActions = memo(
|
|
@@ -29,10 +35,17 @@ const ChatInfoActions = memo(
|
|
|
29
35
|
onPressCreateGroup,
|
|
30
36
|
onPressAddToGroup,
|
|
31
37
|
onPressLeaveGroup,
|
|
38
|
+
onDismissGroup,
|
|
32
39
|
}: ChatInfoActionsProps) => {
|
|
33
40
|
const { pinConversation, unpinConversation } = usePinConversation();
|
|
34
41
|
const isPinned = Boolean(conversation?.isPinned);
|
|
35
42
|
const showName = conversation?.showName || '';
|
|
43
|
+
const { userInfo } = useChatDetailContext();
|
|
44
|
+
const { dismissGroup } = useDismissGroup({ onSuccess: onDismissGroup });
|
|
45
|
+
|
|
46
|
+
const isOwner = useMemo(() => {
|
|
47
|
+
return userInfo?.roleLevel === GroupMemberRole.Owner;
|
|
48
|
+
}, [userInfo?.roleLevel]);
|
|
36
49
|
|
|
37
50
|
const handlePinPress = useCallback(() => {
|
|
38
51
|
if (isPinned) {
|
|
@@ -44,6 +57,11 @@ const ChatInfoActions = memo(
|
|
|
44
57
|
|
|
45
58
|
const handleDeleteHistory = useCallback(() => {}, []);
|
|
46
59
|
|
|
60
|
+
const handleDismissGroup = useCallback(() => {
|
|
61
|
+
if (!conversation?.groupID) return;
|
|
62
|
+
dismissGroup(conversation?.groupID);
|
|
63
|
+
}, [dismissGroup, conversation?.groupID]);
|
|
64
|
+
|
|
47
65
|
const primaryData = useMemo(() => {
|
|
48
66
|
const items: KListItemBaseItemProps[] = [];
|
|
49
67
|
|
|
@@ -118,17 +136,40 @@ const ChatInfoActions = memo(
|
|
|
118
136
|
]);
|
|
119
137
|
|
|
120
138
|
const dangerData: KListItemBaseItemProps[] = useMemo(() => {
|
|
139
|
+
const items: KListItemBaseItemProps[] = [];
|
|
121
140
|
if (isGroup) {
|
|
122
|
-
|
|
123
|
-
{
|
|
141
|
+
items.push({
|
|
142
|
+
leftNode: {
|
|
143
|
+
icon: {
|
|
144
|
+
vectorName: 'logout-o',
|
|
145
|
+
tintColor: KColors.danger.normal,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
tintColor: KColors.danger.normal,
|
|
149
|
+
onPress: onPressLeaveGroup,
|
|
150
|
+
showChevron: false,
|
|
151
|
+
paddingH: '0.75rem',
|
|
152
|
+
paddingV: '0.75rem',
|
|
153
|
+
customLabel: (
|
|
154
|
+
<KLabel.Text
|
|
155
|
+
typo="TextMdMedium"
|
|
156
|
+
color={KColors.danger.normal}
|
|
157
|
+
numberOfLines={1}
|
|
158
|
+
>
|
|
159
|
+
{trans('chat:info_leave_group')}
|
|
160
|
+
</KLabel.Text>
|
|
161
|
+
),
|
|
162
|
+
});
|
|
163
|
+
if (isOwner) {
|
|
164
|
+
items.push({
|
|
124
165
|
leftNode: {
|
|
125
166
|
icon: {
|
|
126
|
-
vectorName: '
|
|
167
|
+
vectorName: 'minus-circle-o',
|
|
127
168
|
tintColor: KColors.danger.normal,
|
|
128
169
|
},
|
|
129
170
|
},
|
|
130
171
|
tintColor: KColors.danger.normal,
|
|
131
|
-
onPress:
|
|
172
|
+
onPress: handleDismissGroup,
|
|
132
173
|
showChevron: false,
|
|
133
174
|
paddingH: '0.75rem',
|
|
134
175
|
paddingV: '0.75rem',
|
|
@@ -138,39 +179,45 @@ const ChatInfoActions = memo(
|
|
|
138
179
|
color={KColors.danger.normal}
|
|
139
180
|
numberOfLines={1}
|
|
140
181
|
>
|
|
141
|
-
{trans('chat:
|
|
182
|
+
{trans('chat:dismiss_group')}
|
|
142
183
|
</KLabel.Text>
|
|
143
184
|
),
|
|
144
|
-
}
|
|
145
|
-
|
|
185
|
+
});
|
|
186
|
+
}
|
|
146
187
|
}
|
|
147
188
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
tintColor: KColors.danger.normal,
|
|
155
|
-
},
|
|
189
|
+
items.push({
|
|
190
|
+
label: trans('chat:info_delete_history'),
|
|
191
|
+
leftNode: {
|
|
192
|
+
icon: {
|
|
193
|
+
vectorName: 'trash-alt-o-1',
|
|
194
|
+
tintColor: KColors.danger.normal,
|
|
156
195
|
},
|
|
157
|
-
tintColor: KColors.danger.normal,
|
|
158
|
-
onPress: handleDeleteHistory,
|
|
159
|
-
showChevron: false,
|
|
160
|
-
paddingH: '0.75rem',
|
|
161
|
-
paddingV: '0.75rem',
|
|
162
|
-
customLabel: (
|
|
163
|
-
<KLabel.Text
|
|
164
|
-
typo="TextMdMedium"
|
|
165
|
-
color={KColors.danger.normal}
|
|
166
|
-
numberOfLines={1}
|
|
167
|
-
>
|
|
168
|
-
{trans('chat:info_delete_history')}
|
|
169
|
-
</KLabel.Text>
|
|
170
|
-
),
|
|
171
196
|
},
|
|
172
|
-
|
|
173
|
-
|
|
197
|
+
tintColor: KColors.danger.normal,
|
|
198
|
+
onPress: handleDeleteHistory,
|
|
199
|
+
showChevron: false,
|
|
200
|
+
paddingH: '0.75rem',
|
|
201
|
+
paddingV: '0.75rem',
|
|
202
|
+
customLabel: (
|
|
203
|
+
<KLabel.Text
|
|
204
|
+
typo="TextMdMedium"
|
|
205
|
+
color={KColors.danger.normal}
|
|
206
|
+
numberOfLines={1}
|
|
207
|
+
>
|
|
208
|
+
{trans('chat:info_delete_history')}
|
|
209
|
+
</KLabel.Text>
|
|
210
|
+
),
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return items;
|
|
214
|
+
}, [
|
|
215
|
+
isGroup,
|
|
216
|
+
onPressLeaveGroup,
|
|
217
|
+
handleDeleteHistory,
|
|
218
|
+
isOwner,
|
|
219
|
+
handleDismissGroup,
|
|
220
|
+
]);
|
|
174
221
|
|
|
175
222
|
return (
|
|
176
223
|
<>
|
|
@@ -124,6 +124,7 @@ const i18nKey: Record<string, string> = {
|
|
|
124
124
|
'chat:info_unpin_message': 'Bỏ ghim trò chuyện',
|
|
125
125
|
'chat:info_delete_history': 'Xoá lịch sử trò chuyện',
|
|
126
126
|
'chat:info_leave_group': 'Rời nhóm',
|
|
127
|
+
'chat:dismiss_group': 'Giải tán nhóm',
|
|
127
128
|
'chat:info_view_more': 'Xem thêm',
|
|
128
129
|
'chat:group_description_title': 'Mô tả nhóm',
|
|
129
130
|
'start': 'Bắt đầu',
|
|
@@ -174,6 +175,12 @@ const i18nKey: Record<string, string> = {
|
|
|
174
175
|
'group:joined_group': 'Đã tham gia nhóm {{groupName}}',
|
|
175
176
|
'group:public_group': 'Nhóm công khai',
|
|
176
177
|
'group:private_group': 'Nhóm riêng tư',
|
|
178
|
+
'group:dismiss_confirm_title': 'Giải tán nhóm?',
|
|
179
|
+
'group:dismiss_confirm_desc':
|
|
180
|
+
'Tất cả thành viên và tin nhắn sẽ bị xoá. Bạn có chắc chắn muốn giải tán nhóm?',
|
|
181
|
+
'group:dismiss_confirm_primary': 'Giải tán',
|
|
182
|
+
'group:dismiss_confirm_secondary': 'Quay lại',
|
|
183
|
+
'group:dismiss_toast_success': 'Đã giải tán nhóm',
|
|
177
184
|
};
|
|
178
185
|
|
|
179
186
|
export default {
|
package/src/types/chat.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GroupPermission,
|
|
3
2
|
MessageType,
|
|
4
3
|
type ConversationItem,
|
|
5
4
|
type MessageItem,
|
|
5
|
+
type SelfUserInfo,
|
|
6
6
|
} from '@droppii/openim-rn-client-sdk';
|
|
7
7
|
import type { PropsWithChildren } from 'react';
|
|
8
8
|
import type { IUrlMetadata } from './common';
|
|
@@ -217,7 +217,7 @@ export interface ChatDetailContextType {
|
|
|
217
217
|
quotedMessage?: MessageItem;
|
|
218
218
|
setQuotedMessage: (item?: MessageItem) => void;
|
|
219
219
|
conversationFlowMainMenu?: InputButtonItem[];
|
|
220
|
-
|
|
220
|
+
userInfo?: SelfUserInfo;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
export interface ChatDetailProviderProps extends PropsWithChildren {}
|
package/src/types/events.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SelfUserInfo } from '@droppii/openim-rn-client-sdk';
|
|
2
2
|
|
|
3
3
|
export enum ChatEvent {
|
|
4
4
|
ScrollToMessage = 'chat:scroll_to_message',
|
|
@@ -16,9 +16,7 @@ export interface MessageRevokedPayload {
|
|
|
16
16
|
clientMsgID: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export
|
|
20
|
-
permissions: GroupPermission[];
|
|
21
|
-
}
|
|
19
|
+
export type GroupPermissionUpdatedPayload = Partial<SelfUserInfo>;
|
|
22
20
|
|
|
23
21
|
export interface GroupRemovedPayload {
|
|
24
22
|
groupID: string;
|