stream-chat-react-native-core 5.0.0-beta.0 → 5.0.0-beta.1
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/FileAttachment.js +16 -7
- package/lib/commonjs/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Gallery.js +19 -17
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +10 -10
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Attachment/utils/getGiphyMimeType.js +15 -0
- package/lib/commonjs/components/Attachment/utils/getGiphyMimeType.js.map +1 -0
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +16 -4
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +12 -7
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js +10 -6
- package/lib/commonjs/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +38 -30
- package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js +2 -2
- package/lib/commonjs/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js +6 -0
- package/lib/commonjs/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -1
- package/lib/commonjs/components/Message/Message.js +6 -6
- package/lib/commonjs/components/Message/Message.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js +7 -3
- package/lib/commonjs/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +4 -4
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js +13 -14
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/lib/commonjs/index.js +13 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock-builders/DB/mock.js +1 -13
- package/lib/commonjs/mock-builders/DB/mock.js.map +1 -1
- package/lib/commonjs/mock-builders/event/messageNew.js +2 -0
- package/lib/commonjs/mock-builders/event/messageNew.js.map +1 -1
- package/lib/commonjs/store/QuickSqliteClient.js +7 -3
- package/lib/commonjs/store/QuickSqliteClient.js.map +1 -1
- package/lib/commonjs/store/apis/getChannels.js +2 -15
- package/lib/commonjs/store/apis/getChannels.js.map +1 -1
- package/lib/commonjs/store/apis/getChannelsForFilterSort.js +37 -0
- package/lib/commonjs/store/apis/getChannelsForFilterSort.js.map +1 -0
- package/lib/commonjs/store/apis/index.js +264 -0
- package/lib/commonjs/store/apis/index.js.map +1 -0
- package/lib/commonjs/store/apis/queries/selectChannelIdsForFilterSort.js +1 -1
- package/lib/commonjs/store/apis/queries/selectChannelIdsForFilterSort.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectChannels.js +2 -2
- package/lib/commonjs/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js +1 -2
- package/lib/commonjs/store/sqlite-utils/appendWhereCluase.js.map +1 -1
- package/lib/commonjs/test-utils/BetterSqlite.js +54 -0
- package/lib/commonjs/test-utils/BetterSqlite.js.map +1 -0
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/FileAttachment.js +16 -7
- package/lib/module/components/Attachment/FileAttachment.js.map +1 -1
- package/lib/module/components/Attachment/Gallery.js +19 -17
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/Giphy.js +10 -10
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Attachment/utils/getGiphyMimeType.js +15 -0
- package/lib/module/components/Attachment/utils/getGiphyMimeType.js.map +1 -0
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +16 -4
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +12 -7
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/ChannelPreview/ChannelPreview.js +10 -6
- package/lib/module/components/ChannelPreview/ChannelPreview.js.map +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +38 -30
- package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
- package/lib/module/components/ImageGallery/components/ImageGrid.js +2 -2
- package/lib/module/components/ImageGallery/components/ImageGrid.js.map +1 -1
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js +6 -0
- package/lib/module/components/ImageGallery/hooks/useImageGalleryGestures.js.map +1 -1
- package/lib/module/components/Message/Message.js +6 -6
- package/lib/module/components/Message/Message.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js +7 -3
- package/lib/module/components/Message/MessageSimple/MessageTextContainer.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +4 -4
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js +13 -14
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.js.map +1 -1
- package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock-builders/DB/mock.js +1 -13
- package/lib/module/mock-builders/DB/mock.js.map +1 -1
- package/lib/module/mock-builders/event/messageNew.js +2 -0
- package/lib/module/mock-builders/event/messageNew.js.map +1 -1
- package/lib/module/store/QuickSqliteClient.js +7 -3
- package/lib/module/store/QuickSqliteClient.js.map +1 -1
- package/lib/module/store/apis/getChannels.js +2 -15
- package/lib/module/store/apis/getChannels.js.map +1 -1
- package/lib/module/store/apis/getChannelsForFilterSort.js +37 -0
- package/lib/module/store/apis/getChannelsForFilterSort.js.map +1 -0
- package/lib/module/store/apis/index.js +264 -0
- package/lib/module/store/apis/index.js.map +1 -0
- package/lib/module/store/apis/queries/selectChannelIdsForFilterSort.js +1 -1
- package/lib/module/store/apis/queries/selectChannelIdsForFilterSort.js.map +1 -1
- package/lib/module/store/apis/queries/selectChannels.js +2 -2
- package/lib/module/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/module/store/sqlite-utils/appendWhereCluase.js +1 -2
- package/lib/module/store/sqlite-utils/appendWhereCluase.js.map +1 -1
- package/lib/module/test-utils/BetterSqlite.js +54 -0
- package/lib/module/test-utils/BetterSqlite.js.map +1 -0
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Gallery.d.ts +1 -1
- package/lib/typescript/components/Attachment/Giphy.d.ts +1 -1
- package/lib/typescript/components/Attachment/utils/getGiphyMimeType.d.ts +6 -0
- package/lib/typescript/components/ImageGallery/components/ImageGrid.d.ts +1 -1
- package/lib/typescript/components/ImageGallery/hooks/useImageGalleryGestures.d.ts +2 -1
- package/lib/typescript/components/Message/Message.d.ts +9 -3
- package/lib/typescript/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/contexts/imageGalleryContext/ImageGalleryContext.d.ts +9 -10
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/store/QuickSqliteClient.d.ts +4 -0
- package/lib/typescript/store/apis/getChannels.d.ts +13 -5
- package/lib/typescript/store/apis/getChannelsForFilterSort.d.ts +17 -0
- package/lib/typescript/store/apis/index.d.ts +20 -0
- package/lib/typescript/store/apis/queries/selectChannelIdsForFilterSort.d.ts +10 -1
- package/lib/typescript/{__tests__/utils → test-utils}/BetterSqlite.d.ts +1 -1
- package/package.json +4 -3
- package/src/__tests__/offline-feature.test.js +1 -2
- package/src/components/Attachment/FileAttachment.tsx +3 -0
- package/src/components/Attachment/Gallery.tsx +20 -17
- package/src/components/Attachment/Giphy.tsx +8 -8
- package/src/components/Attachment/utils/getGiphyMimeType.ts +13 -0
- package/src/components/ChannelList/__tests__/ChannelList.test.js +28 -0
- package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +18 -5
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +19 -10
- package/src/components/ChannelPreview/ChannelPreview.tsx +6 -3
- package/src/components/ImageGallery/ImageGallery.tsx +32 -19
- package/src/components/ImageGallery/__tests__/ImageGallery.test.tsx +6 -6
- package/src/components/ImageGallery/__tests__/ImageGalleryFooter.test.tsx +3 -3
- package/src/components/ImageGallery/__tests__/ImageGalleryGrid.test.tsx +3 -3
- package/src/components/ImageGallery/__tests__/ImageGalleryHeader.test.tsx +3 -3
- package/src/components/ImageGallery/components/ImageGrid.tsx +3 -3
- package/src/components/ImageGallery/hooks/useImageGalleryGestures.tsx +16 -0
- package/src/components/Message/Message.tsx +9 -1
- package/src/components/Message/MessageSimple/MessageTextContainer.tsx +22 -2
- package/src/components/Message/MessageSimple/__tests__/__snapshots__/MessageAvatar.test.js.snap +1 -0
- package/src/components/MessageList/MessageList.tsx +5 -5
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +4 -0
- package/src/contexts/imageGalleryContext/ImageGalleryContext.md +1 -1
- package/src/contexts/imageGalleryContext/ImageGalleryContext.tsx +19 -14
- package/src/index.ts +3 -0
- package/src/mock-builders/DB/mock.ts +4 -9
- package/src/mock-builders/event/messageNew.js +2 -0
- package/src/store/QuickSqliteClient.ts +11 -7
- package/src/store/apis/getChannels.ts +17 -14
- package/src/store/apis/getChannelsForFilterSort.ts +45 -0
- package/src/store/apis/index.ts +20 -0
- package/src/store/apis/queries/selectChannelIdsForFilterSort.ts +12 -2
- package/src/store/apis/queries/selectChannels.ts +9 -3
- package/src/store/sqlite-utils/appendWhereCluase.ts +1 -2
- package/src/{__tests__/utils → test-utils}/BetterSqlite.js +1 -1
- package/src/version.json +1 -1
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ChannelAPIResponse, ChannelFilters, ChannelSort } from 'stream-chat';
|
|
1
|
+
import type { ChannelAPIResponse } from 'stream-chat';
|
|
3
2
|
|
|
4
3
|
import { getMessages } from './getChannelMessages';
|
|
5
4
|
import { getMembers } from './getMembers';
|
|
6
5
|
import { getReads } from './getReads';
|
|
7
|
-
import { selectChannelIdsForFilterSort } from './queries/selectChannelIdsForFilterSort';
|
|
8
6
|
import { selectChannels } from './queries/selectChannels';
|
|
9
7
|
|
|
8
|
+
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
10
9
|
import { mapStorableToChannel } from '../mappers/mapStorableToChannel';
|
|
11
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Returns the list of channels with state enriched for given channel ids.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} param
|
|
15
|
+
* @param {Array} param.channelIds List of channel ids to fetch.
|
|
16
|
+
* @param {Array} param.currentUserId Id of the current logged in user.
|
|
17
|
+
*
|
|
18
|
+
* @returns {Array} Channels with enriched state.
|
|
19
|
+
*/
|
|
12
20
|
export const getChannels = <
|
|
13
21
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
14
22
|
>({
|
|
23
|
+
channelIds,
|
|
15
24
|
currentUserId,
|
|
16
|
-
filters,
|
|
17
|
-
sort,
|
|
18
25
|
}: {
|
|
26
|
+
channelIds: string[];
|
|
19
27
|
currentUserId: string;
|
|
20
|
-
filters?: ChannelFilters<StreamChatGenerics>;
|
|
21
|
-
sort?: ChannelSort<StreamChatGenerics>;
|
|
22
28
|
}): Omit<ChannelAPIResponse<StreamChatGenerics>, 'duration'>[] => {
|
|
23
|
-
if (!filters && !sort) {
|
|
24
|
-
console.warn('Please provide the query (filters/sort) to fetch channels from DB');
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const channelIds = selectChannelIdsForFilterSort({ filters, sort });
|
|
29
29
|
const channels = selectChannels({ channelIds });
|
|
30
30
|
|
|
31
31
|
const cidVsMembers = getMembers<StreamChatGenerics>({ channelIds });
|
|
32
32
|
const cidVsReads = getReads<StreamChatGenerics>({ channelIds });
|
|
33
|
-
const cidVsMessages = getMessages<StreamChatGenerics>({
|
|
33
|
+
const cidVsMessages = getMessages<StreamChatGenerics>({
|
|
34
|
+
channelIds,
|
|
35
|
+
currentUserId,
|
|
36
|
+
});
|
|
34
37
|
|
|
35
38
|
// Enrich the channels with state
|
|
36
39
|
return channels.map((c) => ({
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DefaultStreamChatGenerics } from 'src/types/types';
|
|
2
|
+
import type { ChannelAPIResponse, ChannelFilters, ChannelSort } from 'stream-chat';
|
|
3
|
+
|
|
4
|
+
import { getChannels } from './getChannels';
|
|
5
|
+
import { selectChannelIdsForFilterSort } from './queries/selectChannelIdsForFilterSort';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets the channels from database for given filter and sort query.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} param
|
|
11
|
+
* @param {string} param.currentUserId Id of current logged in user
|
|
12
|
+
* @param {Object} param.filters Filters for channels https://getstream.io/chat/docs/javascript/query_channels/?language=javascript&q=su#query-parameters
|
|
13
|
+
* @param {Object} param.sort Sort for channels https://getstream.io/chat/docs/javascript/query_channels/?language=javascript&q=su#query-parameters
|
|
14
|
+
*
|
|
15
|
+
* @returns Array of channels corresponding to filters & sort. Returns null if filters + sort query doesn't exist in "channelQueries" table.
|
|
16
|
+
*/
|
|
17
|
+
export const getChannelsForFilterSort = <
|
|
18
|
+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
19
|
+
>({
|
|
20
|
+
currentUserId,
|
|
21
|
+
filters,
|
|
22
|
+
sort,
|
|
23
|
+
}: {
|
|
24
|
+
currentUserId: string;
|
|
25
|
+
filters?: ChannelFilters<StreamChatGenerics>;
|
|
26
|
+
sort?: ChannelSort<StreamChatGenerics>;
|
|
27
|
+
}): Omit<ChannelAPIResponse<StreamChatGenerics>, 'duration'>[] | null => {
|
|
28
|
+
if (!filters && !sort) {
|
|
29
|
+
console.warn('Please provide the query (filters/sort) to fetch channels from DB');
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const channelIds = selectChannelIdsForFilterSort({ filters, sort });
|
|
34
|
+
|
|
35
|
+
if (!channelIds) return null;
|
|
36
|
+
|
|
37
|
+
if (channelIds.length === 0) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return getChannels({
|
|
42
|
+
channelIds,
|
|
43
|
+
currentUserId,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './deleteChannel';
|
|
2
|
+
export * from './deleteMember';
|
|
3
|
+
export * from './deleteMessagesForChannel';
|
|
4
|
+
export * from './deleteReactions';
|
|
5
|
+
export * from './getAllChannelIds';
|
|
6
|
+
export * from './getChannelMessages';
|
|
7
|
+
export * from './getChannels';
|
|
8
|
+
export * from './getChannelsForFilterSort';
|
|
9
|
+
export * from './getLastSyncedAt';
|
|
10
|
+
export * from './getMembers';
|
|
11
|
+
export * from './getReads';
|
|
12
|
+
export * from './updateMessage';
|
|
13
|
+
export * from './updateReaction';
|
|
14
|
+
export * from './upsertChannelData';
|
|
15
|
+
export * from './upsertChannels';
|
|
16
|
+
export * from './upsertCidsForQuery';
|
|
17
|
+
export * from './upsertLastSyncedAt';
|
|
18
|
+
export * from './upsertMembers';
|
|
19
|
+
export * from './upsertMessages';
|
|
20
|
+
export * from './upsertReads';
|
|
@@ -6,6 +6,16 @@ import { createSelectQuery } from '../../sqlite-utils/createSelectQuery';
|
|
|
6
6
|
|
|
7
7
|
import { convertFilterSortToQuery } from '../utils/convertFilterSortToQuery';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Gets the channel ids from database for given filter and sort query.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} param
|
|
13
|
+
* @param {Object} param.filters Filters for channels https://getstream.io/chat/docs/javascript/query_channels/?language=javascript&q=su#query-parameters
|
|
14
|
+
* @param {Object} param.sort Sort for channels https://getstream.io/chat/docs/javascript/query_channels/?language=javascript&q=su#query-parameters
|
|
15
|
+
*
|
|
16
|
+
* @returns Array of channel ids corresponding to filters & sort. Returns null if filters + sort query doesn't exist in "channelQueries" table.
|
|
17
|
+
*/
|
|
18
|
+
|
|
9
19
|
export const selectChannelIdsForFilterSort = <
|
|
10
20
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
11
21
|
>({
|
|
@@ -14,7 +24,7 @@ export const selectChannelIdsForFilterSort = <
|
|
|
14
24
|
}: {
|
|
15
25
|
filters?: ChannelFilters<StreamChatGenerics>;
|
|
16
26
|
sort?: ChannelSort<StreamChatGenerics>;
|
|
17
|
-
}): string[] => {
|
|
27
|
+
}): string[] | null => {
|
|
18
28
|
const query = convertFilterSortToQuery({ filters, sort });
|
|
19
29
|
const results = QuickSqliteClient.executeSql.apply(
|
|
20
30
|
null,
|
|
@@ -24,5 +34,5 @@ export const selectChannelIdsForFilterSort = <
|
|
|
24
34
|
);
|
|
25
35
|
|
|
26
36
|
const channelIdsStr = results?.[0]?.cids;
|
|
27
|
-
return channelIdsStr ? JSON.parse(channelIdsStr) :
|
|
37
|
+
return channelIdsStr ? JSON.parse(channelIdsStr) : null;
|
|
28
38
|
};
|
|
@@ -5,9 +5,15 @@ import type { TableRowJoinedUser } from '../../types';
|
|
|
5
5
|
export const selectChannels = ({
|
|
6
6
|
channelIds,
|
|
7
7
|
}: { channelIds?: string[] } = {}): TableRowJoinedUser<'channels'>[] => {
|
|
8
|
-
const query = createSelectQuery(
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const query = createSelectQuery(
|
|
9
|
+
'channels',
|
|
10
|
+
['*'],
|
|
11
|
+
channelIds
|
|
12
|
+
? {
|
|
13
|
+
cid: channelIds,
|
|
14
|
+
}
|
|
15
|
+
: undefined,
|
|
16
|
+
);
|
|
11
17
|
|
|
12
18
|
const result = QuickSqliteClient.executeSql.apply(null, query);
|
|
13
19
|
|
|
@@ -15,7 +15,6 @@ export const appendWhereClause = <T extends keyof Schema>(
|
|
|
15
15
|
if (value === undefined) continue;
|
|
16
16
|
|
|
17
17
|
if (Array.isArray(value)) {
|
|
18
|
-
if (value.length === 0) continue;
|
|
19
18
|
const questionMarks = Array(Object.keys(value).length).fill('?').join(',');
|
|
20
19
|
whereClause.push(`${key} in (${questionMarks})`);
|
|
21
20
|
whereParams.push(...value);
|
|
@@ -25,7 +24,7 @@ export const appendWhereClause = <T extends keyof Schema>(
|
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
if (!whereParams.length) {
|
|
27
|
+
if (!whereParams.length && !whereClause.length) {
|
|
29
28
|
return [selectQuery, []];
|
|
30
29
|
}
|
|
31
30
|
|
package/src/version.json
CHANGED