Merge branch 'master' into feat/pin-message
This commit is contained in:
@@ -690,6 +690,13 @@ class Channel {
|
||||
return _client.decode(response.data, UpdateChannelResponse.fromJson);
|
||||
}
|
||||
|
||||
/// Edit the channel custom data
|
||||
Future<PartialUpdateChannelResponse> updatePartial(
|
||||
Map<String, dynamic> channelData) async {
|
||||
final response = await _client.patch(_channelURL, data: channelData);
|
||||
return _client.decode(response.data, PartialUpdateChannelResponse.fromJson);
|
||||
}
|
||||
|
||||
/// Delete this channel. Messages are permanently removed.
|
||||
Future<EmptyResponse> delete() async {
|
||||
final response = await _client.delete(_channelURL);
|
||||
|
||||
@@ -247,6 +247,20 @@ class UpdateChannelResponse extends _BaseResponse {
|
||||
_$UpdateChannelResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Channel.updatePartial] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class PartialUpdateChannelResponse extends _BaseResponse {
|
||||
/// Updated channel
|
||||
ChannelModel channel;
|
||||
|
||||
/// Channel members
|
||||
List<Member> members;
|
||||
|
||||
/// Create a new instance from a json
|
||||
static PartialUpdateChannelResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$PartialUpdateChannelResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Channel.inviteMembers] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class InviteMembersResponse extends _BaseResponse {
|
||||
|
||||
@@ -225,6 +225,23 @@ UpdateChannelResponse _$UpdateChannelResponseFromJson(Map json) {
|
||||
));
|
||||
}
|
||||
|
||||
PartialUpdateChannelResponse _$PartialUpdateChannelResponseFromJson(Map json) {
|
||||
return PartialUpdateChannelResponse()
|
||||
..duration = json['duration'] as String
|
||||
..channel = json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson((json['channel'] as Map)?.map(
|
||||
(k, e) => MapEntry(k as String, e),
|
||||
))
|
||||
..members = (json['members'] as List)
|
||||
?.map((e) => e == null
|
||||
? null
|
||||
: Member.fromJson((e as Map)?.map(
|
||||
(k, e) => MapEntry(k as String, e),
|
||||
)))
|
||||
?.toList();
|
||||
}
|
||||
|
||||
InviteMembersResponse _$InviteMembersResponseFromJson(Map json) {
|
||||
return InviteMembersResponse()
|
||||
..duration = json['duration'] as String
|
||||
|
||||
@@ -992,5 +992,37 @@ void main() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('channel', () {
|
||||
test('should update channel', () async {
|
||||
final mockDio = MockDio();
|
||||
|
||||
when(mockDio.options).thenReturn(BaseOptions());
|
||||
when(mockDio.interceptors).thenReturn(Interceptors());
|
||||
|
||||
final client = StreamChatClient(
|
||||
'api-key',
|
||||
httpClient: mockDio,
|
||||
);
|
||||
|
||||
final channelClient =
|
||||
client.channel('type', id: 'id', extraData: {'name': 'init'});
|
||||
|
||||
var update = {
|
||||
'set': {'name': 'demo'}
|
||||
};
|
||||
|
||||
when(mockDio.patch<String>(
|
||||
'/channels/${channelClient.type}/${channelClient.id}',
|
||||
data: update,
|
||||
)).thenAnswer((_) async => Response(data: '{}', statusCode: 200));
|
||||
|
||||
await channelClient.updatePartial(update);
|
||||
verify(mockDio.patch<String>(
|
||||
'/channels/${channelClient.type}/${channelClient.id}',
|
||||
data: update))
|
||||
.called(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
||||
},
|
||||
);
|
||||
},
|
||||
errorBuilder: widget.emptyBuilder ??
|
||||
errorBuilder: widget.errorBuilder ??
|
||||
(BuildContext context, dynamic error) {
|
||||
if (error is Error) {
|
||||
print((error).stackTrace);
|
||||
|
||||
Reference in New Issue
Block a user