stream-chat-react-native-core 6.2.0 → 6.3.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/Channel/Channel.js +10 -0
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +8 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js +2 -2
- package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js +1 -1
- package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +112 -67
- package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +121 -14
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSwipeContent.js +32 -0
- package/lib/commonjs/components/Message/MessageSimple/MessageSwipeContent.js.map +1 -0
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +4 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/store/SqliteClient.js +17 -9
- package/lib/commonjs/store/SqliteClient.js.map +1 -1
- package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
- package/lib/commonjs/store/apis/getLastSyncedAt.js +9 -3
- package/lib/commonjs/store/apis/getLastSyncedAt.js.map +1 -1
- package/lib/commonjs/store/apis/getPendingTasks.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectMembersForChannels.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js.map +1 -1
- package/lib/commonjs/store/apis/queries/selectReadsForChannels.js.map +1 -1
- package/lib/commonjs/store/apis/updatePollMessage.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Channel/Channel.js +10 -0
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +8 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js +2 -2
- package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js +1 -1
- package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +112 -67
- package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSimple.js +121 -14
- package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSwipeContent.js +32 -0
- package/lib/module/components/Message/MessageSimple/MessageSwipeContent.js.map +1 -0
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +4 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/store/SqliteClient.js +17 -9
- package/lib/module/store/SqliteClient.js.map +1 -1
- package/lib/module/store/apis/getChannelMessages.js.map +1 -1
- package/lib/module/store/apis/getLastSyncedAt.js +9 -3
- package/lib/module/store/apis/getLastSyncedAt.js.map +1 -1
- package/lib/module/store/apis/getPendingTasks.js.map +1 -1
- package/lib/module/store/apis/queries/selectChannels.js.map +1 -1
- package/lib/module/store/apis/queries/selectMembersForChannels.js.map +1 -1
- package/lib/module/store/apis/queries/selectMessagesForChannels.js.map +1 -1
- package/lib/module/store/apis/queries/selectReactionsForMessages.js.map +1 -1
- package/lib/module/store/apis/queries/selectReadsForChannels.js.map +1 -1
- package/lib/module/store/apis/updatePollMessage.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +5 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
- package/lib/typescript/components/ChannelList/hooks/useCreateChannelsContext.d.ts.map +1 -1
- package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts.map +1 -1
- package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageSimple/MessageSwipeContent.d.ts +3 -0
- package/lib/typescript/components/Message/MessageSimple/MessageSwipeContent.d.ts.map +1 -0
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +14 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +4 -0
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
- package/lib/typescript/store/SqliteClient.d.ts +3 -3
- package/lib/typescript/store/SqliteClient.d.ts.map +1 -1
- package/lib/typescript/store/apis/getAppSettings.d.ts +1 -1
- package/lib/typescript/store/apis/getAppSettings.d.ts.map +1 -1
- package/lib/typescript/store/apis/getLastSyncedAt.d.ts.map +1 -1
- package/lib/typescript/store/apis/queries/selectChannels.d.ts.map +1 -1
- package/lib/typescript/store/apis/updatePollMessage.d.ts.map +1 -1
- package/lib/typescript/store/types.d.ts +2 -0
- package/lib/typescript/store/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Channel/Channel.tsx +11 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +8 -0
- package/src/components/ChannelList/hooks/useCreateChannelsContext.ts +3 -1
- package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +1 -2
- package/src/components/Chat/hooks/handleEventToSyncDB.ts +27 -5
- package/src/components/Message/MessageSimple/MessageSimple.tsx +161 -14
- package/src/components/Message/MessageSimple/MessageSwipeContent.tsx +28 -0
- package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +896 -292
- package/src/contexts/messagesContext/MessagesContext.tsx +15 -1
- package/src/contexts/themeContext/utils/theme.ts +8 -0
- package/src/store/SqliteClient.ts +16 -6
- package/src/store/apis/getAppSettings.ts +1 -1
- package/src/store/apis/getChannelMessages.ts +2 -2
- package/src/store/apis/getLastSyncedAt.ts +4 -1
- package/src/store/apis/getPendingTasks.ts +2 -2
- package/src/store/apis/queries/selectChannels.ts +4 -1
- package/src/store/apis/queries/selectMembersForChannels.ts +1 -1
- package/src/store/apis/queries/selectMessagesForChannels.ts +1 -1
- package/src/store/apis/queries/selectReactionsForMessages.ts +1 -1
- package/src/store/apis/queries/selectReadsForChannels.ts +1 -1
- package/src/store/apis/updatePollMessage.ts +2 -2
- package/src/store/types.ts +3 -0
- package/src/version.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
import { PressableProps } from 'react-native';
|
|
3
|
+
import { PressableProps, ViewProps } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import type { Attachment, ChannelState, MessageResponse } from 'stream-chat';
|
|
6
6
|
|
|
@@ -100,6 +100,10 @@ export type MessagesContextValue<
|
|
|
100
100
|
* Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Attachment/Card.tsx)
|
|
101
101
|
*/
|
|
102
102
|
Card: React.ComponentType<CardProps<StreamChatGenerics>>;
|
|
103
|
+
/**
|
|
104
|
+
* Handler to clear the quoted state of the message.
|
|
105
|
+
*/
|
|
106
|
+
clearQuotedMessageState: () => void;
|
|
103
107
|
/**
|
|
104
108
|
* UI component for DateHeader
|
|
105
109
|
* Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageList/DateHeader.tsx)
|
|
@@ -358,6 +362,10 @@ export type MessagesContextValue<
|
|
|
358
362
|
deletedMessagesVisibilityType?: DeletedMessagesVisibilityType;
|
|
359
363
|
|
|
360
364
|
disableTypingIndicator?: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Enable swipe to reply on messages.
|
|
367
|
+
*/
|
|
368
|
+
enableSwipeToReply?: boolean;
|
|
361
369
|
/**
|
|
362
370
|
* Whether messages should be aligned to right or left part of screen.
|
|
363
371
|
* By default, messages will be received messages will be aligned to left and
|
|
@@ -459,10 +467,16 @@ export type MessagesContextValue<
|
|
|
459
467
|
* @overrideType Function | Array<Objects>
|
|
460
468
|
*/
|
|
461
469
|
messageActions?: (param: MessageActionsParams<StreamChatGenerics>) => MessageActionType[];
|
|
470
|
+
|
|
462
471
|
/**
|
|
463
472
|
* Custom message header component
|
|
464
473
|
*/
|
|
465
474
|
MessageHeader?: React.ComponentType<MessageFooterProps<StreamChatGenerics>>;
|
|
475
|
+
MessageSwipeContent?: React.ComponentType;
|
|
476
|
+
/**
|
|
477
|
+
* HitSlop for the message swipe to reply gesture
|
|
478
|
+
*/
|
|
479
|
+
messageSwipeToReplyHitSlop?: ViewProps['hitSlop'];
|
|
466
480
|
/** Custom UI component for message text */
|
|
467
481
|
MessageText?: React.ComponentType<MessageTextProps<StreamChatGenerics>>;
|
|
468
482
|
/**
|
|
@@ -654,6 +654,10 @@ export type Theme = {
|
|
|
654
654
|
statusContainer: ViewStyle;
|
|
655
655
|
timeIcon: IconProps;
|
|
656
656
|
};
|
|
657
|
+
swipeContentContainer: ViewStyle;
|
|
658
|
+
swipeLeftContent: {
|
|
659
|
+
container: ViewStyle;
|
|
660
|
+
};
|
|
657
661
|
targetedMessageContainer: ViewStyle;
|
|
658
662
|
videoThumbnail: {
|
|
659
663
|
container: ViewStyle;
|
|
@@ -1434,6 +1438,10 @@ export const defaultTheme: Theme = {
|
|
|
1434
1438
|
width: DEFAULT_STATUS_ICON_SIZE,
|
|
1435
1439
|
},
|
|
1436
1440
|
},
|
|
1441
|
+
swipeContentContainer: {},
|
|
1442
|
+
swipeLeftContent: {
|
|
1443
|
+
container: {},
|
|
1444
|
+
},
|
|
1437
1445
|
targetedMessageContainer: {},
|
|
1438
1446
|
unreadUnderlayColor: Colors.bg_gradient_start,
|
|
1439
1447
|
videoThumbnail: {
|
|
@@ -21,7 +21,7 @@ import { Logger } from 'stream-chat';
|
|
|
21
21
|
import { DB_LOCATION, DB_NAME } from './constants';
|
|
22
22
|
import { tables } from './schema';
|
|
23
23
|
import { createCreateTableQuery } from './sqlite-utils/createCreateTableQuery';
|
|
24
|
-
import type { PreparedQueries, Table } from './types';
|
|
24
|
+
import type { PreparedBatchQueries, PreparedQueries, Scalar, Table } from './types';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* SqliteClient takes care of any direct interaction with sqlite.
|
|
@@ -51,7 +51,7 @@ export class SqliteClient {
|
|
|
51
51
|
name: SqliteClient.dbName,
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
await this.db
|
|
54
|
+
await this.db?.execute(`PRAGMA foreign_keys = ON`, []);
|
|
55
55
|
} catch (e) {
|
|
56
56
|
this.logger?.('error', `Error opening database ${SqliteClient.dbName}`, {
|
|
57
57
|
error: e,
|
|
@@ -75,14 +75,24 @@ export class SqliteClient {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
static executeSqlBatch = async (queries:
|
|
78
|
+
static executeSqlBatch = async (queries: PreparedBatchQueries[]) => {
|
|
79
79
|
if (!queries || !queries.length) return;
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
82
|
if (!this.db) {
|
|
83
83
|
throw new Error('DB is not open or initialized.');
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
// This is a workaround to make the executeBatch method work.
|
|
86
|
+
// It expects an empty array as the second argument in the individual queries if nothing present.
|
|
87
|
+
// Discussion - https://discord.com/channels/1301463257722126357/1324262993780932688/1330846910596251711
|
|
88
|
+
const finalQueries = queries.map((query) => {
|
|
89
|
+
if (query.length === 1) {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
query.push([]);
|
|
92
|
+
}
|
|
93
|
+
return query;
|
|
94
|
+
});
|
|
95
|
+
await this.db.executeBatch(finalQueries);
|
|
86
96
|
} catch (e) {
|
|
87
97
|
this.logger?.('error', `SqlBatch queries failed`, {
|
|
88
98
|
error: e,
|
|
@@ -92,14 +102,14 @@ export class SqliteClient {
|
|
|
92
102
|
}
|
|
93
103
|
};
|
|
94
104
|
|
|
95
|
-
static executeSql = async (query: string, params?:
|
|
105
|
+
static executeSql = async (query: string, params?: Scalar[]) => {
|
|
96
106
|
try {
|
|
97
107
|
if (!this.db) {
|
|
98
108
|
throw new Error('DB is not open or initialized.');
|
|
99
109
|
}
|
|
100
110
|
const { rows } = await this.db.execute(query, params);
|
|
101
111
|
|
|
102
|
-
return rows ? rows : [];
|
|
112
|
+
return rows ? (rows as Record<string, string>[]) : [];
|
|
103
113
|
} catch (e) {
|
|
104
114
|
this.logger?.('error', `Sql single query failed`, {
|
|
105
115
|
error: e,
|
|
@@ -39,12 +39,12 @@ export const getChannelMessages = async <
|
|
|
39
39
|
const messageIdsVsPolls: Record<string, TableRow<'poll'>> = {};
|
|
40
40
|
const pollsById: Record<string, TableRow<'poll'>> = {};
|
|
41
41
|
const messagesWithPolls = messageRows.filter((message) => !!message.poll_id);
|
|
42
|
-
const polls = await SqliteClient.executeSql.apply(
|
|
42
|
+
const polls = (await SqliteClient.executeSql.apply(
|
|
43
43
|
null,
|
|
44
44
|
createSelectQuery('poll', ['*'], {
|
|
45
45
|
id: messagesWithPolls.map((message) => message.poll_id),
|
|
46
46
|
}),
|
|
47
|
-
);
|
|
47
|
+
)) as unknown as TableRow<'poll'>[];
|
|
48
48
|
polls.forEach((poll) => {
|
|
49
49
|
pollsById[poll.id] = poll;
|
|
50
50
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mapStorableToTask } from '../mappers/mapStorableToTask';
|
|
2
2
|
import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
|
|
3
3
|
import { SqliteClient } from '../SqliteClient';
|
|
4
|
-
import
|
|
4
|
+
import { TableRowJoinedUser } from '../types';
|
|
5
5
|
|
|
6
6
|
export const getPendingTasks = async (conditions: { messageId?: string } = {}) => {
|
|
7
7
|
const query = createSelectQuery('pendingTasks', ['*'], conditions, {
|
|
@@ -11,5 +11,5 @@ export const getPendingTasks = async (conditions: { messageId?: string } = {}) =
|
|
|
11
11
|
SqliteClient.logger?.('info', 'getPendingTasks', { conditions });
|
|
12
12
|
const result = await SqliteClient.executeSql.apply(null, query);
|
|
13
13
|
|
|
14
|
-
return result.map((r
|
|
14
|
+
return result.map((r) => mapStorableToTask(r as unknown as TableRowJoinedUser<'pendingTasks'>));
|
|
15
15
|
};
|
|
@@ -19,7 +19,10 @@ export const selectChannels = async ({ channelIds }: { channelIds?: string[] } =
|
|
|
19
19
|
channelIds,
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
const result = await SqliteClient.executeSql.apply(
|
|
22
|
+
const result = (await SqliteClient.executeSql.apply(
|
|
23
|
+
null,
|
|
24
|
+
query,
|
|
25
|
+
)) as unknown as TableRowJoinedUser<'channels'>[];
|
|
23
26
|
|
|
24
27
|
if (channelIds) {
|
|
25
28
|
return result.sort(
|
|
@@ -6,7 +6,7 @@ import { mapStorableToPoll } from '../mappers/mapStorableToPoll';
|
|
|
6
6
|
import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
|
|
7
7
|
import { createUpdateQuery } from '../sqlite-utils/createUpdateQuery';
|
|
8
8
|
import { SqliteClient } from '../SqliteClient';
|
|
9
|
-
import type { PreparedQueries } from '../types';
|
|
9
|
+
import type { PreparedQueries, TableRow } from '../types';
|
|
10
10
|
|
|
11
11
|
export const updatePollMessage = async <
|
|
12
12
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -33,7 +33,7 @@ export const updatePollMessage = async <
|
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
for (const pollFromDB of pollsFromDB) {
|
|
36
|
-
const serializedPoll = mapStorableToPoll(pollFromDB);
|
|
36
|
+
const serializedPoll = mapStorableToPoll(pollFromDB as unknown as TableRow<'poll'>);
|
|
37
37
|
const { latest_answers = [], own_votes = [] } = serializedPoll;
|
|
38
38
|
let newOwnVotes = own_votes;
|
|
39
39
|
if (poll_vote && poll_vote.user?.id === userID) {
|
package/src/store/types.ts
CHANGED
|
@@ -10,8 +10,11 @@ export type TableRowJoinedUser<T extends Table> = Schema[T] & {
|
|
|
10
10
|
|
|
11
11
|
export type TableColumnNames<T extends Table> = keyof Schema[T];
|
|
12
12
|
export type TableColumnValue = string | boolean | number | undefined;
|
|
13
|
+
export type Scalar = string | number | boolean | null | ArrayBuffer | ArrayBufferView;
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
export type PreparedQueries = [string] | [string, Array<any>];
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
export type PreparedBatchQueries = [string] | [string, Array<any> | Array<Array<any>>];
|
|
15
18
|
|
|
16
19
|
export type PendingTaskTypes = {
|
|
17
20
|
deleteMessage: 'delete-message';
|
package/src/version.json
CHANGED