stream-chat-react-native-core 5.40.0 → 5.41.0

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 (59) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js +10 -10
  3. package/lib/commonjs/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  4. package/lib/commonjs/components/Poll/Poll.js +8 -8
  5. package/lib/commonjs/components/Poll/Poll.js.map +1 -1
  6. package/lib/commonjs/components/Poll/components/Button.js +16 -16
  7. package/lib/commonjs/components/Poll/components/Button.js.map +1 -1
  8. package/lib/commonjs/components/Poll/components/PollAnswersList.js +3 -3
  9. package/lib/commonjs/components/Poll/components/PollAnswersList.js.map +1 -1
  10. package/lib/commonjs/components/Poll/components/PollOption.js +11 -11
  11. package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -1
  12. package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js +7 -5
  13. package/lib/commonjs/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -1
  14. package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js +19 -13
  15. package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
  16. package/lib/commonjs/components/Poll/components/PollResults/PollResults.js +4 -4
  17. package/lib/commonjs/components/Poll/components/PollResults/PollResults.js.map +1 -1
  18. package/lib/commonjs/components/Poll/hooks/usePollState.js +30 -30
  19. package/lib/commonjs/components/Poll/hooks/usePollState.js.map +1 -1
  20. package/lib/commonjs/version.json +1 -1
  21. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js +10 -10
  22. package/lib/module/components/ChannelPreview/hooks/useLatestMessagePreview.js.map +1 -1
  23. package/lib/module/components/Poll/Poll.js +8 -8
  24. package/lib/module/components/Poll/Poll.js.map +1 -1
  25. package/lib/module/components/Poll/components/Button.js +16 -16
  26. package/lib/module/components/Poll/components/Button.js.map +1 -1
  27. package/lib/module/components/Poll/components/PollAnswersList.js +3 -3
  28. package/lib/module/components/Poll/components/PollAnswersList.js.map +1 -1
  29. package/lib/module/components/Poll/components/PollOption.js +11 -11
  30. package/lib/module/components/Poll/components/PollOption.js.map +1 -1
  31. package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js +7 -5
  32. package/lib/module/components/Poll/components/PollResults/PollOptionFullResults.js.map +1 -1
  33. package/lib/module/components/Poll/components/PollResults/PollResultItem.js +19 -13
  34. package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
  35. package/lib/module/components/Poll/components/PollResults/PollResults.js +4 -4
  36. package/lib/module/components/Poll/components/PollResults/PollResults.js.map +1 -1
  37. package/lib/module/components/Poll/hooks/usePollState.js +30 -30
  38. package/lib/module/components/Poll/hooks/usePollState.js.map +1 -1
  39. package/lib/module/version.json +1 -1
  40. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts +2 -2
  41. package/lib/typescript/components/ChannelPreview/hooks/useLatestMessagePreview.d.ts.map +1 -1
  42. package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -1
  43. package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts +3 -1
  44. package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -1
  45. package/lib/typescript/components/Poll/hooks/usePollOptionVotesPagination.d.ts +1 -1
  46. package/lib/typescript/components/Poll/hooks/usePollState.d.ts +10 -10
  47. package/lib/typescript/components/Poll/hooks/usePollState.d.ts.map +1 -1
  48. package/package.json +1 -1
  49. package/src/components/ChannelPreview/hooks/useLatestMessagePreview.ts +10 -17
  50. package/src/components/Poll/Poll.tsx +5 -5
  51. package/src/components/Poll/components/Button.tsx +14 -14
  52. package/src/components/Poll/components/PollAnswersList.tsx +3 -3
  53. package/src/components/Poll/components/PollOption.tsx +8 -13
  54. package/src/components/Poll/components/PollResults/PollOptionFullResults.tsx +4 -4
  55. package/src/components/Poll/components/PollResults/PollResultItem.tsx +13 -9
  56. package/src/components/Poll/components/PollResults/PollResults.tsx +3 -3
  57. package/src/components/Poll/hooks/usePollOptionVotesPagination.ts +1 -1
  58. package/src/components/Poll/hooks/usePollState.ts +40 -40
  59. package/src/version.json +1 -1
@@ -16,9 +16,9 @@ export type PollResultItemProps<
16
16
  option: PollOption<StreamChatGenerics>;
17
17
  };
18
18
 
19
- export const PollVote = (vote: PollVoteClass) => {
19
+ export const PollVote = ({ vote }: { vote: PollVoteClass }) => {
20
20
  const { t, tDateTimeParser } = useTranslationContext();
21
- const { voting_visibility } = usePollState();
21
+ const { votingVisibility } = usePollState();
22
22
  const {
23
23
  theme: {
24
24
  colors: { black, text_low_emphasis },
@@ -42,12 +42,12 @@ export const PollVote = (vote: PollVoteClass) => {
42
42
  );
43
43
 
44
44
  const isAnonymous = useMemo(
45
- () => voting_visibility === VotingVisibility.anonymous,
46
- [voting_visibility],
45
+ () => votingVisibility === VotingVisibility.anonymous,
46
+ [votingVisibility],
47
47
  );
48
48
 
49
49
  return (
50
- <View key={`results_vote_${vote.id}`} style={[styles.voteContainer, container]}>
50
+ <View style={[styles.voteContainer, container]}>
51
51
  <View style={{ flexDirection: 'row' }}>
52
52
  {!isAnonymous && vote.user?.image ? (
53
53
  <Avatar image={vote.user.image as string} key={vote.id} size={20} />
@@ -61,9 +61,13 @@ export const PollVote = (vote: PollVoteClass) => {
61
61
  );
62
62
  };
63
63
 
64
+ const PollResultsVoteItem = (vote: PollVoteClass) => (
65
+ <PollVote key={`results_vote_${vote.id}`} vote={vote} />
66
+ );
67
+
64
68
  export const PollResultsItem = ({ option }: PollResultItemProps) => {
65
69
  const { t } = useTranslationContext();
66
- const { latest_votes_by_option, vote_counts_by_option } = usePollState();
70
+ const { latestVotesByOption, voteCountsByOption } = usePollState();
67
71
 
68
72
  const {
69
73
  theme: {
@@ -81,12 +85,12 @@ export const PollResultsItem = ({ option }: PollResultItemProps) => {
81
85
  <View style={[styles.headerContainer, headerContainer]}>
82
86
  <Text style={[styles.title, { color: black }, title]}>{option.text}</Text>
83
87
  <Text style={[styles.voteCount, { color: black }, voteCount]}>
84
- {t<string>('{{count}} votes', { count: vote_counts_by_option[option.id] ?? 0 })}
88
+ {t<string>('{{count}} votes', { count: voteCountsByOption[option.id] ?? 0 })}
85
89
  </Text>
86
90
  </View>
87
- {latest_votes_by_option?.[option.id]?.length > 0 ? (
91
+ {latestVotesByOption?.[option.id]?.length > 0 ? (
88
92
  <View style={{ marginTop: 16 }}>
89
- {(latest_votes_by_option?.[option.id] ?? []).slice(0, 5).map(PollVote)}
93
+ {(latestVotesByOption?.[option.id] ?? []).slice(0, 5).map(PollResultsVoteItem)}
90
94
  </View>
91
95
  ) : null}
92
96
  <ShowAllVotesButton option={option} />
@@ -16,14 +16,14 @@ export type PollResultsProps = PollContextValue & {
16
16
  export const PollResultsContent = ({
17
17
  additionalScrollViewProps,
18
18
  }: Pick<PollResultsProps, 'additionalScrollViewProps'>) => {
19
- const { name, options, vote_counts_by_option } = usePollState();
19
+ const { name, options, voteCountsByOption } = usePollState();
20
20
 
21
21
  const sortedOptions = useMemo(
22
22
  () =>
23
23
  [...options].sort(
24
- (a, b) => (vote_counts_by_option[b.id] ?? 0) - (vote_counts_by_option[a.id] ?? 0),
24
+ (a, b) => (voteCountsByOption[b.id] ?? 0) - (voteCountsByOption[a.id] ?? 0),
25
25
  ),
26
- [vote_counts_by_option, options],
26
+ [voteCountsByOption, options],
27
27
  );
28
28
 
29
29
  const {
@@ -22,7 +22,7 @@ export type UsePollVotesReturnType = {
22
22
 
23
23
  /**
24
24
  * A hook that queries votes for a given Poll and returns them in a paginated fashion.
25
- * Should be used instead of the latest_votes_by_option property within the reactive state in the
25
+ * Should be used instead of the latestVotesByOption property within the reactive state in the
26
26
  * event that we need more than the top 10 votes for an option. The returned property votes will
27
27
  * automatically be updated and trigger a state change when paginating further. Querying for votes
28
28
  * can only be done on an option by option basis.
@@ -19,21 +19,21 @@ import { usePollContext } from '../../../contexts';
19
19
  import { DefaultStreamChatGenerics } from '../../../types/types';
20
20
 
21
21
  export type UsePollStateSelectorReturnType = {
22
- allow_answers: boolean | undefined;
23
- allow_user_suggested_options: boolean | undefined;
24
- answers_count: number;
25
- created_by: UserResponse | null;
26
- enforce_unique_vote: boolean;
27
- is_closed: boolean | undefined;
28
- latest_votes_by_option: Record<string, PollVote[]>;
29
- max_votes_allowed: number;
22
+ allowAnswers: boolean | undefined;
23
+ allowUserSuggestedOptions: boolean | undefined;
24
+ answersCount: number;
25
+ createdBy: UserResponse | null;
26
+ enforceUniqueVote: boolean;
27
+ isClosed: boolean | undefined;
28
+ latestVotesByOption: Record<string, PollVote[]>;
30
29
  maxVotedOptionIds: string[];
30
+ maxVotesAllowed: number;
31
31
  name: string;
32
32
  options: PollOption[];
33
33
  ownAnswer: PollAnswer | undefined;
34
34
  ownVotesByOptionId: Record<string, PollVote>;
35
- vote_counts_by_option: Record<string, number>;
36
- voting_visibility: VotingVisibility | undefined;
35
+ voteCountsByOption: Record<string, number>;
36
+ votingVisibility: VotingVisibility | undefined;
37
37
  };
38
38
 
39
39
  export type UsePollStateReturnType<
@@ -49,41 +49,41 @@ export type UsePollStateReturnType<
49
49
  const selector = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
50
50
  nextValue: PollState<StreamChatGenerics>,
51
51
  ): UsePollStateSelectorReturnType => ({
52
- allow_answers: nextValue.allow_answers,
53
- allow_user_suggested_options: nextValue.allow_user_suggested_options,
54
- answers_count: nextValue.answers_count,
55
- created_by: nextValue.created_by,
56
- enforce_unique_vote: nextValue.enforce_unique_vote,
57
- is_closed: nextValue.is_closed,
58
- latest_votes_by_option: nextValue.latest_votes_by_option,
59
- max_votes_allowed: nextValue.max_votes_allowed,
52
+ allowAnswers: nextValue.allow_answers,
53
+ allowUserSuggestedOptions: nextValue.allow_user_suggested_options,
54
+ answersCount: nextValue.answers_count,
55
+ createdBy: nextValue.created_by,
56
+ enforceUniqueVote: nextValue.enforce_unique_vote,
57
+ isClosed: nextValue.is_closed,
58
+ latestVotesByOption: nextValue.latest_votes_by_option,
60
59
  maxVotedOptionIds: nextValue.maxVotedOptionIds,
60
+ maxVotesAllowed: nextValue.max_votes_allowed,
61
61
  name: nextValue.name,
62
62
  options: nextValue.options,
63
63
  ownAnswer: nextValue.ownAnswer,
64
64
  ownVotesByOptionId: nextValue.ownVotesByOptionId,
65
- vote_counts_by_option: nextValue.vote_counts_by_option,
66
- voting_visibility: nextValue.voting_visibility,
65
+ voteCountsByOption: nextValue.vote_counts_by_option,
66
+ votingVisibility: nextValue.voting_visibility,
67
67
  });
68
68
 
69
69
  export const usePollState = (): UsePollStateReturnType => {
70
70
  const { message, poll } = usePollContext();
71
71
  const {
72
- allow_answers,
73
- allow_user_suggested_options,
74
- answers_count,
75
- created_by,
76
- enforce_unique_vote,
77
- is_closed,
78
- latest_votes_by_option,
79
- max_votes_allowed,
72
+ allowAnswers,
73
+ allowUserSuggestedOptions,
74
+ answersCount,
75
+ createdBy,
76
+ enforceUniqueVote,
77
+ isClosed,
78
+ latestVotesByOption,
80
79
  maxVotedOptionIds,
80
+ maxVotesAllowed,
81
81
  name,
82
82
  options,
83
83
  ownAnswer,
84
84
  ownVotesByOptionId,
85
- vote_counts_by_option,
86
- voting_visibility,
85
+ voteCountsByOption,
86
+ votingVisibility,
87
87
  } = usePollStateStore(selector);
88
88
 
89
89
  const addOption = useCallback(
@@ -102,21 +102,21 @@ export const usePollState = (): UsePollStateReturnType => {
102
102
  return {
103
103
  addComment,
104
104
  addOption,
105
- allow_answers,
106
- allow_user_suggested_options,
107
- answers_count,
108
- created_by,
105
+ allowAnswers,
106
+ allowUserSuggestedOptions,
107
+ answersCount,
108
+ createdBy,
109
109
  endVote,
110
- enforce_unique_vote,
111
- is_closed,
112
- latest_votes_by_option,
113
- max_votes_allowed,
110
+ enforceUniqueVote,
111
+ isClosed,
112
+ latestVotesByOption,
114
113
  maxVotedOptionIds,
114
+ maxVotesAllowed,
115
115
  name,
116
116
  options,
117
117
  ownAnswer,
118
118
  ownVotesByOptionId,
119
- vote_counts_by_option,
120
- voting_visibility,
119
+ voteCountsByOption,
120
+ votingVisibility,
121
121
  };
122
122
  };
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.40.0"
2
+ "version": "5.41.0"
3
3
  }