stream-chat-react-native-core 5.38.0-beta.2 → 5.38.0-beta.4
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/commonjs/components/Attachment/Card.js +1 -1
- package/lib/commonjs/components/Attachment/Card.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +5 -1
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/store/apis/getChannels.js +3 -3
- package/lib/commonjs/store/apis/getChannels.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Card.js +1 -1
- package/lib/module/components/Attachment/Card.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +5 -1
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/store/apis/getChannels.js +3 -3
- package/lib/module/store/apis/getChannels.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/offline-support/offline-feature.js +42 -24
- package/src/components/Attachment/Card.tsx +1 -1
- package/src/components/Channel/Channel.tsx +4 -0
- package/src/store/apis/getChannels.ts +3 -3
- package/src/version.json +1 -1
|
@@ -115,7 +115,7 @@ export const Generic = () => {
|
|
|
115
115
|
let allReactions;
|
|
116
116
|
let allReads;
|
|
117
117
|
const getRandomInt = (lower, upper) => Math.floor(lower + Math.random() * (upper - lower + 1));
|
|
118
|
-
const createChannel = () => {
|
|
118
|
+
const createChannel = (messagesOverride) => {
|
|
119
119
|
const id = uuidv4();
|
|
120
120
|
const cid = `messaging:${id}`;
|
|
121
121
|
const begin = getRandomInt(0, allUsers.length - 2); // begin shouldn't be the end of users.length
|
|
@@ -127,31 +127,33 @@ export const Generic = () => {
|
|
|
127
127
|
user,
|
|
128
128
|
}),
|
|
129
129
|
);
|
|
130
|
-
const messages =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
130
|
+
const messages =
|
|
131
|
+
messagesOverride ||
|
|
132
|
+
Array(10)
|
|
133
|
+
.fill(1)
|
|
134
|
+
.map(() => {
|
|
135
|
+
const id = uuidv4();
|
|
136
|
+
const user = usersForMembers[getRandomInt(0, usersForMembers.length - 1)];
|
|
137
|
+
|
|
138
|
+
const begin = getRandomInt(0, usersForMembers.length - 2); // begin shouldn't be the end of users.length
|
|
139
|
+
const end = getRandomInt(begin + 1, usersForMembers.length - 1);
|
|
140
|
+
|
|
141
|
+
const usersForReactions = usersForMembers.slice(begin, end);
|
|
142
|
+
const reactions = usersForReactions.map((user) =>
|
|
143
|
+
generateReaction({
|
|
144
|
+
message_id: id,
|
|
145
|
+
user,
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
allReactions.push(...reactions);
|
|
149
|
+
return generateMessage({
|
|
150
|
+
cid,
|
|
151
|
+
id,
|
|
152
|
+
latest_reactions: reactions,
|
|
143
153
|
user,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
allReactions.push(...reactions);
|
|
147
|
-
return generateMessage({
|
|
148
|
-
cid,
|
|
149
|
-
id,
|
|
150
|
-
latest_reactions: reactions,
|
|
151
|
-
user,
|
|
152
|
-
userId: user.id,
|
|
154
|
+
userId: user.id,
|
|
155
|
+
});
|
|
153
156
|
});
|
|
154
|
-
});
|
|
155
157
|
|
|
156
158
|
const reads = members.map((member) => ({
|
|
157
159
|
last_read: new Date(new Date().setDate(new Date().getDate() - getRandomInt(0, 20))),
|
|
@@ -189,6 +191,7 @@ export const Generic = () => {
|
|
|
189
191
|
afterEach(() => {
|
|
190
192
|
BetterSqlite.dropAllTables();
|
|
191
193
|
cleanup();
|
|
194
|
+
jest.clearAllMocks();
|
|
192
195
|
});
|
|
193
196
|
|
|
194
197
|
const filters = {
|
|
@@ -313,6 +316,21 @@ export const Generic = () => {
|
|
|
313
316
|
expectAllChannelsWithStateToBeInDB(screen.queryAllByLabelText);
|
|
314
317
|
});
|
|
315
318
|
|
|
319
|
+
it('should fetch channels from the db correctly even if they are empty', async () => {
|
|
320
|
+
const emptyChannel = createChannel([]);
|
|
321
|
+
useMockedApis(chatClient, [queryChannelsApi([emptyChannel])]);
|
|
322
|
+
jest.spyOn(chatClient, 'hydrateActiveChannels');
|
|
323
|
+
|
|
324
|
+
renderComponent();
|
|
325
|
+
await act(() => dispatchConnectionChangedEvent(chatClient));
|
|
326
|
+
await waitFor(() => {
|
|
327
|
+
expect(screen.getByTestId('channel-list')).toBeTruthy();
|
|
328
|
+
expect(screen.getByTestId(emptyChannel.cid)).toBeTruthy();
|
|
329
|
+
expect(chatClient.hydrateActiveChannels).toHaveBeenCalledTimes(2);
|
|
330
|
+
expect(chatClient.hydrateActiveChannels.mock.calls[0][0]).toStrictEqual([emptyChannel]);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
316
334
|
it('should add a new message to database', async () => {
|
|
317
335
|
useMockedApis(chatClient, [queryChannelsApi(channels)]);
|
|
318
336
|
|
|
@@ -207,7 +207,7 @@ const CardWithContext = <
|
|
|
207
207
|
imageStyle={styles.cardCover}
|
|
208
208
|
resizeMode='cover'
|
|
209
209
|
source={{ uri: makeImageCompatibleUrl(uri) }}
|
|
210
|
-
style={[styles.cardCover,
|
|
210
|
+
style={[styles.cardCover, stylesProp.cardCover, cover]}
|
|
211
211
|
>
|
|
212
212
|
{isVideoCard ? (
|
|
213
213
|
<View
|
|
@@ -40,9 +40,9 @@ export const getChannels = <
|
|
|
40
40
|
// Enrich the channels with state
|
|
41
41
|
return channels.map((c) => ({
|
|
42
42
|
...mapStorableToChannel<StreamChatGenerics>(c),
|
|
43
|
-
members: cidVsMembers[c.cid],
|
|
44
|
-
messages: cidVsMessages[c.cid],
|
|
43
|
+
members: cidVsMembers[c.cid] || [],
|
|
44
|
+
messages: cidVsMessages[c.cid] || [],
|
|
45
45
|
pinned_messages: [],
|
|
46
|
-
read: cidVsReads[c.cid],
|
|
46
|
+
read: cidVsReads[c.cid] || [],
|
|
47
47
|
}));
|
|
48
48
|
};
|
package/src/version.json
CHANGED