@messenger-box/tailwind-ui-inbox 10.0.3-alpha.67 → 10.0.3-alpha.70
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/CHANGELOG.md +8 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts +10 -7
- package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -1
- package/lib/components/InboxMessage/ConversationItem.js +58 -77
- package/lib/components/InboxMessage/ConversationItem.js.map +1 -1
- package/lib/components/InboxMessage/LeftSidebar.d.ts +2 -1
- package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -1
- package/lib/components/InboxMessage/LeftSidebar.js +15 -8
- package/lib/components/InboxMessage/LeftSidebar.js.map +1 -1
- package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -1
- package/lib/components/InboxMessage/MessageInput.js +15 -1
- package/lib/components/InboxMessage/MessageInput.js.map +1 -1
- package/lib/components/InboxMessage/Messages.d.ts.map +1 -1
- package/lib/components/InboxMessage/Messages.js +48 -13
- package/lib/components/InboxMessage/Messages.js.map +1 -1
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +12 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +134 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -1
- package/lib/components/slot-fill/chat-message-filler.js +1 -1
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -1
- package/lib/container/Inbox.d.ts.map +1 -1
- package/lib/container/Inbox.js +188 -60
- package/lib/container/Inbox.js.map +1 -1
- package/lib/container/InboxWithLoader.d.ts +10 -3
- package/lib/container/InboxWithLoader.d.ts.map +1 -1
- package/lib/container/InboxWithLoader.js +81 -30
- package/lib/container/InboxWithLoader.js.map +1 -1
- package/lib/container/ServiceInbox.js +1 -1
- package/lib/container/ServiceInbox.js.map +1 -1
- package/lib/container/ThreadMessages.js +1 -1
- package/lib/container/ThreadMessages.js.map +1 -1
- package/lib/container/ThreadMessagesInbox.js +1 -1
- package/lib/container/ThreadMessagesInbox.js.map +1 -1
- package/lib/container/Threads.js +1 -1
- package/lib/container/Threads.js.map +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -4
- package/src/components/InboxMessage/ConversationItem.tsx +188 -186
- package/src/components/InboxMessage/LeftSidebar.tsx +20 -11
- package/src/components/InboxMessage/MessageInput.tsx +16 -1
- package/src/components/InboxMessage/Messages.tsx +48 -11
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +208 -0
- package/src/components/InboxMessage/message-widgets/index.ts +1 -0
- package/src/container/Inbox.tsx +194 -66
- package/src/container/InboxWithLoader.tsx +104 -38
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useMemo, useCallback } from 'react';
|
|
2
2
|
import { useParams, useLocation } from '@remix-run/react';
|
|
3
3
|
|
|
4
4
|
// import AddGovernmentId from './AddGovernmentId';
|
|
5
5
|
import Inbox from './Inbox';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useGetChannelsByUserQuery,
|
|
8
|
+
useGetChannelsByUserWithLastMessageQuery,
|
|
9
|
+
useMessagesQuery,
|
|
10
|
+
useViewChannelDetailQuery,
|
|
11
|
+
} from 'common/graphql';
|
|
7
12
|
import { RoomType } from 'common';
|
|
8
13
|
import { config } from '../config';
|
|
9
14
|
|
|
10
15
|
const { MESSAGES_PER_PAGE } = config;
|
|
11
16
|
|
|
12
|
-
//
|
|
13
|
-
export const queryParamsGenerator = (params
|
|
17
|
+
// Enhanced query parameters generator with better typing and flexibility
|
|
18
|
+
export const queryParamsGenerator = (params: {
|
|
19
|
+
role?: string;
|
|
20
|
+
criteria?: Record<string, any>;
|
|
21
|
+
supportServices?: boolean;
|
|
22
|
+
orgName?: string;
|
|
23
|
+
}) => ({
|
|
14
24
|
variable1: {
|
|
15
25
|
role: params.role,
|
|
16
|
-
criteria:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type: RoomType.Service,
|
|
26
|
+
criteria: {
|
|
27
|
+
...params.criteria,
|
|
28
|
+
...(params.orgName && { orgName: params.orgName }),
|
|
20
29
|
},
|
|
30
|
+
supportServices: params.supportServices ? true : false,
|
|
31
|
+
supportServiceCriteria: params.supportServices
|
|
32
|
+
? {
|
|
33
|
+
type: RoomType.Service,
|
|
34
|
+
}
|
|
35
|
+
: undefined,
|
|
21
36
|
orderBy: {
|
|
22
37
|
lastPostAt: 'desc',
|
|
23
38
|
},
|
|
@@ -172,28 +187,35 @@ const InboxWithLoader = (props: InboxWithLoaderProps) => {
|
|
|
172
187
|
const { channelFilters: channelFilterProp, channelRole: channelRoleProp, supportServices, pathPrefix } = props;
|
|
173
188
|
const { orgName, channelRole: channelRoleParam } = useParams();
|
|
174
189
|
const channelRole = channelRoleParam || channelRoleProp;
|
|
175
|
-
|
|
190
|
+
|
|
176
191
|
// Create new props object with orgName instead of mutating original props
|
|
177
|
-
const inboxProps =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
192
|
+
const inboxProps = useMemo(
|
|
193
|
+
() => ({
|
|
194
|
+
...props,
|
|
195
|
+
orgName: orgName || '',
|
|
196
|
+
pathPrefix: pathPrefix || '',
|
|
197
|
+
}),
|
|
198
|
+
[props, orgName, pathPrefix],
|
|
199
|
+
);
|
|
182
200
|
|
|
183
201
|
const { id: pathChannelId } = useParams();
|
|
184
202
|
|
|
185
|
-
//
|
|
186
|
-
const channelsQueryVariables = useMemo(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
// Enhanced query variables with better filtering and stable references
|
|
204
|
+
const channelsQueryVariables = useMemo(() => {
|
|
205
|
+
const channelFilters = { ...channelFilterProp };
|
|
206
|
+
const channelType = channelFilters?.type ?? RoomType.Direct;
|
|
207
|
+
const baseFilters = {
|
|
208
|
+
...channelFilters,
|
|
209
|
+
type: supportServices ? [channelType, RoomType.Service] : channelType,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
return queryParamsGenerator({
|
|
213
|
+
role: channelRole,
|
|
214
|
+
criteria: baseFilters,
|
|
215
|
+
supportServices,
|
|
216
|
+
orgName: orgName || '',
|
|
217
|
+
}).variable1;
|
|
218
|
+
}, [channelRole, channelFilterProp, supportServices, orgName]);
|
|
197
219
|
|
|
198
220
|
const messagesQueryVariables = useMemo(
|
|
199
221
|
() => ({
|
|
@@ -211,43 +233,67 @@ const InboxWithLoader = (props: InboxWithLoaderProps) => {
|
|
|
211
233
|
[pathChannelId],
|
|
212
234
|
);
|
|
213
235
|
|
|
214
|
-
// Apollo queries with
|
|
236
|
+
// Enhanced Apollo queries with better cache policies and error handling
|
|
215
237
|
const channelsQuery = useGetChannelsByUserQuery({
|
|
216
238
|
variables: channelsQueryVariables,
|
|
217
|
-
fetchPolicy: 'cache-
|
|
239
|
+
fetchPolicy: 'cache-and-network', // Better for real-time updates
|
|
218
240
|
errorPolicy: 'all',
|
|
219
|
-
notifyOnNetworkStatusChange:
|
|
220
|
-
// Enable optimistic updates and real-time subscriptions
|
|
241
|
+
notifyOnNetworkStatusChange: false,
|
|
221
242
|
returnPartialData: true,
|
|
243
|
+
// Add context for better cache management
|
|
244
|
+
context: {
|
|
245
|
+
cacheKey: 'channels-list',
|
|
246
|
+
},
|
|
222
247
|
});
|
|
223
248
|
|
|
224
249
|
const messagesQuery = useMessagesQuery({
|
|
225
250
|
variables: messagesQueryVariables,
|
|
226
251
|
skip: !pathChannelId,
|
|
227
|
-
fetchPolicy: 'cache-and-network', //
|
|
252
|
+
fetchPolicy: 'cache-and-network', // Better for real-time messaging
|
|
228
253
|
errorPolicy: 'all',
|
|
229
254
|
notifyOnNetworkStatusChange: true,
|
|
230
255
|
returnPartialData: true,
|
|
231
|
-
//
|
|
232
|
-
pollInterval:
|
|
256
|
+
// Disable polling to allow subscriptions to work properly
|
|
257
|
+
pollInterval: 0,
|
|
258
|
+
// Add context for better cache management
|
|
259
|
+
context: {
|
|
260
|
+
cacheKey: 'messages-list',
|
|
261
|
+
},
|
|
233
262
|
});
|
|
234
263
|
|
|
235
264
|
const channelDetailQuery = useViewChannelDetailQuery({
|
|
236
265
|
variables: channelDetailQueryVariables,
|
|
237
266
|
skip: !pathChannelId,
|
|
238
|
-
fetchPolicy: 'cache-first',
|
|
267
|
+
fetchPolicy: 'cache-first', // Channel details don't change often
|
|
239
268
|
errorPolicy: 'all',
|
|
240
|
-
notifyOnNetworkStatusChange:
|
|
269
|
+
notifyOnNetworkStatusChange: false, // No need for real-time updates
|
|
241
270
|
returnPartialData: true,
|
|
271
|
+
// Add context for better cache management
|
|
272
|
+
context: {
|
|
273
|
+
cacheKey: 'channel-detail',
|
|
274
|
+
},
|
|
242
275
|
});
|
|
243
276
|
|
|
244
|
-
//
|
|
277
|
+
// Enhanced error handling with retry logic
|
|
278
|
+
const handleRetry = useCallback(() => {
|
|
279
|
+
if (channelsQuery.error) {
|
|
280
|
+
channelsQuery.refetch();
|
|
281
|
+
}
|
|
282
|
+
if (messagesQuery.error) {
|
|
283
|
+
messagesQuery.refetch();
|
|
284
|
+
}
|
|
285
|
+
if (channelDetailQuery.error) {
|
|
286
|
+
channelDetailQuery.refetch();
|
|
287
|
+
}
|
|
288
|
+
}, [channelsQuery, messagesQuery, channelDetailQuery]);
|
|
289
|
+
|
|
290
|
+
// Create loader data array for Inbox component with better error handling
|
|
245
291
|
const loaderData = useMemo(
|
|
246
292
|
() => [channelsQuery, messagesQuery, channelDetailQuery],
|
|
247
293
|
[channelsQuery, messagesQuery, channelDetailQuery],
|
|
248
294
|
);
|
|
249
295
|
|
|
250
|
-
// Enhanced loading states with
|
|
296
|
+
// Enhanced loading states with better UX
|
|
251
297
|
if (channelsQuery.loading && !pathChannelId && !channelsQuery.data) {
|
|
252
298
|
return <InboxSkeleton showRightSidebar={false} />;
|
|
253
299
|
}
|
|
@@ -262,8 +308,28 @@ const InboxWithLoader = (props: InboxWithLoaderProps) => {
|
|
|
262
308
|
return <InboxSkeleton showRightSidebar={true} />;
|
|
263
309
|
}
|
|
264
310
|
|
|
311
|
+
// Enhanced error handling with retry option
|
|
265
312
|
if (channelsQuery.error && !channelsQuery.data) {
|
|
266
|
-
return
|
|
313
|
+
return (
|
|
314
|
+
<div className="flex flex-col items-center justify-center min-h-screen space-y-4">
|
|
315
|
+
<TailwindAlert>Error loading channels: {channelsQuery.error.message}</TailwindAlert>
|
|
316
|
+
<button
|
|
317
|
+
onClick={handleRetry}
|
|
318
|
+
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
319
|
+
>
|
|
320
|
+
Retry
|
|
321
|
+
</button>
|
|
322
|
+
</div>
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Handle individual query errors gracefully
|
|
327
|
+
if (messagesQuery.error && !messagesQuery.data && pathChannelId) {
|
|
328
|
+
console.warn('Messages query error:', messagesQuery.error);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (channelDetailQuery.error && !channelDetailQuery.data && pathChannelId) {
|
|
332
|
+
console.warn('Channel detail query error:', channelDetailQuery.error);
|
|
267
333
|
}
|
|
268
334
|
|
|
269
335
|
return <Inbox data={loaderData} {...inboxProps} />;
|