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.
Files changed (108) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +10 -0
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +8 -0
  4. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  5. package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js +2 -2
  6. package/lib/commonjs/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
  7. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js +1 -1
  8. package/lib/commonjs/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
  9. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +112 -67
  10. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  11. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +121 -14
  12. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  13. package/lib/commonjs/components/Message/MessageSimple/MessageSwipeContent.js +32 -0
  14. package/lib/commonjs/components/Message/MessageSimple/MessageSwipeContent.js.map +1 -0
  15. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  16. package/lib/commonjs/contexts/themeContext/utils/theme.js +4 -0
  17. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  18. package/lib/commonjs/store/SqliteClient.js +17 -9
  19. package/lib/commonjs/store/SqliteClient.js.map +1 -1
  20. package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
  21. package/lib/commonjs/store/apis/getLastSyncedAt.js +9 -3
  22. package/lib/commonjs/store/apis/getLastSyncedAt.js.map +1 -1
  23. package/lib/commonjs/store/apis/getPendingTasks.js.map +1 -1
  24. package/lib/commonjs/store/apis/queries/selectChannels.js.map +1 -1
  25. package/lib/commonjs/store/apis/queries/selectMembersForChannels.js.map +1 -1
  26. package/lib/commonjs/store/apis/queries/selectMessagesForChannels.js.map +1 -1
  27. package/lib/commonjs/store/apis/queries/selectReactionsForMessages.js.map +1 -1
  28. package/lib/commonjs/store/apis/queries/selectReadsForChannels.js.map +1 -1
  29. package/lib/commonjs/store/apis/updatePollMessage.js.map +1 -1
  30. package/lib/commonjs/version.json +1 -1
  31. package/lib/module/components/Channel/Channel.js +10 -0
  32. package/lib/module/components/Channel/Channel.js.map +1 -1
  33. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +8 -0
  34. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  35. package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js +2 -2
  36. package/lib/module/components/ChannelList/hooks/useCreateChannelsContext.js.map +1 -1
  37. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js +1 -1
  38. package/lib/module/components/ChannelPreview/hooks/useChannelPreviewData.js.map +1 -1
  39. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +112 -67
  40. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  41. package/lib/module/components/Message/MessageSimple/MessageSimple.js +121 -14
  42. package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  43. package/lib/module/components/Message/MessageSimple/MessageSwipeContent.js +32 -0
  44. package/lib/module/components/Message/MessageSimple/MessageSwipeContent.js.map +1 -0
  45. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  46. package/lib/module/contexts/themeContext/utils/theme.js +4 -0
  47. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  48. package/lib/module/store/SqliteClient.js +17 -9
  49. package/lib/module/store/SqliteClient.js.map +1 -1
  50. package/lib/module/store/apis/getChannelMessages.js.map +1 -1
  51. package/lib/module/store/apis/getLastSyncedAt.js +9 -3
  52. package/lib/module/store/apis/getLastSyncedAt.js.map +1 -1
  53. package/lib/module/store/apis/getPendingTasks.js.map +1 -1
  54. package/lib/module/store/apis/queries/selectChannels.js.map +1 -1
  55. package/lib/module/store/apis/queries/selectMembersForChannels.js.map +1 -1
  56. package/lib/module/store/apis/queries/selectMessagesForChannels.js.map +1 -1
  57. package/lib/module/store/apis/queries/selectReactionsForMessages.js.map +1 -1
  58. package/lib/module/store/apis/queries/selectReadsForChannels.js.map +1 -1
  59. package/lib/module/store/apis/updatePollMessage.js.map +1 -1
  60. package/lib/module/version.json +1 -1
  61. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  62. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  63. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +5 -1
  64. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
  65. package/lib/typescript/components/ChannelList/hooks/useCreateChannelsContext.d.ts.map +1 -1
  66. package/lib/typescript/components/ChannelPreview/hooks/useChannelPreviewData.d.ts.map +1 -1
  67. package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +1 -1
  68. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts +1 -1
  69. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts.map +1 -1
  70. package/lib/typescript/components/Message/MessageSimple/MessageSwipeContent.d.ts +3 -0
  71. package/lib/typescript/components/Message/MessageSimple/MessageSwipeContent.d.ts.map +1 -0
  72. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +14 -1
  73. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
  74. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +4 -0
  75. package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
  76. package/lib/typescript/store/SqliteClient.d.ts +3 -3
  77. package/lib/typescript/store/SqliteClient.d.ts.map +1 -1
  78. package/lib/typescript/store/apis/getAppSettings.d.ts +1 -1
  79. package/lib/typescript/store/apis/getAppSettings.d.ts.map +1 -1
  80. package/lib/typescript/store/apis/getLastSyncedAt.d.ts.map +1 -1
  81. package/lib/typescript/store/apis/queries/selectChannels.d.ts.map +1 -1
  82. package/lib/typescript/store/apis/updatePollMessage.d.ts.map +1 -1
  83. package/lib/typescript/store/types.d.ts +2 -0
  84. package/lib/typescript/store/types.d.ts.map +1 -1
  85. package/package.json +1 -1
  86. package/src/components/Channel/Channel.tsx +11 -0
  87. package/src/components/Channel/hooks/useCreateMessagesContext.ts +8 -0
  88. package/src/components/ChannelList/hooks/useCreateChannelsContext.ts +3 -1
  89. package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts +1 -2
  90. package/src/components/Chat/hooks/handleEventToSyncDB.ts +27 -5
  91. package/src/components/Message/MessageSimple/MessageSimple.tsx +161 -14
  92. package/src/components/Message/MessageSimple/MessageSwipeContent.tsx +28 -0
  93. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +896 -292
  94. package/src/contexts/messagesContext/MessagesContext.tsx +15 -1
  95. package/src/contexts/themeContext/utils/theme.ts +8 -0
  96. package/src/store/SqliteClient.ts +16 -6
  97. package/src/store/apis/getAppSettings.ts +1 -1
  98. package/src/store/apis/getChannelMessages.ts +2 -2
  99. package/src/store/apis/getLastSyncedAt.ts +4 -1
  100. package/src/store/apis/getPendingTasks.ts +2 -2
  101. package/src/store/apis/queries/selectChannels.ts +4 -1
  102. package/src/store/apis/queries/selectMembersForChannels.ts +1 -1
  103. package/src/store/apis/queries/selectMessagesForChannels.ts +1 -1
  104. package/src/store/apis/queries/selectReactionsForMessages.ts +1 -1
  105. package/src/store/apis/queries/selectReadsForChannels.ts +1 -1
  106. package/src/store/apis/updatePollMessage.ts +2 -2
  107. package/src/store/types.ts +3 -0
  108. 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.execute(`PRAGMA foreign_keys = ON`, []);
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: PreparedQueries[]) => {
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
- await this.db.executeBatch(queries);
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?: string[]) => {
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,
@@ -7,7 +7,7 @@ export const getAppSettings = async ({
7
7
  currentUserId,
8
8
  }: {
9
9
  currentUserId: string;
10
- }): Promise<AppSettingsAPIResponse> => {
10
+ }): Promise<AppSettingsAPIResponse | null> => {
11
11
  SqliteClient.logger?.('info', 'getAppSettings', {
12
12
  currentUserId,
13
13
  });
@@ -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
  });
@@ -14,5 +14,8 @@ export const getLastSyncedAt = async ({
14
14
  }),
15
15
  );
16
16
 
17
- return result[0]?.lastSyncedAt;
17
+ if (typeof result[0]?.lastSyncedAt === 'number') {
18
+ return result[0]?.lastSyncedAt;
19
+ }
20
+ return undefined;
18
21
  };
@@ -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 type { TableRowJoinedUser } from '../types';
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: TableRowJoinedUser<'pendingTasks'>) => mapStorableToTask(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(null, query);
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(
@@ -34,5 +34,5 @@ export const selectMembersForChannels = async (
34
34
  cids,
35
35
  );
36
36
 
37
- return result.map((r: { value: string }) => JSON.parse(r.value));
37
+ return result.map((r) => JSON.parse(r.value));
38
38
  };
@@ -42,5 +42,5 @@ export const selectMessagesForChannels = async (
42
42
  cids,
43
43
  );
44
44
 
45
- return result.map((r: { value: string }) => JSON.parse(r.value));
45
+ return result.map((r) => JSON.parse(r.value));
46
46
  };
@@ -37,5 +37,5 @@ export const selectReactionsForMessages = async (
37
37
  messageIds,
38
38
  );
39
39
 
40
- return result.map((r: { value: string }) => JSON.parse(r.value));
40
+ return result.map((r) => JSON.parse(r.value));
41
41
  };
@@ -33,5 +33,5 @@ export const selectReadsForChannels = async (
33
33
  cids,
34
34
  );
35
35
 
36
- return result.map((r: { value: string }) => JSON.parse(r.value));
36
+ return result.map((r) => JSON.parse(r.value));
37
37
  };
@@ -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) {
@@ -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
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "6.2.0"
2
+ "version": "6.3.0-beta.1"
3
3
  }