Skip to content

Commit

Permalink
fix: poll offline fixes (#2772)
Browse files Browse the repository at this point in the history
* fix: message disallowed indicator display (#2754)

* fix: native image picker poll control (#2762)

* fix: check for channel validity before consuming config (#2760)

* fix: receiverMessageBackgroundColor hotfix (#2763)

* fix: receiverMessageBackgroundColor hotfix

* fix: tests

* chore(release): 5.41.3 [skip ci]

* chore(release): 1.31.4 [skip ci]

* fix: theme for the message bubble and replies (#2766)

* fix: theme for the message bubble and replies

* fix: theme for the message bubble and replies

* fix: add null coleasing operator

* fix: poll edge cases (#2768)

* fix: poll related edge cases with offline storage

* feat: offline db for polls wip

* fix: reconcile own_votes properly

* fix: all underlying offline store issues with polls

* fix: properly resolve own_votes and latest_answers

* fix: remove faulty poll check

* chore: remove commented out code

* chore: remove log

* fix: multiple answers bug and remove logs

* chore: remove index as we have primary key

* chore(release): 5.41.4 [skip ci]

* chore(release): 1.31.5 [skip ci]

* fix: errors during resolving conflicts and yarn.locks

* fix: pod cache revalidation

* fix: lint issues

---------

Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Khushal Agarwal <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent 77980fa commit fd88bef
Show file tree
Hide file tree
Showing 32 changed files with 353 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sample-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
${{ runner.os }}-pods-
- name: iOS Pods setup
working-directory: examples/SampleApp/ios
run: bundle exec pod install
run: pod update hermes-engine --no-repo-update
- name: Build and release Testflight QA
working-directory: examples/SampleApp
run: bundle exec fastlane deploy_to_testflight_qa deploy:${{ github.ref == 'refs/heads/develop' }};
Expand Down
14 changes: 14 additions & 0 deletions examples/SampleApp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

### [1.31.5](https://github.com/GetStream/stream-chat-react-native/compare/[email protected]@v1.31.5) (2024-11-08)


### Workspaces

* Following linked packages updated: [stream-chat-react-native]

### [1.31.4](https://github.com/GetStream/stream-chat-react-native/compare/[email protected]@v1.31.4) (2024-11-07)


### Workspaces

* Following linked packages updated: [stream-chat-react-native]

### [1.31.3](https://github.com/GetStream/stream-chat-react-native/compare/[email protected]@v1.31.3) (2024-11-04)


Expand Down
1 change: 1 addition & 0 deletions examples/SampleApp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ DEPENDENCIES
fastlane-plugin-stream_actions (= 0.3.73)
rubocop-performance
rubocop-require_tools
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.3.4p94
Expand Down
16 changes: 8 additions & 8 deletions examples/SampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ PODS:
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.10)
- SocketRocket (0.7.1)
- stream-chat-react-native (5.41.2):
- stream-chat-react-native (5.41.4):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -2499,8 +2499,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
boost: 1dca942403ed9342f98334bf4c3621f011aa7946
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
FBLazyVector: 7075bb12898bc3998fd60f4b7ca422496cc2cdf7
Firebase: 91fefd38712feb9186ea8996af6cbdef41473442
FirebaseAnalytics: b5efc493eb0f40ec560b04a472e3e1a15d39ca13
Expand All @@ -2513,8 +2513,8 @@ SPEC CHECKSUMS:
FirebaseMessaging: 4d52717dd820707cc4eadec5eb981b4832ec8d5d
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
GoogleAppMeasurement: f3abf08495ef2cba7829f15318c373b8d9226491
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
Expand All @@ -2524,7 +2524,7 @@ SPEC CHECKSUMS:
op-sqlite: 88dd68621bea1e7ea28606f76228a84a23d5ad58
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259
RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007
RCTTypeSafety: 7e6fe47bfb693c50d4669db1a480ca5331795f5b
Expand Down Expand Up @@ -2603,9 +2603,9 @@ SPEC CHECKSUMS:
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
stream-chat-react-native: fde9ff0df6796523ef66b7bef2274f0deef8ff19
stream-chat-react-native: 5f358230d87074128d47ea6bee43ef6a81720186
Yoga: 83048fe4b4ce15018a5e9ccbf0b06bd76fc643d4

PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d

COCOAPODS: 1.16.2
COCOAPODS: 1.14.3
2 changes: 1 addition & 1 deletion examples/SampleApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sampleapp",
"version": "1.31.3",
"version": "1.31.5",
"private": true,
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions examples/SampleApp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7361,10 +7361,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==

[email protected].2:
version "5.41.2"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.2.tgz#74fda94b80e28dd542a90abbfeb0291bf97a3d77"
integrity sha512-mr8yTj7O40w13EvOkhDTJH8OCisdB8f8REeFFt2y2LA2PWkFb5hpI1e5uFMW7XTuL58ftD1jXdF2ug6n4OUDug==
[email protected].4:
version "5.41.4"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d"
integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ==
dependencies:
"@gorhom/bottom-sheet" "^4.6.4"
dayjs "1.10.5"
Expand Down
18 changes: 18 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Change Log

### [5.41.4](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.3...v5.41.4) (2024-11-08)


### Bug Fixes

* poll edge cases ([#2768](https://github.com/GetStream/stream-chat-react-native/issues/2768)) ([b26b98c](https://github.com/GetStream/stream-chat-react-native/commit/b26b98c5cb34e5446c1600026fbaa1f442d8dbcb))
* theme for the message bubble and replies ([#2766](https://github.com/GetStream/stream-chat-react-native/issues/2766)) ([980c383](https://github.com/GetStream/stream-chat-react-native/commit/980c3832a4a59ebab07c67f1d24a50ebe587e8fe))

### [5.41.3](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.2...v5.41.3) (2024-11-07)


### Bug Fixes

* check for channel validity before consuming config ([#2760](https://github.com/GetStream/stream-chat-react-native/issues/2760)) ([ff53399](https://github.com/GetStream/stream-chat-react-native/commit/ff5339982914051b6e8f941a4799fc772ce409aa))
* message disallowed indicator display ([#2754](https://github.com/GetStream/stream-chat-react-native/issues/2754)) ([fe08bd7](https://github.com/GetStream/stream-chat-react-native/commit/fe08bd75ea1d7d3041b86b1e8519f2f04b9c19bc))
* native image picker poll control ([#2762](https://github.com/GetStream/stream-chat-react-native/issues/2762)) ([b9c49be](https://github.com/GetStream/stream-chat-react-native/commit/b9c49be85b8d7927dc64f55d7e9ba01b11737016))
* receiverMessageBackgroundColor hotfix ([#2763](https://github.com/GetStream/stream-chat-react-native/issues/2763)) ([5258a18](https://github.com/GetStream/stream-chat-react-native/commit/5258a18468fe9716918ec9e663ae5e0861b17df5))

### [5.41.2](https://github.com/GetStream/stream-chat-react-native/compare/v5.41.1...v5.41.2) (2024-11-04)


Expand Down
4 changes: 2 additions & 2 deletions package/expo-package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stream-chat-expo",
"description": "The official Expo SDK for Stream Chat, a service for building chat applications",
"version": "5.41.2",
"version": "5.41.4",
"author": {
"company": "Stream.io Inc",
"name": "Stream.io Inc"
Expand All @@ -10,7 +10,7 @@
"main": "src/index.js",
"types": "types/index.d.ts",
"dependencies": {
"stream-chat-react-native-core": "5.41.2"
"stream-chat-react-native-core": "5.41.4"
},
"peerDependencies": {
"expo": ">=51.0.0",
Expand Down
8 changes: 4 additions & 4 deletions package/expo-package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5113,10 +5113,10 @@ [email protected], stream-buffers@~2.2.0:
resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4"
integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==

[email protected].2:
version "5.41.2"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.2.tgz#74fda94b80e28dd542a90abbfeb0291bf97a3d77"
integrity sha512-mr8yTj7O40w13EvOkhDTJH8OCisdB8f8REeFFt2y2LA2PWkFb5hpI1e5uFMW7XTuL58ftD1jXdF2ug6n4OUDug==
[email protected].4:
version "5.41.4"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d"
integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ==
dependencies:
"@gorhom/bottom-sheet" "^4.6.4"
dayjs "1.10.5"
Expand Down
4 changes: 2 additions & 2 deletions package/native-package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stream-chat-react-native",
"description": "The official React Native SDK for Stream Chat, a service for building chat applications",
"version": "5.41.2",
"version": "5.41.4",
"homepage": "https://www.npmjs.com/package/stream-chat-react-native",
"author": {
"company": "Stream.io Inc",
Expand All @@ -20,7 +20,7 @@
"types": "types/index.d.ts",
"dependencies": {
"es6-symbol": "^3.1.3",
"stream-chat-react-native-core": "5.41.2"
"stream-chat-react-native-core": "5.41.4"
},
"peerDependencies": {
"@react-native-camera-roll/camera-roll": ">=7.8.0",
Expand Down
8 changes: 4 additions & 4 deletions package/native-package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4242,10 +4242,10 @@ statuses@~1.5.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==

[email protected].2:
version "5.41.2"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.2.tgz#74fda94b80e28dd542a90abbfeb0291bf97a3d77"
integrity sha512-mr8yTj7O40w13EvOkhDTJH8OCisdB8f8REeFFt2y2LA2PWkFb5hpI1e5uFMW7XTuL58ftD1jXdF2ug6n4OUDug==
[email protected].4:
version "5.41.4"
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-5.41.4.tgz#55104e1eb10f464b27d82b9566a18005723ea26d"
integrity sha512-Fe2AnbfZ98nRfP5BwMOwR2iae/hT8N5oEiYOb2FwbgtJqot4UFABZDCxMVcoYcFouOK1gc5BkTjdnXYYm/L8EQ==
dependencies:
"@gorhom/bottom-sheet" "^4.6.4"
dayjs "1.10.5"
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stream-chat-react-native-core",
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
"version": "5.41.2",
"version": "5.41.4",
"author": {
"company": "Stream.io Inc",
"name": "Stream.io Inc"
Expand Down
8 changes: 1 addition & 7 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -881,13 +881,7 @@ const ChannelWithContext = <
setThreadMessages(updatedThreadMessages);
}

if (
channel &&
thread?.id &&
event.message?.id === thread.id &&
!threadInstance &&
!thread.poll_id
) {
if (channel && thread?.id && event.message?.id === thread.id && !threadInstance) {
const updatedThread = channel.state.formatMessage(event.message);
setThread(updatedThread);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export type LatestMessagePreview<
export type LatestMessagePreviewSelectorReturnType = {
createdBy?: UserResponse | null;
latestVotesByOption?: Record<string, PollVote[]>;
name?: string;
};

const selector = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
nextValue: PollState<StreamChatGenerics>,
): LatestMessagePreviewSelectorReturnType => ({
createdBy: nextValue.created_by,
latestVotesByOption: nextValue.latest_votes_by_option,
name: nextValue.name,
});

const getMessageSenderName = <
Expand Down Expand Up @@ -145,8 +147,8 @@ const getLatestMessageDisplayText = <
{ bold: false, text: t('🏙 Attachment...') },
];
}
if (message.poll && pollState) {
const { createdBy, latestVotesByOption } = pollState;
if (message.poll_id && pollState) {
const { createdBy, latestVotesByOption, name } = pollState;
let latestVotes;
if (latestVotesByOption) {
latestVotes = Object.values(latestVotesByOption)
Expand All @@ -161,7 +163,7 @@ const getLatestMessageDisplayText = <
}
const previewMessage = `${
client.userID === previewUser?.id ? 'You' : previewUser?.name
} ${previewAction}: ${message.poll.name}`;
} ${previewAction}: ${name}`;
return [
{ bold: false, text: '📊 ' },
{ bold: false, text: previewMessage },
Expand Down Expand Up @@ -298,7 +300,8 @@ export const useLatestMessagePreview = <

useEffect(() => {
if (channelConfigExists) {
const read_events = channel.getConfig()?.read_events;
const read_events =
!channel.disconnected && !!channel?.id && channel.getConfig()?.read_events;
if (typeof read_events === 'boolean') {
setReadEvents(read_events);
}
Expand All @@ -310,7 +313,7 @@ export const useLatestMessagePreview = <
const poll = client.polls.fromState(pollId);
const pollState: LatestMessagePreviewSelectorReturnType =
useStateStore(poll?.state, selector) ?? {};
const { createdBy, latestVotesByOption } = pollState;
const { createdBy, latestVotesByOption, name } = pollState;

useEffect(
() =>
Expand All @@ -325,7 +328,15 @@ export const useLatestMessagePreview = <
}),
),
// eslint-disable-next-line react-hooks/exhaustive-deps
[channelLastMessageString, forceUpdate, readEvents, readStatus, latestVotesByOption, createdBy],
[
channelLastMessageString,
forceUpdate,
readEvents,
readStatus,
latestVotesByOption,
createdBy,
name,
],
);

return latestMessagePreview;
Expand Down
5 changes: 4 additions & 1 deletion package/src/components/Chat/hooks/handleEventToSyncDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,14 @@ export const handleEventToSyncDB = async <
'poll.vote_removed',
].includes(type)
) {
const poll = event.poll;
const { poll, poll_vote, type } = event;
if (poll) {
return updatePollMessage({
eventType: type,
flush,
poll,
poll_vote,
userID: client?.userID || '',
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const MessageContentWithContext = <

const {
theme: {
colors: { grey_gainsboro, grey_whisper },
colors: { grey_whisper, light_gray },
messageSimple: {
content: {
container: {
Expand Down Expand Up @@ -171,7 +171,7 @@ const MessageContentWithContext = <

const { hasThreadReplies, isMessageErrorType, isMessageReceivedOrErrorType } = useMessageData({});

const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : grey_gainsboro;
const repliesCurveColor = !isMessageReceivedOrErrorType ? backgroundColor : light_gray;

const getBorderRadius = () => {
// enum('top', 'middle', 'bottom', 'single')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const styles = StyleSheet.create({
},
messageRepliesCurve: {
borderTopWidth: 0,
borderWidth: 1,
borderWidth: 2,
height: 16,
width: 16,
},
Expand Down Expand Up @@ -181,13 +181,15 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
message: prevMessage,
noBorder: prevNoBorder,
onOpenThread: prevOnOpenThread,
repliesCurveColor: prevRepliesCurveColor,
t: prevT,
threadList: prevThreadList,
} = prevProps;
const {
message: nextMessage,
noBorder: nextNoBorder,
onOpenThread: nextOnOpenThread,
repliesCurveColor: nextRepliesCurveColor,
t: nextT,
threadList: nextThreadList,
} = nextProps;
Expand All @@ -201,6 +203,9 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
const noBorderEqual = prevNoBorder === nextNoBorder;
if (!noBorderEqual) return false;

const repliesCurveColorEqual = prevRepliesCurveColor === nextRepliesCurveColor;
if (!repliesCurveColorEqual) return false;

const tEqual = prevT === nextT;
if (!tEqual) return false;

Expand Down
2 changes: 1 addition & 1 deletion package/src/components/MessageInput/MessageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ export const MessageInput = <
* Disable the message input if the channel is frozen, or the user doesn't have the capability to send a message.
* Enable it in frozen mode, if it the input has editing state.
*/
if (!editing && disabled && !ownCapabilities.sendMessage && SendMessageDisallowedIndicator) {
if ((disabled || !ownCapabilities.sendMessage) && !editing && SendMessageDisallowedIndicator) {
return <SendMessageDisallowedIndicator />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ export const NativeAttachmentPicker = ({

// do not allow poll creation in threads
const buttons =
threadList && hasCreatePoll && ownCapabilities.sendPoll
? []
: [
!threadList && hasCreatePoll && ownCapabilities.sendPoll
? [
{
icon: <CreatePollIcon />,
id: 'Poll',
onPressHandler: () => {
openPollCreationDialog?.({ sendMessage });
},
},
];
]
: [];

if (hasImagePicker) {
buttons.push({
Expand Down
Loading

0 comments on commit fd88bef

Please sign in to comment.