stream-chat-react-native-core 5.0.0-offline-support.0 → 5.0.0-offline-support.3

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 (57) hide show
  1. package/lib/commonjs/components/ChannelList/ChannelList.js +2 -2
  2. package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
  3. package/lib/commonjs/components/ChannelList/hooks/listeners/handleEventToSyncDB.js +2 -47
  4. package/lib/commonjs/components/ChannelList/hooks/listeners/handleEventToSyncDB.js.map +1 -1
  5. package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +2 -2
  6. package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
  7. package/lib/commonjs/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  8. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  9. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  10. package/lib/commonjs/contexts/overlayContext/OverlayProvider.js +12 -16
  11. package/lib/commonjs/contexts/overlayContext/OverlayProvider.js.map +1 -1
  12. package/lib/commonjs/mock-builders/event/memberAdded.js.map +1 -1
  13. package/lib/commonjs/mock-builders/event/memberRemoved.js.map +1 -1
  14. package/lib/commonjs/mock-builders/event/memberUpdated.js.map +1 -1
  15. package/lib/commonjs/mock-builders/event/reactionDeleted.js.map +1 -1
  16. package/lib/commonjs/mock-builders/event/reactionNew.js.map +1 -1
  17. package/lib/commonjs/mock-builders/event/reactionUpdated.js.map +1 -1
  18. package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js +2 -1
  19. package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js.map +1 -1
  20. package/lib/commonjs/version.json +1 -1
  21. package/lib/module/components/ChannelList/ChannelList.js +2 -2
  22. package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
  23. package/lib/module/components/ChannelList/hooks/listeners/handleEventToSyncDB.js +2 -47
  24. package/lib/module/components/ChannelList/hooks/listeners/handleEventToSyncDB.js.map +1 -1
  25. package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +2 -2
  26. package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
  27. package/lib/module/components/ChannelPreview/ChannelAvatar.js.map +1 -1
  28. package/lib/module/components/MessageList/MessageList.js +1 -1
  29. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  30. package/lib/module/contexts/overlayContext/OverlayProvider.js +12 -16
  31. package/lib/module/contexts/overlayContext/OverlayProvider.js.map +1 -1
  32. package/lib/module/mock-builders/event/memberAdded.js.map +1 -1
  33. package/lib/module/mock-builders/event/memberRemoved.js.map +1 -1
  34. package/lib/module/mock-builders/event/memberUpdated.js.map +1 -1
  35. package/lib/module/mock-builders/event/reactionDeleted.js.map +1 -1
  36. package/lib/module/mock-builders/event/reactionNew.js.map +1 -1
  37. package/lib/module/mock-builders/event/reactionUpdated.js.map +1 -1
  38. package/lib/module/store/sqlite-utils/appendWhereCluase.js +2 -1
  39. package/lib/module/store/sqlite-utils/appendWhereCluase.js.map +1 -1
  40. package/lib/module/version.json +1 -1
  41. package/lib/typescript/components/ChannelList/hooks/usePaginatedChannels.d.ts +1 -1
  42. package/package.json +2 -2
  43. package/src/__tests__/offline-feature.test.js +149 -109
  44. package/src/components/ChannelList/ChannelList.tsx +1 -1
  45. package/src/components/ChannelList/hooks/listeners/handleEventToSyncDB.ts +15 -48
  46. package/src/components/ChannelList/hooks/usePaginatedChannels.ts +1 -1
  47. package/src/components/ChannelPreview/ChannelAvatar.tsx +3 -3
  48. package/src/components/MessageList/MessageList.tsx +1 -1
  49. package/src/contexts/overlayContext/OverlayProvider.tsx +0 -3
  50. package/src/mock-builders/event/memberAdded.js +7 -8
  51. package/src/mock-builders/event/memberRemoved.js +7 -8
  52. package/src/mock-builders/event/memberUpdated.js +7 -8
  53. package/src/mock-builders/event/reactionDeleted.js +8 -9
  54. package/src/mock-builders/event/reactionNew.js +8 -9
  55. package/src/mock-builders/event/reactionUpdated.js +8 -9
  56. package/src/store/sqlite-utils/appendWhereCluase.ts +3 -1
  57. package/src/version.json +1 -1
@@ -41,15 +41,18 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
41
41
  if (type === 'message.updated' || type === 'message.deleted') {
42
42
  if (event.message && !event.message.parent_id) {
43
43
  // Update only if it exists, otherwise event could be related
44
- // to a message which is not related to existing messages with database.
44
+ // to a message which is not in database.
45
45
  return updateMessage({
46
46
  flush,
47
47
  message: event.message,
48
48
  });
49
49
  }
50
50
  }
51
+
51
52
  if (type === 'reaction.updated') {
52
53
  if (event.message && event.reaction) {
54
+ // We update the entire message to make sure we also update
55
+ // reaction_counts.
53
56
  updateMessage({
54
57
  flush,
55
58
  message: event.message,
@@ -69,7 +72,12 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
69
72
  }
70
73
  }
71
74
 
72
- if (type === 'channel.updated') {
75
+ if (
76
+ type === 'channel.updated' ||
77
+ type === 'channel.visible' ||
78
+ type === 'notification.added_to_channel' ||
79
+ type === 'notification.message_new'
80
+ ) {
73
81
  if (event.channel) {
74
82
  return upsertChannelData({
75
83
  channel: event.channel,
@@ -78,7 +86,11 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
78
86
  }
79
87
  }
80
88
 
81
- if (type === 'channel.hidden') {
89
+ if (
90
+ type === 'channel.hidden' ||
91
+ type === 'channel.deleted' ||
92
+ type === 'notification.removed_from_channel'
93
+ ) {
82
94
  if (event.channel) {
83
95
  return deleteChannel({
84
96
  cid: event.channel.cid,
@@ -87,15 +99,6 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
87
99
  }
88
100
  }
89
101
 
90
- if (type === 'channel.visible') {
91
- if (event.channel) {
92
- return upsertChannelData({
93
- channel: event.channel,
94
- flush,
95
- });
96
- }
97
- }
98
-
99
102
  if (type === 'channel.truncated') {
100
103
  if (event.channel) {
101
104
  return deleteMessagesForChannel({
@@ -105,15 +108,6 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
105
108
  }
106
109
  }
107
110
 
108
- if (type === 'channel.deleted') {
109
- if (event.channel) {
110
- return deleteChannel({
111
- cid: event.channel.cid,
112
- flush,
113
- });
114
- }
115
- }
116
-
117
111
  if (type === 'channels.queried') {
118
112
  if (event.queriedChannels) {
119
113
  return upsertChannels({
@@ -144,32 +138,5 @@ export const handleEventToSyncDB = (event: Event, flush?: boolean) => {
144
138
  }
145
139
  }
146
140
 
147
- if (type === 'notification.added_to_channel') {
148
- if (event.channel) {
149
- return upsertChannelData({
150
- channel: event.channel,
151
- flush,
152
- });
153
- }
154
- }
155
-
156
- if (type === 'notification.removed_from_channel') {
157
- if (event.channel) {
158
- return deleteChannel({
159
- cid: event.channel.cid,
160
- flush,
161
- });
162
- }
163
- }
164
-
165
- if (type === 'notification.message_new') {
166
- if (event.channel) {
167
- return upsertChannelData({
168
- channel: event.channel,
169
- flush,
170
- });
171
- }
172
- }
173
-
174
141
  return [];
175
142
  };
@@ -205,10 +205,10 @@ export const usePaginatedChannels = <
205
205
  : activeQueryType === 'reload' && channels.length === 0,
206
206
  loadingNextPage: activeQueryType === 'loadChannels',
207
207
  loadNextPage,
208
- staticChannelsActive,
209
208
  refreshing: activeQueryType === 'refresh',
210
209
  refreshList,
211
210
  reloadList,
212
211
  setChannels,
212
+ staticChannelsActive,
213
213
  };
214
214
  };
@@ -10,15 +10,15 @@ import { GroupAvatar } from '../Avatar/GroupAvatar';
10
10
 
11
11
  export type ChannelAvatarProps<
12
12
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
13
- > = Pick<ChannelPreviewProps<StreamChatGenerics>, 'channel'>;
13
+ > = Pick<ChannelPreviewProps<StreamChatGenerics>, 'channel'>;
14
14
 
15
15
  /**
16
16
  * This UI component displays an avatar for a particular channel.
17
17
  */
18
18
  export const ChannelAvatar = <
19
19
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
20
- >(
21
- props: ChannelAvatarProps<StreamChatGenerics>,
20
+ >(
21
+ props: ChannelAvatarProps<StreamChatGenerics>,
22
22
  ) => {
23
23
  const { channel } = props;
24
24
 
@@ -530,7 +530,7 @@ const MessageListWithContext = <
530
530
  index: number;
531
531
  item: MessageType<StreamChatGenerics>;
532
532
  }) => {
533
- if (!channel || !channel.initialized) return null;
533
+ if (!channel || (!channel.initialized && !channel.staticState)) return null;
534
534
 
535
535
  const lastRead = channel.lastRead();
536
536
 
@@ -167,9 +167,6 @@ export const OverlayProvider = <
167
167
  }
168
168
  }, [overlay]);
169
169
 
170
- // Setup translators
171
- useStreami18n({ i18nInstance, setTranslators });
172
-
173
170
  const attachmentPickerContext = {
174
171
  attachmentPickerBottomSheetHeight,
175
172
  attachmentSelectionBarHeight,
@@ -1,9 +1,8 @@
1
1
  export default (client, member, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- member,
6
- type: 'member.added',
7
- });
8
- };
9
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ member,
6
+ type: 'member.added',
7
+ });
8
+ };
@@ -1,9 +1,8 @@
1
1
  export default (client, member, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- member,
6
- type: 'member.removed',
7
- });
8
- };
9
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ member,
6
+ type: 'member.removed',
7
+ });
8
+ };
@@ -1,9 +1,8 @@
1
1
  export default (client, member, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- member,
6
- type: 'member.updated',
7
- });
8
- };
9
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ member,
6
+ type: 'member.updated',
7
+ });
8
+ };
@@ -1,10 +1,9 @@
1
1
  export default (client, reaction, message, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- message,
6
- reaction,
7
- type: 'reaction.deleted',
8
- });
9
- };
10
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ message,
6
+ reaction,
7
+ type: 'reaction.deleted',
8
+ });
9
+ };
@@ -1,10 +1,9 @@
1
1
  export default (client, reaction, message, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- message,
6
- reaction,
7
- type: 'reaction.new',
8
- });
9
- };
10
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ message,
6
+ reaction,
7
+ type: 'reaction.new',
8
+ });
9
+ };
@@ -1,10 +1,9 @@
1
1
  export default (client, reaction, message, channel = {}) => {
2
- client.dispatchEvent({
3
- channel,
4
- cid: channel.cid,
5
- message,
6
- reaction,
7
- type: 'reaction.updated',
8
- });
9
- };
10
-
2
+ client.dispatchEvent({
3
+ channel,
4
+ cid: channel.cid,
5
+ message,
6
+ reaction,
7
+ type: 'reaction.updated',
8
+ });
9
+ };
@@ -12,8 +12,10 @@ export const appendWhereClause = <T extends keyof Schema>(
12
12
 
13
13
  for (const key in whereCondition) {
14
14
  const value: unknown = whereCondition[key];
15
+ if (value === undefined) continue;
16
+
15
17
  if (Array.isArray(value)) {
16
- if (!value || value.length === 0) continue;
18
+ if (value.length === 0) continue;
17
19
  const questionMarks = Array(Object.keys(value).length).fill('?').join(',');
18
20
  whereClause.push(`${key} in (${questionMarks})`);
19
21
  whereParams.push(...value);
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.0.0-offline-support.0"
2
+ "version": "5.0.0-offline-support.3"
3
3
  }