Merge branch 'develop' of github.com:GetStream/stream-chat-flutter into fix/message-search-pagination
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -767,7 +767,9 @@ class StreamChatClient {
|
||||
cancelToken: cancelToken,
|
||||
);
|
||||
|
||||
/// Replaces the [channelId] of type [ChannelType] data with [data]
|
||||
/// Replaces the [channelId] of type [ChannelType] data with [data].
|
||||
///
|
||||
/// Use [updateChannelPartial] for a partial update.
|
||||
Future<UpdateChannelResponse> updateChannel(
|
||||
String channelId,
|
||||
String channelType,
|
||||
@@ -781,7 +783,10 @@ class StreamChatClient {
|
||||
message: message,
|
||||
);
|
||||
|
||||
/// Updates the [channelId] of type [ChannelType] data with [data]
|
||||
/// Partial update for the [channelId] of type [ChannelType]. Sets the
|
||||
/// data provided in [set], and removes the attributes given in [unset].
|
||||
///
|
||||
/// Use [updateChannel] for a full update.
|
||||
Future<PartialUpdateChannelResponse> updateChannelPartial(
|
||||
String channelId,
|
||||
String channelType, {
|
||||
@@ -1247,6 +1252,28 @@ class StreamChatClient {
|
||||
language,
|
||||
);
|
||||
|
||||
/// Enables slow mode
|
||||
Future<PartialUpdateChannelResponse> enableSlowdown(
|
||||
String channelId,
|
||||
String channelType,
|
||||
int cooldown,
|
||||
) async =>
|
||||
_chatApi.channel.enableSlowdown(
|
||||
channelId,
|
||||
channelType,
|
||||
cooldown,
|
||||
);
|
||||
|
||||
/// Disables slow mode
|
||||
Future<PartialUpdateChannelResponse> disableSlowdown(
|
||||
String channelId,
|
||||
String channelType,
|
||||
) async =>
|
||||
_chatApi.channel.disableSlowdown(
|
||||
channelId,
|
||||
channelType,
|
||||
);
|
||||
|
||||
/// Pins provided message
|
||||
/// [timeoutOrExpirationDate] can either be a [DateTime] or a value in seconds
|
||||
/// to be added to [DateTime.now]
|
||||
|
||||
@@ -123,6 +123,35 @@ class ChannelApi {
|
||||
return PartialUpdateChannelResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
/// Enable slowdown
|
||||
Future<PartialUpdateChannelResponse> enableSlowdown(
|
||||
String channelId,
|
||||
String channelType,
|
||||
int cooldown,
|
||||
) async {
|
||||
final response = await updateChannelPartial(
|
||||
channelId,
|
||||
channelType,
|
||||
set: {
|
||||
'cooldown': cooldown,
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Disable slowdown
|
||||
Future<PartialUpdateChannelResponse> disableSlowdown(
|
||||
String channelId,
|
||||
String channelType,
|
||||
) async {
|
||||
final response = await updateChannelPartial(
|
||||
channelId,
|
||||
channelType,
|
||||
unset: ['cooldown'],
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Accept invitation to the channel
|
||||
Future<AcceptInviteResponse> acceptChannelInvite(
|
||||
String channelId,
|
||||
@@ -263,6 +292,7 @@ class ChannelApi {
|
||||
) async {
|
||||
final response = await _client.post(
|
||||
'${_getChannelUrl(channelId, channelType)}/show',
|
||||
data: {},
|
||||
);
|
||||
return EmptyResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ class ChannelModel {
|
||||
this.memberCount = 0,
|
||||
this.extraData = const {},
|
||||
this.team,
|
||||
this.cooldown = 0,
|
||||
}) : assert(
|
||||
(cid != null && cid.contains(':')) || (id != null && type != null),
|
||||
'provide either a cid or an id and type',
|
||||
@@ -81,6 +82,10 @@ class ChannelModel {
|
||||
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
|
||||
final int memberCount;
|
||||
|
||||
/// The number of seconds in a cooldown
|
||||
@JsonKey(includeIfNull: false, defaultValue: 0)
|
||||
final int cooldown;
|
||||
|
||||
/// Map of custom channel extraData
|
||||
@JsonKey(
|
||||
includeIfNull: false,
|
||||
@@ -107,6 +112,7 @@ class ChannelModel {
|
||||
'deleted_at',
|
||||
'member_count',
|
||||
'team',
|
||||
'cooldown',
|
||||
];
|
||||
|
||||
/// Shortcut for channel name
|
||||
@@ -133,6 +139,7 @@ class ChannelModel {
|
||||
int? memberCount,
|
||||
Map<String, Object?>? extraData,
|
||||
String? team,
|
||||
int? cooldown,
|
||||
}) =>
|
||||
ChannelModel(
|
||||
id: id ?? this.id,
|
||||
@@ -148,6 +155,7 @@ class ChannelModel {
|
||||
memberCount: memberCount ?? this.memberCount,
|
||||
extraData: extraData ?? this.extraData,
|
||||
team: team ?? this.team,
|
||||
cooldown: cooldown ?? this.cooldown,
|
||||
);
|
||||
|
||||
/// Returns a new [ChannelModel] that is a combination of this channelModel
|
||||
@@ -168,6 +176,7 @@ class ChannelModel {
|
||||
memberCount: other.memberCount,
|
||||
extraData: other.extraData,
|
||||
team: other.team,
|
||||
cooldown: other.cooldown,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ ChannelModel _$ChannelModelFromJson(Map<String, dynamic> json) {
|
||||
memberCount: json['member_count'] as int? ?? 0,
|
||||
extraData: json['extra_data'] as Map<String, dynamic>? ?? {},
|
||||
team: json['team'] as String?,
|
||||
cooldown: json['cooldown'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,6 +58,7 @@ Map<String, dynamic> _$ChannelModelToJson(ChannelModel instance) {
|
||||
writeNotNull('updated_at', readonly(instance.updatedAt));
|
||||
writeNotNull('deleted_at', readonly(instance.deletedAt));
|
||||
writeNotNull('member_count', readonly(instance.memberCount));
|
||||
val['cooldown'] = instance.cooldown;
|
||||
val['extra_data'] = instance.extraData;
|
||||
writeNotNull('team', readonly(instance.team));
|
||||
return val;
|
||||
|
||||
@@ -184,6 +184,8 @@ class EventChannel extends ChannelModel {
|
||||
DateTime? deletedAt,
|
||||
required int memberCount,
|
||||
Map<String, Object?>? extraData,
|
||||
required int cooldown,
|
||||
String? team,
|
||||
}) : super(
|
||||
id: id,
|
||||
type: type,
|
||||
@@ -197,6 +199,8 @@ class EventChannel extends ChannelModel {
|
||||
deletedAt: deletedAt,
|
||||
memberCount: memberCount,
|
||||
extraData: extraData ?? {},
|
||||
cooldown: cooldown,
|
||||
team: team,
|
||||
);
|
||||
|
||||
/// Create a new instance from a json
|
||||
|
||||
@@ -87,5 +87,7 @@ EventChannel _$EventChannelFromJson(Map<String, dynamic> json) {
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
memberCount: json['member_count'] as int? ?? 0,
|
||||
extraData: json['extra_data'] as Map<String, dynamic>? ?? {},
|
||||
cooldown: json['cooldown'] as int? ?? 0,
|
||||
team: json['team'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user