stream-chat-react-native-core 5.41.3 → 5.41.4-beta.2

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 (120) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +1 -1
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js +9 -6
  4. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  5. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +7 -2
  6. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  7. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +6 -6
  8. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
  9. package/lib/commonjs/components/Message/MessageSimple/MessageReplies.js +5 -1
  10. package/lib/commonjs/components/Message/MessageSimple/MessageReplies.js.map +1 -1
  11. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js +3 -1
  12. package/lib/commonjs/components/MessageOverlay/MessageOverlay.js.map +1 -1
  13. package/lib/commonjs/components/Poll/CreatePollContent.js +4 -1
  14. package/lib/commonjs/components/Poll/CreatePollContent.js.map +1 -1
  15. package/lib/commonjs/components/Reply/Reply.js +14 -2
  16. package/lib/commonjs/components/Reply/Reply.js.map +1 -1
  17. package/lib/commonjs/contexts/themeContext/utils/theme.js +0 -2
  18. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  19. package/lib/commonjs/store/QuickSqliteClient.js +1 -1
  20. package/lib/commonjs/store/apis/getChannelMessages.js +18 -0
  21. package/lib/commonjs/store/apis/getChannelMessages.js.map +1 -1
  22. package/lib/commonjs/store/apis/updateMessage.js +1 -1
  23. package/lib/commonjs/store/apis/updateMessage.js.map +1 -1
  24. package/lib/commonjs/store/apis/updatePollMessage.js +41 -15
  25. package/lib/commonjs/store/apis/updatePollMessage.js.map +1 -1
  26. package/lib/commonjs/store/apis/upsertMessages.js +8 -0
  27. package/lib/commonjs/store/apis/upsertMessages.js.map +1 -1
  28. package/lib/commonjs/store/mappers/mapMessageToStorable.js +0 -1
  29. package/lib/commonjs/store/mappers/mapMessageToStorable.js.map +1 -1
  30. package/lib/commonjs/store/mappers/mapPollToStorable.js +51 -0
  31. package/lib/commonjs/store/mappers/mapPollToStorable.js.map +1 -0
  32. package/lib/commonjs/store/mappers/mapStorableToMessage.js +6 -4
  33. package/lib/commonjs/store/mappers/mapStorableToMessage.js.map +1 -1
  34. package/lib/commonjs/store/mappers/mapStorableToPoll.js +50 -0
  35. package/lib/commonjs/store/mappers/mapStorableToPoll.js.map +1 -0
  36. package/lib/commonjs/store/schema.js +25 -1
  37. package/lib/commonjs/store/schema.js.map +1 -1
  38. package/lib/commonjs/version.json +1 -1
  39. package/lib/module/components/Channel/Channel.js +1 -1
  40. package/lib/module/components/Channel/Channel.js.map +1 -1
  41. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js +9 -6
  42. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  43. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +7 -2
  44. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  45. package/lib/module/components/Message/MessageSimple/MessageContent.js +6 -6
  46. package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
  47. package/lib/module/components/Message/MessageSimple/MessageReplies.js +5 -1
  48. package/lib/module/components/Message/MessageSimple/MessageReplies.js.map +1 -1
  49. package/lib/module/components/MessageOverlay/MessageOverlay.js +3 -1
  50. package/lib/module/components/MessageOverlay/MessageOverlay.js.map +1 -1
  51. package/lib/module/components/Poll/CreatePollContent.js +4 -1
  52. package/lib/module/components/Poll/CreatePollContent.js.map +1 -1
  53. package/lib/module/components/Reply/Reply.js +14 -2
  54. package/lib/module/components/Reply/Reply.js.map +1 -1
  55. package/lib/module/contexts/themeContext/utils/theme.js +0 -2
  56. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  57. package/lib/module/store/QuickSqliteClient.js +1 -1
  58. package/lib/module/store/apis/getChannelMessages.js +18 -0
  59. package/lib/module/store/apis/getChannelMessages.js.map +1 -1
  60. package/lib/module/store/apis/updateMessage.js +1 -1
  61. package/lib/module/store/apis/updateMessage.js.map +1 -1
  62. package/lib/module/store/apis/updatePollMessage.js +41 -15
  63. package/lib/module/store/apis/updatePollMessage.js.map +1 -1
  64. package/lib/module/store/apis/upsertMessages.js +8 -0
  65. package/lib/module/store/apis/upsertMessages.js.map +1 -1
  66. package/lib/module/store/mappers/mapMessageToStorable.js +0 -1
  67. package/lib/module/store/mappers/mapMessageToStorable.js.map +1 -1
  68. package/lib/module/store/mappers/mapPollToStorable.js +51 -0
  69. package/lib/module/store/mappers/mapPollToStorable.js.map +1 -0
  70. package/lib/module/store/mappers/mapStorableToMessage.js +6 -4
  71. package/lib/module/store/mappers/mapStorableToMessage.js.map +1 -1
  72. package/lib/module/store/mappers/mapStorableToPoll.js +50 -0
  73. package/lib/module/store/mappers/mapStorableToPoll.js.map +1 -0
  74. package/lib/module/store/schema.js +25 -1
  75. package/lib/module/store/schema.js.map +1 -1
  76. package/lib/module/version.json +1 -1
  77. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  78. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts +1 -0
  79. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts.map +1 -1
  80. package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +1 -1
  81. package/lib/typescript/components/Message/MessageSimple/MessageReplies.d.ts.map +1 -1
  82. package/lib/typescript/components/Poll/CreatePollContent.d.ts.map +1 -1
  83. package/lib/typescript/components/Reply/Reply.d.ts +3 -0
  84. package/lib/typescript/components/Reply/Reply.d.ts.map +1 -1
  85. package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
  86. package/lib/typescript/store/apis/getChannelMessages.d.ts.map +1 -1
  87. package/lib/typescript/store/apis/updateMessage.d.ts.map +1 -1
  88. package/lib/typescript/store/apis/updatePollMessage.d.ts +7 -3
  89. package/lib/typescript/store/apis/updatePollMessage.d.ts.map +1 -1
  90. package/lib/typescript/store/apis/upsertMessages.d.ts.map +1 -1
  91. package/lib/typescript/store/mappers/mapPollToStorable.d.ts +4 -0
  92. package/lib/typescript/store/mappers/mapPollToStorable.d.ts.map +1 -0
  93. package/lib/typescript/store/mappers/mapStorableToMessage.d.ts +3 -2
  94. package/lib/typescript/store/mappers/mapStorableToMessage.d.ts.map +1 -1
  95. package/lib/typescript/store/mappers/mapStorableToPoll.d.ts +5 -0
  96. package/lib/typescript/store/mappers/mapStorableToPoll.d.ts.map +1 -0
  97. package/lib/typescript/store/schema.d.ts +22 -1
  98. package/lib/typescript/store/schema.d.ts.map +1 -1
  99. package/package.json +1 -1
  100. package/src/components/Channel/Channel.tsx +1 -7
  101. package/src/components/ChannelPreview/hooks/useLatestMessagePreview.ts +15 -5
  102. package/src/components/Chat/hooks/handleEventToSyncDB.ts +4 -1
  103. package/src/components/Message/MessageSimple/MessageContent.tsx +5 -5
  104. package/src/components/Message/MessageSimple/MessageReplies.tsx +6 -1
  105. package/src/components/MessageOverlay/MessageOverlay.tsx +3 -3
  106. package/src/components/Poll/CreatePollContent.tsx +6 -1
  107. package/src/components/Reply/Reply.tsx +20 -3
  108. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +4 -4
  109. package/src/contexts/themeContext/utils/theme.ts +0 -2
  110. package/src/store/QuickSqliteClient.ts +1 -1
  111. package/src/store/apis/getChannelMessages.ts +18 -1
  112. package/src/store/apis/updateMessage.ts +3 -1
  113. package/src/store/apis/updatePollMessage.ts +40 -14
  114. package/src/store/apis/upsertMessages.ts +7 -0
  115. package/src/store/mappers/mapMessageToStorable.ts +1 -1
  116. package/src/store/mappers/mapPollToStorable.ts +53 -0
  117. package/src/store/mappers/mapStorableToMessage.ts +5 -3
  118. package/src/store/mappers/mapStorableToPoll.ts +56 -0
  119. package/src/store/schema.ts +47 -2
  120. package/src/version.json +1 -1
@@ -74,7 +74,6 @@ export type Schema = {
74
74
  extraData: string;
75
75
  id: string;
76
76
  messageTextUpdatedAt: string;
77
- poll: string;
78
77
  poll_id: string;
79
78
  reactionGroups: string;
80
79
  type: MessageLabel;
@@ -91,6 +90,28 @@ export type Schema = {
91
90
  payload: string;
92
91
  type: ValueOf<PendingTaskTypes>;
93
92
  };
93
+ poll: {
94
+ answers_count: number;
95
+ created_at: string;
96
+ created_by: string;
97
+ created_by_id: string;
98
+ enforce_unique_vote: boolean;
99
+ id: string;
100
+ latest_answers: string;
101
+ latest_votes_by_option: string;
102
+ max_votes_allowed: number;
103
+ name: string;
104
+ options: string;
105
+ updated_at: string;
106
+ vote_count: number;
107
+ vote_counts_by_option: string;
108
+ allow_answers?: boolean;
109
+ allow_user_suggested_options?: boolean;
110
+ description?: string;
111
+ is_closed?: boolean;
112
+ own_votes?: string;
113
+ voting_visibility?: string;
114
+ };
94
115
  reactions: {
95
116
  createdAt: string;
96
117
  messageId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/store/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,MAAM,GAAG;KACX,CAAC,IAAI,MAAM,MAAM,GAAG;QACnB,OAAO,EAAE;aACN,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM;SAC/B,CAAC;QACF,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC;YAC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C5B,CAAC;IACF,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,cAAc,EAAE;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.41.3",
4
+ "version": "5.41.4-beta.2",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -852,13 +852,7 @@ const ChannelWithContext = <
852
852
  setThreadMessages(updatedThreadMessages);
853
853
  }
854
854
 
855
- if (
856
- channel &&
857
- thread?.id &&
858
- event.message?.id === thread.id &&
859
- !threadInstance &&
860
- !thread.poll_id
861
- ) {
855
+ if (channel && thread?.id && event.message?.id === thread.id && !threadInstance) {
862
856
  const updatedThread = channel.state.formatMessage(event.message);
863
857
  setThread(updatedThread);
864
858
  }
@@ -40,6 +40,7 @@ export type LatestMessagePreview<
40
40
  export type LatestMessagePreviewSelectorReturnType = {
41
41
  createdBy?: UserResponse | null;
42
42
  latestVotesByOption?: Record<string, PollVote[]>;
43
+ name?: string;
43
44
  };
44
45
 
45
46
  const selector = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
@@ -47,6 +48,7 @@ const selector = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
47
48
  ): LatestMessagePreviewSelectorReturnType => ({
48
49
  createdBy: nextValue.created_by,
49
50
  latestVotesByOption: nextValue.latest_votes_by_option,
51
+ name: nextValue.name,
50
52
  });
51
53
 
52
54
  const getMessageSenderName = <
@@ -145,8 +147,8 @@ const getLatestMessageDisplayText = <
145
147
  { bold: false, text: t('🏙 Attachment...') },
146
148
  ];
147
149
  }
148
- if (message.poll && pollState) {
149
- const { createdBy, latestVotesByOption } = pollState;
150
+ if (message.poll_id && pollState) {
151
+ const { createdBy, latestVotesByOption, name } = pollState;
150
152
  let latestVotes;
151
153
  if (latestVotesByOption) {
152
154
  latestVotes = Object.values(latestVotesByOption)
@@ -161,7 +163,7 @@ const getLatestMessageDisplayText = <
161
163
  }
162
164
  const previewMessage = `${
163
165
  client.userID === previewUser?.id ? 'You' : previewUser?.name
164
- } ${previewAction}: ${message.poll.name}`;
166
+ } ${previewAction}: ${name}`;
165
167
  return [
166
168
  { bold: false, text: '📊 ' },
167
169
  { bold: false, text: previewMessage },
@@ -311,7 +313,7 @@ export const useLatestMessagePreview = <
311
313
  const poll = client.polls.fromState(pollId);
312
314
  const pollState: LatestMessagePreviewSelectorReturnType =
313
315
  useStateStore(poll?.state, selector) ?? {};
314
- const { createdBy, latestVotesByOption } = pollState;
316
+ const { createdBy, latestVotesByOption, name } = pollState;
315
317
 
316
318
  useEffect(
317
319
  () =>
@@ -326,7 +328,15 @@ export const useLatestMessagePreview = <
326
328
  }),
327
329
  ),
328
330
  // eslint-disable-next-line react-hooks/exhaustive-deps
329
- [channelLastMessageString, forceUpdate, readEvents, readStatus, latestVotesByOption, createdBy],
331
+ [
332
+ channelLastMessageString,
333
+ forceUpdate,
334
+ readEvents,
335
+ readStatus,
336
+ latestVotesByOption,
337
+ createdBy,
338
+ name,
339
+ ],
330
340
  );
331
341
 
332
342
  return latestMessagePreview;
@@ -233,11 +233,14 @@ export const handleEventToSyncDB = <
233
233
  'poll.vote_removed',
234
234
  ].includes(type)
235
235
  ) {
236
- const poll = event.poll;
236
+ const { poll, poll_vote, type } = event;
237
237
  if (poll) {
238
238
  return updatePollMessage({
239
+ eventType: type,
239
240
  flush,
240
241
  poll,
242
+ poll_vote,
243
+ userID: client?.userID || '',
241
244
  });
242
245
  }
243
246
  }
@@ -149,7 +149,7 @@ const MessageContentWithContext = <
149
149
 
150
150
  const {
151
151
  theme: {
152
- colors: { blue_alice, grey_gainsboro, grey_whisper, transparent, white },
152
+ colors: { blue_alice, grey_whisper, light_gray, transparent, white_snow },
153
153
  messageSimple: {
154
154
  content: {
155
155
  container: {
@@ -214,20 +214,20 @@ const MessageContentWithContext = <
214
214
 
215
215
  const isMessageReceivedOrErrorType = !isMyMessage || error;
216
216
 
217
- let backgroundColor = senderMessageBackgroundColor || grey_gainsboro;
217
+ let backgroundColor = senderMessageBackgroundColor ?? light_gray;
218
218
  if (onlyEmojis && !message.quoted_message) {
219
219
  backgroundColor = transparent;
220
220
  } else if (otherAttachments.length) {
221
221
  if (otherAttachments[0].type === 'giphy') {
222
- backgroundColor = message.quoted_message ? grey_gainsboro : transparent;
222
+ backgroundColor = message.quoted_message ? light_gray : transparent;
223
223
  } else {
224
224
  backgroundColor = blue_alice;
225
225
  }
226
226
  } else if (isMessageReceivedOrErrorType) {
227
- backgroundColor = receiverMessageBackgroundColor || white;
227
+ backgroundColor = receiverMessageBackgroundColor ?? white_snow;
228
228
  }
229
229
 
230
- const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : grey_gainsboro;
230
+ const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : light_gray;
231
231
 
232
232
  const getBorderRadius = () => {
233
233
  // enum('top', 'middle', 'bottom', 'single')
@@ -32,7 +32,7 @@ const styles = StyleSheet.create({
32
32
  },
33
33
  messageRepliesCurve: {
34
34
  borderTopWidth: 0,
35
- borderWidth: 1,
35
+ borderWidth: 2,
36
36
  height: 16,
37
37
  width: 16,
38
38
  },
@@ -181,6 +181,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
181
181
  message: prevMessage,
182
182
  noBorder: prevNoBorder,
183
183
  onOpenThread: prevOnOpenThread,
184
+ repliesCurveColor: prevRepliesCurveColor,
184
185
  t: prevT,
185
186
  threadList: prevThreadList,
186
187
  } = prevProps;
@@ -188,6 +189,7 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
188
189
  message: nextMessage,
189
190
  noBorder: nextNoBorder,
190
191
  onOpenThread: nextOnOpenThread,
192
+ repliesCurveColor: nextRepliesCurveColor,
191
193
  t: nextT,
192
194
  threadList: nextThreadList,
193
195
  } = nextProps;
@@ -201,6 +203,9 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
201
203
  const noBorderEqual = prevNoBorder === nextNoBorder;
202
204
  if (!noBorderEqual) return false;
203
205
 
206
+ const repliesCurveColorEqual = prevRepliesCurveColor === nextRepliesCurveColor;
207
+ if (!repliesCurveColorEqual) return false;
208
+
204
209
  const tEqual = prevT === nextT;
205
210
  if (!tEqual) return false;
206
211
 
@@ -170,7 +170,7 @@ const MessageOverlayWithContext = <
170
170
  );
171
171
 
172
172
  const {
173
- colors: { blue_alice, grey_gainsboro, grey_whisper, transparent },
173
+ colors: { blue_alice, grey_gainsboro, grey_whisper, light_gray, transparent, white_snow },
174
174
  messageSimple: {
175
175
  content: {
176
176
  container: { borderRadiusL, borderRadiusS },
@@ -364,8 +364,8 @@ const MessageOverlayWithContext = <
364
364
  : grey_gainsboro
365
365
  : blue_alice
366
366
  : alignment === 'left'
367
- ? receiverMessageBackgroundColor
368
- : senderMessageBackgroundColor,
367
+ ? receiverMessageBackgroundColor ?? white_snow
368
+ : senderMessageBackgroundColor ?? light_gray,
369
369
  borderBottomLeftRadius:
370
370
  (groupStyle === 'left_bottom' || groupStyle === 'left_single') &&
371
371
  (!hasThreadReplies || threadList)
@@ -164,7 +164,12 @@ export const CreatePollContent = () => {
164
164
  {t<string>('Multiple answers')}
165
165
  </Text>
166
166
  <Switch
167
- onValueChange={() => setMultipleAnswersAllowed(!multipleAnswersAllowed)}
167
+ onValueChange={() => {
168
+ if (multipleAnswersAllowed) {
169
+ setMaxVotesPerPersonEnabled(false);
170
+ }
171
+ setMultipleAnswersAllowed(!multipleAnswersAllowed);
172
+ }}
168
173
  value={multipleAnswersAllowed}
169
174
  />
170
175
  </View>
@@ -6,8 +6,9 @@ import dayjs from 'dayjs';
6
6
 
7
7
  import merge from 'lodash/merge';
8
8
 
9
- import type { Attachment } from 'stream-chat';
9
+ import type { Attachment, PollState } from 'stream-chat';
10
10
 
11
+ import { useChatContext } from '../../contexts';
11
12
  import { useMessageContext } from '../../contexts/messageContext/MessageContext';
12
13
  import {
13
14
  MessageInputContext,
@@ -22,6 +23,7 @@ import {
22
23
  TranslationContextValue,
23
24
  useTranslationContext,
24
25
  } from '../../contexts/translationContext/TranslationContext';
26
+ import { useStateStore } from '../../hooks';
25
27
  import { DefaultStreamChatGenerics, FileTypes } from '../../types/types';
26
28
  import { getResizedImageUrl } from '../../utils/getResizedImageUrl';
27
29
  import { getTrimmedAttachmentTitle } from '../../utils/getTrimmedAttachmentTitle';
@@ -31,6 +33,7 @@ import { FileIcon as FileIconDefault } from '../Attachment/FileIcon';
31
33
  import { VideoThumbnail } from '../Attachment/VideoThumbnail';
32
34
  import { MessageAvatar as MessageAvatarDefault } from '../Message/MessageSimple/MessageAvatar';
33
35
  import { MessageTextContainer } from '../Message/MessageSimple/MessageTextContainer';
36
+ import { MessageType } from '../MessageList/hooks/useMessageList';
34
37
 
35
38
  const styles = StyleSheet.create({
36
39
  container: {
@@ -72,6 +75,16 @@ const styles = StyleSheet.create({
72
75
  },
73
76
  });
74
77
 
78
+ export type ReplySelectorReturnType = {
79
+ name?: string;
80
+ };
81
+
82
+ const selector = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
83
+ nextValue: PollState<StreamChatGenerics>,
84
+ ): ReplySelectorReturnType => ({
85
+ name: nextValue.name,
86
+ });
87
+
75
88
  type ReplyPropsWithContext<
76
89
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
77
90
  > = Pick<MessageInputContextValue<StreamChatGenerics>, 'quotedMessage'> &
@@ -134,6 +147,7 @@ const ReplyWithContext = <
134
147
  >(
135
148
  props: ReplyPropsWithContext<StreamChatGenerics>,
136
149
  ) => {
150
+ const { client } = useChatContext();
137
151
  const {
138
152
  attachmentSize = 40,
139
153
  FileAttachmentIcon,
@@ -167,6 +181,9 @@ const ReplyWithContext = <
167
181
  },
168
182
  } = useTheme();
169
183
 
184
+ const poll = client.polls.fromState((quotedMessage as MessageType)?.poll_id ?? '');
185
+ const { name: pollName }: ReplySelectorReturnType = useStateStore(poll?.state, selector) ?? {};
186
+
170
187
  const messageText = typeof quotedMessage === 'boolean' ? '' : quotedMessage.text || '';
171
188
 
172
189
  const emojiOnlyText = useMemo(() => {
@@ -262,8 +279,8 @@ const ReplyWithContext = <
262
279
  text:
263
280
  quotedMessage.type === 'deleted'
264
281
  ? `_${t('Message deleted')}_`
265
- : quotedMessage.poll
266
- ? `📊 ${quotedMessage.poll.name}`
282
+ : pollName
283
+ ? `📊 ${pollName}`
267
284
  : quotedMessage.text
268
285
  ? quotedMessage.text.length > 170
269
286
  ? `${quotedMessage.text.slice(0, 170)}...`
@@ -416,7 +416,7 @@ exports[`Thread should match thread snapshot 1`] = `
416
416
  "overflow": "hidden",
417
417
  },
418
418
  {
419
- "backgroundColor": "#F2F2F2",
419
+ "backgroundColor": "#FCFCFC",
420
420
  "borderBottomLeftRadius": 0,
421
421
  "borderBottomRightRadius": 16,
422
422
  "borderColor": "#ECEBEB",
@@ -742,7 +742,7 @@ exports[`Thread should match thread snapshot 1`] = `
742
742
  "overflow": "hidden",
743
743
  },
744
744
  {
745
- "backgroundColor": "#F2F2F2",
745
+ "backgroundColor": "#FCFCFC",
746
746
  "borderBottomLeftRadius": 0,
747
747
  "borderBottomRightRadius": 16,
748
748
  "borderColor": "#ECEBEB",
@@ -1068,7 +1068,7 @@ exports[`Thread should match thread snapshot 1`] = `
1068
1068
  "overflow": "hidden",
1069
1069
  },
1070
1070
  {
1071
- "backgroundColor": "#F2F2F2",
1071
+ "backgroundColor": "#FCFCFC",
1072
1072
  "borderBottomLeftRadius": 0,
1073
1073
  "borderBottomRightRadius": 16,
1074
1074
  "borderColor": "#ECEBEB",
@@ -1422,7 +1422,7 @@ exports[`Thread should match thread snapshot 1`] = `
1422
1422
  "overflow": "hidden",
1423
1423
  },
1424
1424
  {
1425
- "backgroundColor": "#F2F2F2",
1425
+ "backgroundColor": "#FCFCFC",
1426
1426
  "borderBottomLeftRadius": 0,
1427
1427
  "borderBottomRightRadius": 16,
1428
1428
  "borderColor": "#ECEBEB",
@@ -1218,10 +1218,8 @@ export const defaultTheme: Theme = {
1218
1218
  metaText: {
1219
1219
  fontSize: 12,
1220
1220
  },
1221
- receiverMessageBackgroundColor: Colors.white_smoke,
1222
1221
  replyBorder: {},
1223
1222
  replyContainer: {},
1224
- senderMessageBackgroundColor: Colors.grey_gainsboro,
1225
1223
  textContainer: {
1226
1224
  onlyEmojiMarkdown: { text: { fontSize: 50 } },
1227
1225
  },
@@ -30,7 +30,7 @@ import type { PreparedQueries, Table } from './types';
30
30
  *
31
31
  */
32
32
  export class QuickSqliteClient {
33
- static dbVersion = 6;
33
+ static dbVersion = 7;
34
34
 
35
35
  static dbName = DB_NAME;
36
36
  static dbLocation = DB_LOCATION;
@@ -8,7 +8,8 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
8
8
  import { isBlockedMessage } from '../../utils/utils';
9
9
  import { mapStorableToMessage } from '../mappers/mapStorableToMessage';
10
10
  import { QuickSqliteClient } from '../QuickSqliteClient';
11
- import type { TableRowJoinedUser } from '../types';
11
+ import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
12
+ import type { TableRow, TableRowJoinedUser } from '../types';
12
13
 
13
14
  export const getChannelMessages = <
14
15
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -35,6 +36,21 @@ export const getChannelMessages = <
35
36
  }
36
37
  messageIdVsReactions[reaction.messageId].push(reaction);
37
38
  });
39
+ const messageIdsVsPolls: Record<string, TableRow<'poll'>> = {};
40
+ const pollsById: Record<string, TableRow<'poll'>> = {};
41
+ const messagesWithPolls = messageRows.filter((message) => !!message.poll_id);
42
+ const polls = QuickSqliteClient.executeSql.apply(
43
+ null,
44
+ createSelectQuery('poll', ['*'], {
45
+ id: messagesWithPolls.map((message) => message.poll_id),
46
+ }),
47
+ );
48
+ polls.forEach((poll) => {
49
+ pollsById[poll.id] = poll;
50
+ });
51
+ messagesWithPolls.forEach((message) => {
52
+ messageIdsVsPolls[message.poll_id] = pollsById[message.poll_id];
53
+ });
38
54
 
39
55
  // Populate the messages.
40
56
  const cidVsMessages: Record<string, MessageResponse<StreamChatGenerics>[]> = {};
@@ -48,6 +64,7 @@ export const getChannelMessages = <
48
64
  mapStorableToMessage<StreamChatGenerics>({
49
65
  currentUserId,
50
66
  messageRow: m,
67
+ pollRow: messageIdsVsPolls[m.poll_id],
51
68
  reactionRows: messageIdVsReactions[m.id],
52
69
  }),
53
70
  );
@@ -30,7 +30,9 @@ export const updateMessage = ({
30
30
  return queries;
31
31
  }
32
32
 
33
- const storableMessage = mapMessageToStorable(message);
33
+ const storableMessage = mapMessageToStorable({
34
+ ...message,
35
+ });
34
36
 
35
37
  queries.push(
36
38
  createUpdateQuery('messages', storableMessage, {
@@ -1,41 +1,67 @@
1
- import type { PollResponse } from 'stream-chat';
1
+ import { isVoteAnswer, PollAnswer, PollResponse, PollVote } from 'stream-chat';
2
2
 
3
+ import { DefaultStreamChatGenerics } from '../../types/types';
4
+ import { mapPollToStorable } from '../mappers/mapPollToStorable';
5
+ import { mapStorableToPoll } from '../mappers/mapStorableToPoll';
3
6
  import { QuickSqliteClient } from '../QuickSqliteClient';
4
7
  import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
5
8
  import { createUpdateQuery } from '../sqlite-utils/createUpdateQuery';
6
9
  import type { PreparedQueries } from '../types';
7
10
 
8
- export const updatePollMessage = ({
11
+ export const updatePollMessage = <
12
+ StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
13
+ >({
14
+ eventType,
9
15
  flush = true,
10
16
  poll,
17
+ poll_vote,
18
+ userID,
11
19
  }: {
12
- poll: PollResponse;
20
+ eventType: string;
21
+ poll: PollResponse<StreamChatGenerics>;
22
+ userID: string;
13
23
  flush?: boolean;
24
+ poll_vote?: PollVote<StreamChatGenerics> | PollAnswer<StreamChatGenerics>;
14
25
  }) => {
15
26
  const queries: PreparedQueries[] = [];
16
27
 
17
- const messagesWithPoll = QuickSqliteClient.executeSql.apply(
28
+ const pollsFromDB = QuickSqliteClient.executeSql.apply(
18
29
  null,
19
- createSelectQuery('messages', ['*'], {
20
- poll_id: poll.id,
30
+ createSelectQuery('poll', ['*'], {
31
+ id: poll.id,
21
32
  }),
22
33
  );
23
34
 
24
- for (const message of messagesWithPoll) {
25
- const storablePoll = JSON.stringify({
35
+ for (const pollFromDB of pollsFromDB) {
36
+ const serializedPoll = mapStorableToPoll(pollFromDB);
37
+ const { latest_answers = [], own_votes = [] } = serializedPoll;
38
+ let newOwnVotes = own_votes;
39
+ if (poll_vote && poll_vote.user?.id === userID) {
40
+ newOwnVotes =
41
+ eventType === 'poll.vote_removed'
42
+ ? newOwnVotes.filter((vote) => vote.id !== poll_vote.id)
43
+ : [poll_vote, ...newOwnVotes.filter((vote) => vote.id !== poll_vote.id)];
44
+ }
45
+ let newLatestAnswers = latest_answers;
46
+ if (poll_vote && isVoteAnswer(poll_vote)) {
47
+ newLatestAnswers =
48
+ eventType === 'poll.vote_removed'
49
+ ? newLatestAnswers.filter((answer) => answer.id !== poll_vote?.id)
50
+ : [poll_vote, ...newLatestAnswers.filter((answer) => answer.id !== poll_vote?.id)];
51
+ }
52
+
53
+ const storablePoll = mapPollToStorable({
26
54
  ...poll,
27
- latest_votes: message.poll.latest_votes,
28
- own_votes: message.poll.own_votes,
55
+ latest_answers: newLatestAnswers,
56
+ own_votes: newOwnVotes,
29
57
  });
30
- const storableMessage = { ...message, poll: storablePoll };
31
58
 
32
59
  queries.push(
33
- createUpdateQuery('messages', storableMessage, {
34
- id: message.id,
60
+ createUpdateQuery('poll', storablePoll, {
61
+ id: poll.id,
35
62
  }),
36
63
  );
37
64
  QuickSqliteClient.logger?.('info', 'updatePoll', {
38
- message: storableMessage,
39
65
  poll: storablePoll,
40
66
  });
41
67
  }
@@ -1,6 +1,7 @@
1
1
  import type { MessageResponse } from 'stream-chat';
2
2
 
3
3
  import { mapMessageToStorable } from '../mappers/mapMessageToStorable';
4
+ import { mapPollToStorable } from '../mappers/mapPollToStorable';
4
5
  import { mapReactionToStorable } from '../mappers/mapReactionToStorable';
5
6
  import { mapUserToStorable } from '../mappers/mapUserToStorable';
6
7
  import { QuickSqliteClient } from '../QuickSqliteClient';
@@ -16,6 +17,7 @@ export const upsertMessages = ({
16
17
  const storableMessages: Array<ReturnType<typeof mapMessageToStorable>> = [];
17
18
  const storableUsers: Array<ReturnType<typeof mapUserToStorable>> = [];
18
19
  const storableReactions: Array<ReturnType<typeof mapReactionToStorable>> = [];
20
+ const storablePolls: Array<ReturnType<typeof mapPollToStorable>> = [];
19
21
 
20
22
  messages?.forEach((message: MessageResponse) => {
21
23
  storableMessages.push(mapMessageToStorable(message));
@@ -28,6 +30,9 @@ export const upsertMessages = ({
28
30
  }
29
31
  storableReactions.push(mapReactionToStorable(r));
30
32
  });
33
+ if (message.poll) {
34
+ storablePolls.push(mapPollToStorable(message.poll));
35
+ }
31
36
  });
32
37
 
33
38
  const finalQueries = [
@@ -36,11 +41,13 @@ export const upsertMessages = ({
36
41
  ...storableReactions.map((storableReaction) =>
37
42
  createUpsertQuery('reactions', storableReaction),
38
43
  ),
44
+ ...storablePolls.map((storablePoll) => createUpsertQuery('poll', storablePoll)),
39
45
  ];
40
46
 
41
47
  QuickSqliteClient.logger?.('info', 'upsertMessages', {
42
48
  flush,
43
49
  messages: storableMessages,
50
+ polls: storablePolls,
44
51
  reactions: storableReactions,
45
52
  users: storableUsers,
46
53
  });
@@ -18,6 +18,7 @@ export const mapMessageToStorable = (
18
18
  message_text_updated_at,
19
19
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
20
  own_reactions,
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
22
  poll,
22
23
  poll_id,
23
24
  reaction_groups,
@@ -36,7 +37,6 @@ export const mapMessageToStorable = (
36
37
  extraData: JSON.stringify(extraData),
37
38
  id,
38
39
  messageTextUpdatedAt: mapDateTimeToStorable(message_text_updated_at),
39
- poll: JSON.stringify(poll),
40
40
  poll_id: poll_id || '',
41
41
  reactionGroups: JSON.stringify(reaction_groups),
42
42
  text,
@@ -0,0 +1,53 @@
1
+ import type { PollResponse } from 'stream-chat';
2
+
3
+ import { mapDateTimeToStorable } from './mapDateTimeToStorable';
4
+
5
+ import type { TableRow } from '../types';
6
+
7
+ export const mapPollToStorable = (poll: PollResponse): TableRow<'poll'> => {
8
+ const {
9
+ allow_answers,
10
+ allow_user_suggested_options,
11
+ answers_count,
12
+ created_at,
13
+ created_by,
14
+ created_by_id,
15
+ description,
16
+ enforce_unique_vote,
17
+ id,
18
+ is_closed,
19
+ latest_answers,
20
+ latest_votes_by_option,
21
+ max_votes_allowed,
22
+ name,
23
+ options,
24
+ own_votes,
25
+ updated_at,
26
+ vote_count,
27
+ vote_counts_by_option,
28
+ voting_visibility,
29
+ } = poll;
30
+
31
+ return {
32
+ allow_answers,
33
+ allow_user_suggested_options,
34
+ answers_count,
35
+ created_at: mapDateTimeToStorable(created_at),
36
+ created_by: JSON.stringify(created_by), // decouple the users from the actual poll
37
+ created_by_id,
38
+ description,
39
+ enforce_unique_vote,
40
+ id,
41
+ is_closed,
42
+ latest_answers: JSON.stringify(latest_answers),
43
+ latest_votes_by_option: JSON.stringify(latest_votes_by_option),
44
+ max_votes_allowed,
45
+ name,
46
+ options: JSON.stringify(options),
47
+ own_votes: JSON.stringify(own_votes),
48
+ updated_at,
49
+ vote_count,
50
+ vote_counts_by_option: JSON.stringify(vote_counts_by_option),
51
+ voting_visibility,
52
+ };
53
+ };