From 41e3c6504e3a264e24880f2de429a5ec8288a147 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 16:42:29 +0200 Subject: [PATCH 1/7] fix(llc): Fix `UpsertPushPreferencesResponse` null values parsing --- .../lib/src/core/api/responses.dart | 15 +- .../lib/src/core/api/responses.g.dart | 595 +++++++++--------- .../test/src/core/api/responses_test.dart | 6 +- 3 files changed, 329 insertions(+), 287 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.dart b/packages/stream_chat/lib/src/core/api/responses.dart index cbd4505678..49c186010a 100644 --- a/packages/stream_chat/lib/src/core/api/responses.dart +++ b/packages/stream_chat/lib/src/core/api/responses.dart @@ -834,8 +834,11 @@ class GetUnreadCountResponse extends _BaseResponse { /// Model response for [StreamChatClient.setPushPreferences] api call @JsonSerializable(createToJson: false) class UpsertPushPreferencesResponse extends _BaseResponse { - /// Mapping of user IDs to their push preferences - @JsonKey(defaultValue: {}) + /// Mapping of user IDs to their push preferences. + /// + /// Users whose user-global preferences were not touched by the upsert call + /// (the server returns `null` for them) are omitted from this map. + @JsonKey(fromJson: _userPreferencesFromJson) late Map userPreferences; /// Mapping of user IDs to their channel-specific push preferences @@ -846,3 +849,11 @@ class UpsertPushPreferencesResponse extends _BaseResponse { static UpsertPushPreferencesResponse fromJson(Map json) => _$UpsertPushPreferencesResponseFromJson(json); } + +Map _userPreferencesFromJson(Map? json) { + if (json == null) return {}; + return { + for (final MapEntry(:key, :value) in json.entries) + if (value != null) key: PushPreference.fromJson(value as Map), + }; +} \ No newline at end of file diff --git a/packages/stream_chat/lib/src/core/api/responses.g.dart b/packages/stream_chat/lib/src/core/api/responses.g.dart index 30dd445960..6bb4081862 100644 --- a/packages/stream_chat/lib/src/core/api/responses.g.dart +++ b/packages/stream_chat/lib/src/core/api/responses.g.dart @@ -25,90 +25,99 @@ Map _$ErrorResponseToJson(ErrorResponse instance) => SyncResponse _$SyncResponseFromJson(Map json) => SyncResponse() ..duration = json['duration'] as String? - ..events = (json['events'] as List?) + ..events = + (json['events'] as List?) ?.map((e) => Event.fromJson(e as Map)) .toList() ?? []; QueryChannelsResponse _$QueryChannelsResponseFromJson( - Map json) => - QueryChannelsResponse() - ..duration = json['duration'] as String? - ..channels = (json['channels'] as List?) - ?.map((e) => ChannelState.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => QueryChannelsResponse() + ..duration = json['duration'] as String? + ..channels = + (json['channels'] as List?) + ?.map((e) => ChannelState.fromJson(e as Map)) + .toList() ?? + []; TranslateMessageResponse _$TranslateMessageResponseFromJson( - Map json) => - TranslateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); + Map json, +) => TranslateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); QueryMembersResponse _$QueryMembersResponseFromJson( - Map json) => - QueryMembersResponse() - ..duration = json['duration'] as String? - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => QueryMembersResponse() + ..duration = json['duration'] as String? + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + []; PartialUpdateMemberResponse _$PartialUpdateMemberResponseFromJson( - Map json) => - PartialUpdateMemberResponse() - ..duration = json['duration'] as String? - ..channelMember = - Member.fromJson(json['channel_member'] as Map); + Map json, +) => PartialUpdateMemberResponse() + ..duration = json['duration'] as String? + ..channelMember = Member.fromJson( + json['channel_member'] as Map, + ); QueryUsersResponse _$QueryUsersResponseFromJson(Map json) => QueryUsersResponse() ..duration = json['duration'] as String? - ..users = (json['users'] as List?) + ..users = + (json['users'] as List?) ?.map((e) => User.fromJson(e as Map)) .toList() ?? []; QueryBannedUsersResponse _$QueryBannedUsersResponseFromJson( - Map json) => - QueryBannedUsersResponse() - ..duration = json['duration'] as String? - ..bans = (json['bans'] as List?) - ?.map((e) => BannedUser.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => QueryBannedUsersResponse() + ..duration = json['duration'] as String? + ..bans = + (json['bans'] as List?) + ?.map((e) => BannedUser.fromJson(e as Map)) + .toList() ?? + []; QueryReactionsResponse _$QueryReactionsResponseFromJson( - Map json) => - QueryReactionsResponse() - ..duration = json['duration'] as String? - ..reactions = (json['reactions'] as List?) - ?.map((e) => Reaction.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => QueryReactionsResponse() + ..duration = json['duration'] as String? + ..reactions = + (json['reactions'] as List?) + ?.map((e) => Reaction.fromJson(e as Map)) + .toList() ?? + []; QueryRepliesResponse _$QueryRepliesResponseFromJson( - Map json) => - QueryRepliesResponse() - ..duration = json['duration'] as String? - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => QueryRepliesResponse() + ..duration = json['duration'] as String? + ..messages = + (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; ListDevicesResponse _$ListDevicesResponseFromJson(Map json) => ListDevicesResponse() ..duration = json['duration'] as String? - ..devices = (json['devices'] as List?) + ..devices = + (json['devices'] as List?) ?.map((e) => Device.fromJson(e as Map)) .toList() ?? []; SendAttachmentResponse _$SendAttachmentResponseFromJson( - Map json) => - SendAttachmentResponse() - ..duration = json['duration'] as String? - ..file = json['file'] as String?; + Map json, +) => SendAttachmentResponse() + ..duration = json['duration'] as String? + ..file = json['file'] as String?; SendFileResponse _$SendFileResponseFromJson(Map json) => SendFileResponse() @@ -117,32 +126,33 @@ SendFileResponse _$SendFileResponseFromJson(Map json) => ..thumbUrl = json['thumb_url'] as String?; SendReactionResponse _$SendReactionResponseFromJson( - Map json) => - SendReactionResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map) - ..reaction = Reaction.fromJson(json['reaction'] as Map); + Map json, +) => SendReactionResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map) + ..reaction = Reaction.fromJson(json['reaction'] as Map); ConnectGuestUserResponse _$ConnectGuestUserResponseFromJson( - Map json) => - ConnectGuestUserResponse() - ..duration = json['duration'] as String? - ..accessToken = json['access_token'] as String - ..user = User.fromJson(json['user'] as Map); + Map json, +) => ConnectGuestUserResponse() + ..duration = json['duration'] as String? + ..accessToken = json['access_token'] as String + ..user = User.fromJson(json['user'] as Map); UpdateUsersResponse _$UpdateUsersResponseFromJson(Map json) => UpdateUsersResponse() ..duration = json['duration'] as String? - ..users = (json['users'] as Map?)?.map( + ..users = + (json['users'] as Map?)?.map( (k, e) => MapEntry(k, User.fromJson(e as Map)), ) ?? {}; UpdateMessageResponse _$UpdateMessageResponseFromJson( - Map json) => - UpdateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); + Map json, +) => UpdateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); SendMessageResponse _$SendMessageResponseFromJson(Map json) => SendMessageResponse() @@ -158,72 +168,75 @@ GetMessageResponse _$GetMessageResponseFromJson(Map json) => : ChannelModel.fromJson(json['channel'] as Map); SearchMessagesResponse _$SearchMessagesResponseFromJson( - Map json) => - SearchMessagesResponse() - ..duration = json['duration'] as String? - ..results = (json['results'] as List?) - ?.map( - (e) => GetMessageResponse.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String? - ..previous = json['previous'] as String?; + Map json, +) => SearchMessagesResponse() + ..duration = json['duration'] as String? + ..results = + (json['results'] as List?) + ?.map((e) => GetMessageResponse.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String? + ..previous = json['previous'] as String?; GetMessagesByIdResponse _$GetMessagesByIdResponseFromJson( - Map json) => - GetMessagesByIdResponse() - ..duration = json['duration'] as String? - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => GetMessagesByIdResponse() + ..duration = json['duration'] as String? + ..messages = + (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; UpdateChannelResponse _$UpdateChannelResponseFromJson( - Map json) => - UpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json, +) => UpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson( - Map json) => - PartialUpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList(); + Map json, +) => PartialUpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList(); InviteMembersResponse _$InviteMembersResponseFromJson( - Map json) => - InviteMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json, +) => InviteMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); RemoveMembersResponse _$RemoveMembersResponseFromJson( - Map json) => - RemoveMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json, +) => RemoveMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); SendActionResponse _$SendActionResponseFromJson(Map json) => SendActionResponse() @@ -236,7 +249,8 @@ AddMembersResponse _$AddMembersResponseFromJson(Map json) => AddMembersResponse() ..duration = json['duration'] as String? ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) + ..members = + (json['members'] as List?) ?.map((e) => Member.fromJson(e as Map)) .toList() ?? [] @@ -245,67 +259,72 @@ AddMembersResponse _$AddMembersResponseFromJson(Map json) => : Message.fromJson(json['message'] as Map); AcceptInviteResponse _$AcceptInviteResponseFromJson( - Map json) => - AcceptInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json, +) => AcceptInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); RejectInviteResponse _$RejectInviteResponseFromJson( - Map json) => - RejectInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json, +) => RejectInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); EmptyResponse _$EmptyResponseFromJson(Map json) => EmptyResponse()..duration = json['duration'] as String?; ChannelStateResponse _$ChannelStateResponseFromJson( - Map json) => - ChannelStateResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..messages = (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - [] - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..watcherCount = (json['watcher_count'] as num?)?.toInt() ?? 0 - ..read = (json['read'] as List?) - ?.map((e) => Read.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => ChannelStateResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..messages = + (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + [] + ..members = + (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..watcherCount = (json['watcher_count'] as num?)?.toInt() ?? 0 + ..read = + (json['read'] as List?) + ?.map((e) => Read.fromJson(e as Map)) + .toList() ?? + []; OGAttachmentResponse _$OGAttachmentResponseFromJson( - Map json) => - OGAttachmentResponse() - ..duration = json['duration'] as String? - ..ogScrapeUrl = json['og_scrape_url'] as String - ..assetUrl = json['asset_url'] as String? - ..authorLink = json['author_link'] as String? - ..authorName = json['author_name'] as String? - ..imageUrl = json['image_url'] as String? - ..text = json['text'] as String? - ..thumbUrl = json['thumb_url'] as String? - ..title = json['title'] as String? - ..titleLink = json['title_link'] as String? - ..type = json['type'] as String?; + Map json, +) => OGAttachmentResponse() + ..duration = json['duration'] as String? + ..ogScrapeUrl = json['og_scrape_url'] as String + ..assetUrl = json['asset_url'] as String? + ..authorLink = json['author_link'] as String? + ..authorName = json['author_name'] as String? + ..imageUrl = json['image_url'] as String? + ..text = json['text'] as String? + ..thumbUrl = json['thumb_url'] as String? + ..title = json['title'] as String? + ..titleLink = json['title_link'] as String? + ..type = json['type'] as String?; CallTokenPayload _$CallTokenPayloadFromJson(Map json) => CallTokenPayload() @@ -329,13 +348,14 @@ UserBlockResponse _$UserBlockResponseFromJson(Map json) => ..createdAt = DateTime.parse(json['created_at'] as String); BlockedUsersResponse _$BlockedUsersResponseFromJson( - Map json) => - BlockedUsersResponse() - ..duration = json['duration'] as String? - ..blocks = (json['blocks'] as List?) - ?.map((e) => UserBlock.fromJson(e as Map)) - .toList() ?? - []; + Map json, +) => BlockedUsersResponse() + ..duration = json['duration'] as String? + ..blocks = + (json['blocks'] as List?) + ?.map((e) => UserBlock.fromJson(e as Map)) + .toList() ?? + []; CreatePollResponse _$CreatePollResponseFromJson(Map json) => CreatePollResponse() @@ -353,56 +373,61 @@ UpdatePollResponse _$UpdatePollResponseFromJson(Map json) => ..poll = Poll.fromJson(json['poll'] as Map); CreatePollOptionResponse _$CreatePollOptionResponseFromJson( - Map json) => - CreatePollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = - PollOption.fromJson(json['poll_option'] as Map); + Map json, +) => CreatePollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = PollOption.fromJson( + json['poll_option'] as Map, + ); GetPollOptionResponse _$GetPollOptionResponseFromJson( - Map json) => - GetPollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = - PollOption.fromJson(json['poll_option'] as Map); + Map json, +) => GetPollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = PollOption.fromJson( + json['poll_option'] as Map, + ); UpdatePollOptionResponse _$UpdatePollOptionResponseFromJson( - Map json) => - UpdatePollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = - PollOption.fromJson(json['poll_option'] as Map); + Map json, +) => UpdatePollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = PollOption.fromJson( + json['poll_option'] as Map, + ); CastPollVoteResponse _$CastPollVoteResponseFromJson( - Map json) => - CastPollVoteResponse() - ..duration = json['duration'] as String? - ..vote = PollVote.fromJson(json['vote'] as Map); + Map json, +) => CastPollVoteResponse() + ..duration = json['duration'] as String? + ..vote = PollVote.fromJson(json['vote'] as Map); RemovePollVoteResponse _$RemovePollVoteResponseFromJson( - Map json) => - RemovePollVoteResponse() - ..duration = json['duration'] as String? - ..vote = PollVote.fromJson(json['vote'] as Map); + Map json, +) => RemovePollVoteResponse() + ..duration = json['duration'] as String? + ..vote = PollVote.fromJson(json['vote'] as Map); QueryPollsResponse _$QueryPollsResponseFromJson(Map json) => QueryPollsResponse() ..duration = json['duration'] as String? - ..polls = (json['polls'] as List?) + ..polls = + (json['polls'] as List?) ?.map((e) => Poll.fromJson(e as Map)) .toList() ?? [] ..next = json['next'] as String?; QueryPollVotesResponse _$QueryPollVotesResponseFromJson( - Map json) => - QueryPollVotesResponse() - ..duration = json['duration'] as String? - ..votes = (json['votes'] as List?) - ?.map((e) => PollVote.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json, +) => QueryPollVotesResponse() + ..duration = json['duration'] as String? + ..votes = + (json['votes'] as List?) + ?.map((e) => PollVote.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; GetThreadResponse _$GetThreadResponseFromJson(Map json) => GetThreadResponse() @@ -410,20 +435,21 @@ GetThreadResponse _$GetThreadResponseFromJson(Map json) => ..thread = Thread.fromJson(json['thread'] as Map); UpdateThreadResponse _$UpdateThreadResponseFromJson( - Map json) => - UpdateThreadResponse() - ..duration = json['duration'] as String? - ..thread = Thread.fromJson(json['thread'] as Map); + Map json, +) => UpdateThreadResponse() + ..duration = json['duration'] as String? + ..thread = Thread.fromJson(json['thread'] as Map); QueryThreadsResponse _$QueryThreadsResponseFromJson( - Map json) => - QueryThreadsResponse() - ..duration = json['duration'] as String? - ..threads = (json['threads'] as List?) - ?.map((e) => Thread.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json, +) => QueryThreadsResponse() + ..duration = json['duration'] as String? + ..threads = + (json['threads'] as List?) + ?.map((e) => Thread.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; CreateDraftResponse _$CreateDraftResponseFromJson(Map json) => CreateDraftResponse() @@ -438,77 +464,78 @@ GetDraftResponse _$GetDraftResponseFromJson(Map json) => QueryDraftsResponse _$QueryDraftsResponseFromJson(Map json) => QueryDraftsResponse() ..duration = json['duration'] as String? - ..drafts = (json['drafts'] as List?) + ..drafts = + (json['drafts'] as List?) ?.map((e) => Draft.fromJson(e as Map)) .toList() ?? [] ..next = json['next'] as String?; CreateReminderResponse _$CreateReminderResponseFromJson( - Map json) => - CreateReminderResponse() - ..duration = json['duration'] as String? - ..reminder = - MessageReminder.fromJson(json['reminder'] as Map); + Map json, +) => CreateReminderResponse() + ..duration = json['duration'] as String? + ..reminder = MessageReminder.fromJson( + json['reminder'] as Map, + ); UpdateReminderResponse _$UpdateReminderResponseFromJson( - Map json) => - UpdateReminderResponse() - ..duration = json['duration'] as String? - ..reminder = - MessageReminder.fromJson(json['reminder'] as Map); + Map json, +) => UpdateReminderResponse() + ..duration = json['duration'] as String? + ..reminder = MessageReminder.fromJson( + json['reminder'] as Map, + ); QueryRemindersResponse _$QueryRemindersResponseFromJson( - Map json) => - QueryRemindersResponse() - ..duration = json['duration'] as String? - ..reminders = (json['reminders'] as List?) - ?.map((e) => MessageReminder.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json, +) => QueryRemindersResponse() + ..duration = json['duration'] as String? + ..reminders = + (json['reminders'] as List?) + ?.map((e) => MessageReminder.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; GetUnreadCountResponse _$GetUnreadCountResponseFromJson( - Map json) => - GetUnreadCountResponse() - ..duration = json['duration'] as String? - ..totalUnreadCount = (json['total_unread_count'] as num).toInt() - ..totalUnreadThreadsCount = - (json['total_unread_threads_count'] as num).toInt() - ..totalUnreadCountByTeam = - (json['total_unread_count_by_team'] as Map?)?.map( + Map json, +) => GetUnreadCountResponse() + ..duration = json['duration'] as String? + ..totalUnreadCount = (json['total_unread_count'] as num).toInt() + ..totalUnreadThreadsCount = (json['total_unread_threads_count'] as num) + .toInt() + ..totalUnreadCountByTeam = + (json['total_unread_count_by_team'] as Map?)?.map( (k, e) => MapEntry(k, (e as num).toInt()), ) - ..channels = (json['channels'] as List) - .map((e) => UnreadCountsChannel.fromJson(e as Map)) - .toList() - ..channelType = (json['channel_type'] as List) - .map((e) => - UnreadCountsChannelType.fromJson(e as Map)) - .toList() - ..threads = (json['threads'] as List) - .map((e) => UnreadCountsThread.fromJson(e as Map)) - .toList(); + ..channels = (json['channels'] as List) + .map((e) => UnreadCountsChannel.fromJson(e as Map)) + .toList() + ..channelType = (json['channel_type'] as List) + .map((e) => UnreadCountsChannelType.fromJson(e as Map)) + .toList() + ..threads = (json['threads'] as List) + .map((e) => UnreadCountsThread.fromJson(e as Map)) + .toList(); UpsertPushPreferencesResponse _$UpsertPushPreferencesResponseFromJson( - Map json) => - UpsertPushPreferencesResponse() - ..duration = json['duration'] as String? - ..userPreferences = (json['user_preferences'] as Map?) - ?.map( - (k, e) => - MapEntry(k, PushPreference.fromJson(e as Map)), - ) ?? - {} - ..userChannelPreferences = - (json['user_channel_preferences'] as Map?)?.map( - (k, e) => MapEntry( - k, - (e as Map).map( - (k, e) => MapEntry( - k, - ChannelPushPreference.fromJson( - e as Map)), - )), - ) ?? - {}; + Map json, +) => UpsertPushPreferencesResponse() + ..duration = json['duration'] as String? + ..userPreferences = _userPreferencesFromJson( + json['user_preferences'] as Map?, + ) + ..userChannelPreferences = + (json['user_channel_preferences'] as Map?)?.map( + (k, e) => MapEntry( + k, + (e as Map).map( + (k, e) => MapEntry( + k, + ChannelPushPreference.fromJson(e as Map), + ), + ), + ), + ) ?? + {}; diff --git a/packages/stream_chat/test/src/core/api/responses_test.dart b/packages/stream_chat/test/src/core/api/responses_test.dart index 4f9d45c740..292dd5a127 100644 --- a/packages/stream_chat/test/src/core/api/responses_test.dart +++ b/packages/stream_chat/test/src/core/api/responses_test.dart @@ -4457,7 +4457,8 @@ void main() { }, "user2": { "chat_level": "none" - } + }, + "user3": null }, "user_channel_preferences": { "user1": { @@ -4482,7 +4483,10 @@ void main() { ); expect(response.userPreferences, isA>()); + // user3 had a `null` value in the response (no user-global prefs were + // touched by the upsert) — should be filtered outs. expect(response.userPreferences, hasLength(2)); + expect(response.userPreferences.containsKey('user3'), isFalse); // Test user1 preferences final user1Prefs = response.userPreferences['user1']!; From 4e5f7a0036f5153b770a91a6baf26e060c07b54a Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 16:48:41 +0200 Subject: [PATCH 2/7] Update CHANGELOG.md --- packages/stream_chat/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 9869247fa2..259710eff6 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🐞 Fixed + +- Fixed failing to parse `null` values in `UpsertPushPreferencesResponse.userPreferences` JSON. + ## 9.25.0 - Minor bug fixes and improvements From 7bb93f9969432a1b36ede97b8fd8ba1be531f233 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 19:56:58 +0200 Subject: [PATCH 3/7] Fix formatting --- packages/stream_chat/lib/src/core/api/responses.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.dart b/packages/stream_chat/lib/src/core/api/responses.dart index 49c186010a..111da5c71d 100644 --- a/packages/stream_chat/lib/src/core/api/responses.dart +++ b/packages/stream_chat/lib/src/core/api/responses.dart @@ -53,7 +53,8 @@ class ErrorResponse extends _BaseResponse { Map toJson() => _$ErrorResponseToJson(this); @override - String toString() => 'ErrorResponse(code: $code, ' + String toString() => + 'ErrorResponse(code: $code, ' 'message: $message, ' 'statusCode: $statusCode, ' 'moreInfo: $moreInfo)'; @@ -850,10 +851,13 @@ class UpsertPushPreferencesResponse extends _BaseResponse { _$UpsertPushPreferencesResponseFromJson(json); } -Map _userPreferencesFromJson(Map? json) { +Map _userPreferencesFromJson( + Map? json, +) { if (json == null) return {}; return { for (final MapEntry(:key, :value) in json.entries) - if (value != null) key: PushPreference.fromJson(value as Map), + if (value != null) + key: PushPreference.fromJson(value as Map), }; -} \ No newline at end of file +} From 6fa471020542e760403de176e0cda21f273fda0f Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 21:23:48 +0200 Subject: [PATCH 4/7] Fix formatting --- .../lib/src/core/api/responses.g.dart | 595 +++++++++--------- 1 file changed, 284 insertions(+), 311 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.g.dart b/packages/stream_chat/lib/src/core/api/responses.g.dart index 6bb4081862..30dd445960 100644 --- a/packages/stream_chat/lib/src/core/api/responses.g.dart +++ b/packages/stream_chat/lib/src/core/api/responses.g.dart @@ -25,99 +25,90 @@ Map _$ErrorResponseToJson(ErrorResponse instance) => SyncResponse _$SyncResponseFromJson(Map json) => SyncResponse() ..duration = json['duration'] as String? - ..events = - (json['events'] as List?) + ..events = (json['events'] as List?) ?.map((e) => Event.fromJson(e as Map)) .toList() ?? []; QueryChannelsResponse _$QueryChannelsResponseFromJson( - Map json, -) => QueryChannelsResponse() - ..duration = json['duration'] as String? - ..channels = - (json['channels'] as List?) - ?.map((e) => ChannelState.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + QueryChannelsResponse() + ..duration = json['duration'] as String? + ..channels = (json['channels'] as List?) + ?.map((e) => ChannelState.fromJson(e as Map)) + .toList() ?? + []; TranslateMessageResponse _$TranslateMessageResponseFromJson( - Map json, -) => TranslateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); + Map json) => + TranslateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); QueryMembersResponse _$QueryMembersResponseFromJson( - Map json, -) => QueryMembersResponse() - ..duration = json['duration'] as String? - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + QueryMembersResponse() + ..duration = json['duration'] as String? + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + []; PartialUpdateMemberResponse _$PartialUpdateMemberResponseFromJson( - Map json, -) => PartialUpdateMemberResponse() - ..duration = json['duration'] as String? - ..channelMember = Member.fromJson( - json['channel_member'] as Map, - ); + Map json) => + PartialUpdateMemberResponse() + ..duration = json['duration'] as String? + ..channelMember = + Member.fromJson(json['channel_member'] as Map); QueryUsersResponse _$QueryUsersResponseFromJson(Map json) => QueryUsersResponse() ..duration = json['duration'] as String? - ..users = - (json['users'] as List?) + ..users = (json['users'] as List?) ?.map((e) => User.fromJson(e as Map)) .toList() ?? []; QueryBannedUsersResponse _$QueryBannedUsersResponseFromJson( - Map json, -) => QueryBannedUsersResponse() - ..duration = json['duration'] as String? - ..bans = - (json['bans'] as List?) - ?.map((e) => BannedUser.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + QueryBannedUsersResponse() + ..duration = json['duration'] as String? + ..bans = (json['bans'] as List?) + ?.map((e) => BannedUser.fromJson(e as Map)) + .toList() ?? + []; QueryReactionsResponse _$QueryReactionsResponseFromJson( - Map json, -) => QueryReactionsResponse() - ..duration = json['duration'] as String? - ..reactions = - (json['reactions'] as List?) - ?.map((e) => Reaction.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + QueryReactionsResponse() + ..duration = json['duration'] as String? + ..reactions = (json['reactions'] as List?) + ?.map((e) => Reaction.fromJson(e as Map)) + .toList() ?? + []; QueryRepliesResponse _$QueryRepliesResponseFromJson( - Map json, -) => QueryRepliesResponse() - ..duration = json['duration'] as String? - ..messages = - (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + QueryRepliesResponse() + ..duration = json['duration'] as String? + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; ListDevicesResponse _$ListDevicesResponseFromJson(Map json) => ListDevicesResponse() ..duration = json['duration'] as String? - ..devices = - (json['devices'] as List?) + ..devices = (json['devices'] as List?) ?.map((e) => Device.fromJson(e as Map)) .toList() ?? []; SendAttachmentResponse _$SendAttachmentResponseFromJson( - Map json, -) => SendAttachmentResponse() - ..duration = json['duration'] as String? - ..file = json['file'] as String?; + Map json) => + SendAttachmentResponse() + ..duration = json['duration'] as String? + ..file = json['file'] as String?; SendFileResponse _$SendFileResponseFromJson(Map json) => SendFileResponse() @@ -126,33 +117,32 @@ SendFileResponse _$SendFileResponseFromJson(Map json) => ..thumbUrl = json['thumb_url'] as String?; SendReactionResponse _$SendReactionResponseFromJson( - Map json, -) => SendReactionResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map) - ..reaction = Reaction.fromJson(json['reaction'] as Map); + Map json) => + SendReactionResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map) + ..reaction = Reaction.fromJson(json['reaction'] as Map); ConnectGuestUserResponse _$ConnectGuestUserResponseFromJson( - Map json, -) => ConnectGuestUserResponse() - ..duration = json['duration'] as String? - ..accessToken = json['access_token'] as String - ..user = User.fromJson(json['user'] as Map); + Map json) => + ConnectGuestUserResponse() + ..duration = json['duration'] as String? + ..accessToken = json['access_token'] as String + ..user = User.fromJson(json['user'] as Map); UpdateUsersResponse _$UpdateUsersResponseFromJson(Map json) => UpdateUsersResponse() ..duration = json['duration'] as String? - ..users = - (json['users'] as Map?)?.map( + ..users = (json['users'] as Map?)?.map( (k, e) => MapEntry(k, User.fromJson(e as Map)), ) ?? {}; UpdateMessageResponse _$UpdateMessageResponseFromJson( - Map json, -) => UpdateMessageResponse() - ..duration = json['duration'] as String? - ..message = Message.fromJson(json['message'] as Map); + Map json) => + UpdateMessageResponse() + ..duration = json['duration'] as String? + ..message = Message.fromJson(json['message'] as Map); SendMessageResponse _$SendMessageResponseFromJson(Map json) => SendMessageResponse() @@ -168,75 +158,72 @@ GetMessageResponse _$GetMessageResponseFromJson(Map json) => : ChannelModel.fromJson(json['channel'] as Map); SearchMessagesResponse _$SearchMessagesResponseFromJson( - Map json, -) => SearchMessagesResponse() - ..duration = json['duration'] as String? - ..results = - (json['results'] as List?) - ?.map((e) => GetMessageResponse.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String? - ..previous = json['previous'] as String?; + Map json) => + SearchMessagesResponse() + ..duration = json['duration'] as String? + ..results = (json['results'] as List?) + ?.map( + (e) => GetMessageResponse.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String? + ..previous = json['previous'] as String?; GetMessagesByIdResponse _$GetMessagesByIdResponseFromJson( - Map json, -) => GetMessagesByIdResponse() - ..duration = json['duration'] as String? - ..messages = - (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + GetMessagesByIdResponse() + ..duration = json['duration'] as String? + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + []; UpdateChannelResponse _$UpdateChannelResponseFromJson( - Map json, -) => UpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json) => + UpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson( - Map json, -) => PartialUpdateChannelResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList(); + Map json) => + PartialUpdateChannelResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList(); InviteMembersResponse _$InviteMembersResponseFromJson( - Map json, -) => InviteMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json) => + InviteMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); RemoveMembersResponse _$RemoveMembersResponseFromJson( - Map json, -) => RemoveMembersResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json) => + RemoveMembersResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); SendActionResponse _$SendActionResponseFromJson(Map json) => SendActionResponse() @@ -249,8 +236,7 @@ AddMembersResponse _$AddMembersResponseFromJson(Map json) => AddMembersResponse() ..duration = json['duration'] as String? ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = - (json['members'] as List?) + ..members = (json['members'] as List?) ?.map((e) => Member.fromJson(e as Map)) .toList() ?? [] @@ -259,72 +245,67 @@ AddMembersResponse _$AddMembersResponseFromJson(Map json) => : Message.fromJson(json['message'] as Map); AcceptInviteResponse _$AcceptInviteResponseFromJson( - Map json, -) => AcceptInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json) => + AcceptInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); RejectInviteResponse _$RejectInviteResponseFromJson( - Map json, -) => RejectInviteResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..message = json['message'] == null - ? null - : Message.fromJson(json['message'] as Map); + Map json) => + RejectInviteResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..message = json['message'] == null + ? null + : Message.fromJson(json['message'] as Map); EmptyResponse _$EmptyResponseFromJson(Map json) => EmptyResponse()..duration = json['duration'] as String?; ChannelStateResponse _$ChannelStateResponseFromJson( - Map json, -) => ChannelStateResponse() - ..duration = json['duration'] as String? - ..channel = ChannelModel.fromJson(json['channel'] as Map) - ..messages = - (json['messages'] as List?) - ?.map((e) => Message.fromJson(e as Map)) - .toList() ?? - [] - ..members = - (json['members'] as List?) - ?.map((e) => Member.fromJson(e as Map)) - .toList() ?? - [] - ..watcherCount = (json['watcher_count'] as num?)?.toInt() ?? 0 - ..read = - (json['read'] as List?) - ?.map((e) => Read.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + ChannelStateResponse() + ..duration = json['duration'] as String? + ..channel = ChannelModel.fromJson(json['channel'] as Map) + ..messages = (json['messages'] as List?) + ?.map((e) => Message.fromJson(e as Map)) + .toList() ?? + [] + ..members = (json['members'] as List?) + ?.map((e) => Member.fromJson(e as Map)) + .toList() ?? + [] + ..watcherCount = (json['watcher_count'] as num?)?.toInt() ?? 0 + ..read = (json['read'] as List?) + ?.map((e) => Read.fromJson(e as Map)) + .toList() ?? + []; OGAttachmentResponse _$OGAttachmentResponseFromJson( - Map json, -) => OGAttachmentResponse() - ..duration = json['duration'] as String? - ..ogScrapeUrl = json['og_scrape_url'] as String - ..assetUrl = json['asset_url'] as String? - ..authorLink = json['author_link'] as String? - ..authorName = json['author_name'] as String? - ..imageUrl = json['image_url'] as String? - ..text = json['text'] as String? - ..thumbUrl = json['thumb_url'] as String? - ..title = json['title'] as String? - ..titleLink = json['title_link'] as String? - ..type = json['type'] as String?; + Map json) => + OGAttachmentResponse() + ..duration = json['duration'] as String? + ..ogScrapeUrl = json['og_scrape_url'] as String + ..assetUrl = json['asset_url'] as String? + ..authorLink = json['author_link'] as String? + ..authorName = json['author_name'] as String? + ..imageUrl = json['image_url'] as String? + ..text = json['text'] as String? + ..thumbUrl = json['thumb_url'] as String? + ..title = json['title'] as String? + ..titleLink = json['title_link'] as String? + ..type = json['type'] as String?; CallTokenPayload _$CallTokenPayloadFromJson(Map json) => CallTokenPayload() @@ -348,14 +329,13 @@ UserBlockResponse _$UserBlockResponseFromJson(Map json) => ..createdAt = DateTime.parse(json['created_at'] as String); BlockedUsersResponse _$BlockedUsersResponseFromJson( - Map json, -) => BlockedUsersResponse() - ..duration = json['duration'] as String? - ..blocks = - (json['blocks'] as List?) - ?.map((e) => UserBlock.fromJson(e as Map)) - .toList() ?? - []; + Map json) => + BlockedUsersResponse() + ..duration = json['duration'] as String? + ..blocks = (json['blocks'] as List?) + ?.map((e) => UserBlock.fromJson(e as Map)) + .toList() ?? + []; CreatePollResponse _$CreatePollResponseFromJson(Map json) => CreatePollResponse() @@ -373,61 +353,56 @@ UpdatePollResponse _$UpdatePollResponseFromJson(Map json) => ..poll = Poll.fromJson(json['poll'] as Map); CreatePollOptionResponse _$CreatePollOptionResponseFromJson( - Map json, -) => CreatePollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = PollOption.fromJson( - json['poll_option'] as Map, - ); + Map json) => + CreatePollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = + PollOption.fromJson(json['poll_option'] as Map); GetPollOptionResponse _$GetPollOptionResponseFromJson( - Map json, -) => GetPollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = PollOption.fromJson( - json['poll_option'] as Map, - ); + Map json) => + GetPollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = + PollOption.fromJson(json['poll_option'] as Map); UpdatePollOptionResponse _$UpdatePollOptionResponseFromJson( - Map json, -) => UpdatePollOptionResponse() - ..duration = json['duration'] as String? - ..pollOption = PollOption.fromJson( - json['poll_option'] as Map, - ); + Map json) => + UpdatePollOptionResponse() + ..duration = json['duration'] as String? + ..pollOption = + PollOption.fromJson(json['poll_option'] as Map); CastPollVoteResponse _$CastPollVoteResponseFromJson( - Map json, -) => CastPollVoteResponse() - ..duration = json['duration'] as String? - ..vote = PollVote.fromJson(json['vote'] as Map); + Map json) => + CastPollVoteResponse() + ..duration = json['duration'] as String? + ..vote = PollVote.fromJson(json['vote'] as Map); RemovePollVoteResponse _$RemovePollVoteResponseFromJson( - Map json, -) => RemovePollVoteResponse() - ..duration = json['duration'] as String? - ..vote = PollVote.fromJson(json['vote'] as Map); + Map json) => + RemovePollVoteResponse() + ..duration = json['duration'] as String? + ..vote = PollVote.fromJson(json['vote'] as Map); QueryPollsResponse _$QueryPollsResponseFromJson(Map json) => QueryPollsResponse() ..duration = json['duration'] as String? - ..polls = - (json['polls'] as List?) + ..polls = (json['polls'] as List?) ?.map((e) => Poll.fromJson(e as Map)) .toList() ?? [] ..next = json['next'] as String?; QueryPollVotesResponse _$QueryPollVotesResponseFromJson( - Map json, -) => QueryPollVotesResponse() - ..duration = json['duration'] as String? - ..votes = - (json['votes'] as List?) - ?.map((e) => PollVote.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json) => + QueryPollVotesResponse() + ..duration = json['duration'] as String? + ..votes = (json['votes'] as List?) + ?.map((e) => PollVote.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; GetThreadResponse _$GetThreadResponseFromJson(Map json) => GetThreadResponse() @@ -435,21 +410,20 @@ GetThreadResponse _$GetThreadResponseFromJson(Map json) => ..thread = Thread.fromJson(json['thread'] as Map); UpdateThreadResponse _$UpdateThreadResponseFromJson( - Map json, -) => UpdateThreadResponse() - ..duration = json['duration'] as String? - ..thread = Thread.fromJson(json['thread'] as Map); + Map json) => + UpdateThreadResponse() + ..duration = json['duration'] as String? + ..thread = Thread.fromJson(json['thread'] as Map); QueryThreadsResponse _$QueryThreadsResponseFromJson( - Map json, -) => QueryThreadsResponse() - ..duration = json['duration'] as String? - ..threads = - (json['threads'] as List?) - ?.map((e) => Thread.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json) => + QueryThreadsResponse() + ..duration = json['duration'] as String? + ..threads = (json['threads'] as List?) + ?.map((e) => Thread.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; CreateDraftResponse _$CreateDraftResponseFromJson(Map json) => CreateDraftResponse() @@ -464,78 +438,77 @@ GetDraftResponse _$GetDraftResponseFromJson(Map json) => QueryDraftsResponse _$QueryDraftsResponseFromJson(Map json) => QueryDraftsResponse() ..duration = json['duration'] as String? - ..drafts = - (json['drafts'] as List?) + ..drafts = (json['drafts'] as List?) ?.map((e) => Draft.fromJson(e as Map)) .toList() ?? [] ..next = json['next'] as String?; CreateReminderResponse _$CreateReminderResponseFromJson( - Map json, -) => CreateReminderResponse() - ..duration = json['duration'] as String? - ..reminder = MessageReminder.fromJson( - json['reminder'] as Map, - ); + Map json) => + CreateReminderResponse() + ..duration = json['duration'] as String? + ..reminder = + MessageReminder.fromJson(json['reminder'] as Map); UpdateReminderResponse _$UpdateReminderResponseFromJson( - Map json, -) => UpdateReminderResponse() - ..duration = json['duration'] as String? - ..reminder = MessageReminder.fromJson( - json['reminder'] as Map, - ); + Map json) => + UpdateReminderResponse() + ..duration = json['duration'] as String? + ..reminder = + MessageReminder.fromJson(json['reminder'] as Map); QueryRemindersResponse _$QueryRemindersResponseFromJson( - Map json, -) => QueryRemindersResponse() - ..duration = json['duration'] as String? - ..reminders = - (json['reminders'] as List?) - ?.map((e) => MessageReminder.fromJson(e as Map)) - .toList() ?? - [] - ..next = json['next'] as String?; + Map json) => + QueryRemindersResponse() + ..duration = json['duration'] as String? + ..reminders = (json['reminders'] as List?) + ?.map((e) => MessageReminder.fromJson(e as Map)) + .toList() ?? + [] + ..next = json['next'] as String?; GetUnreadCountResponse _$GetUnreadCountResponseFromJson( - Map json, -) => GetUnreadCountResponse() - ..duration = json['duration'] as String? - ..totalUnreadCount = (json['total_unread_count'] as num).toInt() - ..totalUnreadThreadsCount = (json['total_unread_threads_count'] as num) - .toInt() - ..totalUnreadCountByTeam = - (json['total_unread_count_by_team'] as Map?)?.map( + Map json) => + GetUnreadCountResponse() + ..duration = json['duration'] as String? + ..totalUnreadCount = (json['total_unread_count'] as num).toInt() + ..totalUnreadThreadsCount = + (json['total_unread_threads_count'] as num).toInt() + ..totalUnreadCountByTeam = + (json['total_unread_count_by_team'] as Map?)?.map( (k, e) => MapEntry(k, (e as num).toInt()), ) - ..channels = (json['channels'] as List) - .map((e) => UnreadCountsChannel.fromJson(e as Map)) - .toList() - ..channelType = (json['channel_type'] as List) - .map((e) => UnreadCountsChannelType.fromJson(e as Map)) - .toList() - ..threads = (json['threads'] as List) - .map((e) => UnreadCountsThread.fromJson(e as Map)) - .toList(); + ..channels = (json['channels'] as List) + .map((e) => UnreadCountsChannel.fromJson(e as Map)) + .toList() + ..channelType = (json['channel_type'] as List) + .map((e) => + UnreadCountsChannelType.fromJson(e as Map)) + .toList() + ..threads = (json['threads'] as List) + .map((e) => UnreadCountsThread.fromJson(e as Map)) + .toList(); UpsertPushPreferencesResponse _$UpsertPushPreferencesResponseFromJson( - Map json, -) => UpsertPushPreferencesResponse() - ..duration = json['duration'] as String? - ..userPreferences = _userPreferencesFromJson( - json['user_preferences'] as Map?, - ) - ..userChannelPreferences = - (json['user_channel_preferences'] as Map?)?.map( - (k, e) => MapEntry( - k, - (e as Map).map( - (k, e) => MapEntry( - k, - ChannelPushPreference.fromJson(e as Map), - ), - ), - ), - ) ?? - {}; + Map json) => + UpsertPushPreferencesResponse() + ..duration = json['duration'] as String? + ..userPreferences = (json['user_preferences'] as Map?) + ?.map( + (k, e) => + MapEntry(k, PushPreference.fromJson(e as Map)), + ) ?? + {} + ..userChannelPreferences = + (json['user_channel_preferences'] as Map?)?.map( + (k, e) => MapEntry( + k, + (e as Map).map( + (k, e) => MapEntry( + k, + ChannelPushPreference.fromJson( + e as Map)), + )), + ) ?? + {}; From 9c0fe0ac8abe1b50d10c4c3ea63d43dbb59619eb Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 21:34:47 +0200 Subject: [PATCH 5/7] Fix formatting --- packages/stream_chat/lib/src/core/api/responses.g.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.g.dart b/packages/stream_chat/lib/src/core/api/responses.g.dart index 30dd445960..58b5619e0a 100644 --- a/packages/stream_chat/lib/src/core/api/responses.g.dart +++ b/packages/stream_chat/lib/src/core/api/responses.g.dart @@ -494,12 +494,8 @@ UpsertPushPreferencesResponse _$UpsertPushPreferencesResponseFromJson( Map json) => UpsertPushPreferencesResponse() ..duration = json['duration'] as String? - ..userPreferences = (json['user_preferences'] as Map?) - ?.map( - (k, e) => - MapEntry(k, PushPreference.fromJson(e as Map)), - ) ?? - {} + ..userPreferences = _userPreferencesFromJson( + json['user_preferences'] as Map?) ..userChannelPreferences = (json['user_channel_preferences'] as Map?)?.map( (k, e) => MapEntry( From d6fa66b9485b544e79a366760075a70db2ef0104 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 21:53:01 +0200 Subject: [PATCH 6/7] Fix formatting --- packages/stream_chat/lib/src/core/api/responses.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.dart b/packages/stream_chat/lib/src/core/api/responses.dart index 111da5c71d..8c97b3e8f6 100644 --- a/packages/stream_chat/lib/src/core/api/responses.dart +++ b/packages/stream_chat/lib/src/core/api/responses.dart @@ -53,8 +53,7 @@ class ErrorResponse extends _BaseResponse { Map toJson() => _$ErrorResponseToJson(this); @override - String toString() => - 'ErrorResponse(code: $code, ' + String toString() => 'ErrorResponse(code: $code, ' 'message: $message, ' 'statusCode: $statusCode, ' 'moreInfo: $moreInfo)'; @@ -851,9 +850,7 @@ class UpsertPushPreferencesResponse extends _BaseResponse { _$UpsertPushPreferencesResponseFromJson(json); } -Map _userPreferencesFromJson( - Map? json, -) { +Map _userPreferencesFromJson(Map? json) { if (json == null) return {}; return { for (final MapEntry(:key, :value) in json.entries) From 87f61a4cd2a69f5daa692e467f6b67636836d5a2 Mon Sep 17 00:00:00 2001 From: VelikovPetar Date: Fri, 12 Jun 2026 22:11:12 +0200 Subject: [PATCH 7/7] Fix formatting --- packages/stream_chat/lib/src/core/api/responses.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat/lib/src/core/api/responses.dart b/packages/stream_chat/lib/src/core/api/responses.dart index 8c97b3e8f6..e1d0537eec 100644 --- a/packages/stream_chat/lib/src/core/api/responses.dart +++ b/packages/stream_chat/lib/src/core/api/responses.dart @@ -850,7 +850,9 @@ class UpsertPushPreferencesResponse extends _BaseResponse { _$UpsertPushPreferencesResponseFromJson(json); } -Map _userPreferencesFromJson(Map? json) { +Map _userPreferencesFromJson( + Map? json, +) { if (json == null) return {}; return { for (final MapEntry(:key, :value) in json.entries)