Skip to content

Commit 4d44a44

Browse files
Merge pull request #95 from sendbird/v4.2.2
Add 4.2.2.
2 parents fdfe7fa + bb12e3a commit 4d44a44

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
## v4.2.2 (Fed 15, 2024)
2+
3+
### Improvements
4+
- Fixed the bug where `votedPollOptionIds` in `Poll` is always empty
5+
16
## v4.2.1 (Fed 5, 2024)
27

38
### Improvements
4-
- Fixed the bug where `getCachedMetaData()` in `BaseChannel` is not being updated when deleting metadata.
9+
- Fixed the bug where `getCachedMetaData()` in `BaseChannel` is not being updated when deleting metadata
510

611
## v4.2.0 (Jan 31, 2024)
712

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o
4848

4949
```yaml
5050
dependencies:
51-
sendbird_chat_sdk: ^4.2.1
51+
sendbird_chat_sdk: ^4.2.2
5252
```
5353
5454
- Run `flutter pub get` command in your project directory.

lib/src/internal/main/chat/chat.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ part 'chat_notifications.dart';
6060
part 'chat_push.dart';
6161
part 'chat_user.dart';
6262

63-
const sdkVersion = '4.2.1';
63+
const sdkVersion = '4.2.2';
6464

6565
// Internal implementation for main class. Do not directly access this class.
6666
class Chat with WidgetsBindingObserver {

lib/src/public/main/model/poll/poll.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Poll {
5858

5959
/// Contains optionIds which the current user voted on.
6060
/// If the current user has not voted, this list will be empty.
61-
@JsonKey(defaultValue: [])
61+
@JsonKey(name: 'voted_option_ids', defaultValue: [])
6262
List<int>? votedPollOptionIds;
6363

6464
Poll({
@@ -149,9 +149,12 @@ class Poll {
149149
if (event.json['poll']['allow_multiple_votes'] != null) {
150150
allowMultipleVotes = event.json['poll']['allow_multiple_votes'];
151151
}
152-
if (event.json['poll']['voted_poll_option_ids'] != null) {
153-
votedPollOptionIds = event.json['poll']['voted_poll_option_ids'];
154-
}
152+
153+
// voted_option_ids is not coming from PEDI, so validate it by SDK itself
154+
final optionIds = options.map((option) => option.id).toSet();
155+
final validVotedOptionIds =
156+
votedPollOptionIds?.toSet().intersection(optionIds).toList();
157+
votedPollOptionIds = validVotedOptionIds;
155158

156159
return true;
157160
} else {
@@ -175,6 +178,13 @@ class Poll {
175178
options.firstWhere((e) => (e.id == optionId)).voteCount = voteCount;
176179
}
177180
}
181+
182+
if (event.json['voted_option_ids'] != null) {
183+
votedPollOptionIds = (event.json['voted_option_ids'] as List<dynamic>?)
184+
?.map((e) => e as int)
185+
.toList() ??
186+
[];
187+
}
178188
} else {
179189
return false;
180190
}

lib/src/public/main/model/poll/poll.g.dart

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sendbird_chat_sdk
22
description: With Sendbird Chat for Flutter, you can easily build an in-app chat with all the essential messaging features.
3-
version: 4.2.1
3+
version: 4.2.2
44
homepage: https://sendbird.com
55
repository: https://github.com/sendbird/sendbird-chat-sdk-flutter
66
documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message

0 commit comments

Comments
 (0)