chore: add cooldown to channel_model.dart and test it
This commit is contained in:
@@ -23,6 +23,7 @@ class ChannelModel {
|
|||||||
this.memberCount = 0,
|
this.memberCount = 0,
|
||||||
this.extraData = const {},
|
this.extraData = const {},
|
||||||
this.team,
|
this.team,
|
||||||
|
this.cooldown = 0,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
(cid != null && cid.contains(':')) || (id != null && type != null),
|
(cid != null && cid.contains(':')) || (id != null && type != null),
|
||||||
'provide either a cid or an id and type',
|
'provide either a cid or an id and type',
|
||||||
@@ -81,6 +82,9 @@ class ChannelModel {
|
|||||||
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
|
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
|
||||||
final int memberCount;
|
final int memberCount;
|
||||||
|
|
||||||
|
@JsonKey(includeIfNull: false)
|
||||||
|
final int cooldown;
|
||||||
|
|
||||||
/// Map of custom channel extraData
|
/// Map of custom channel extraData
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
includeIfNull: false,
|
includeIfNull: false,
|
||||||
@@ -107,6 +111,7 @@ class ChannelModel {
|
|||||||
'deleted_at',
|
'deleted_at',
|
||||||
'member_count',
|
'member_count',
|
||||||
'team',
|
'team',
|
||||||
|
'cooldown',
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Shortcut for channel name
|
/// Shortcut for channel name
|
||||||
@@ -133,6 +138,7 @@ class ChannelModel {
|
|||||||
int? memberCount,
|
int? memberCount,
|
||||||
Map<String, Object?>? extraData,
|
Map<String, Object?>? extraData,
|
||||||
String? team,
|
String? team,
|
||||||
|
int? cooldown,
|
||||||
}) =>
|
}) =>
|
||||||
ChannelModel(
|
ChannelModel(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -148,6 +154,7 @@ class ChannelModel {
|
|||||||
memberCount: memberCount ?? this.memberCount,
|
memberCount: memberCount ?? this.memberCount,
|
||||||
extraData: extraData ?? this.extraData,
|
extraData: extraData ?? this.extraData,
|
||||||
team: team ?? this.team,
|
team: team ?? this.team,
|
||||||
|
cooldown: cooldown ?? this.cooldown,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Returns a new [ChannelModel] that is a combination of this channelModel
|
/// Returns a new [ChannelModel] that is a combination of this channelModel
|
||||||
@@ -168,6 +175,7 @@ class ChannelModel {
|
|||||||
memberCount: other.memberCount,
|
memberCount: other.memberCount,
|
||||||
extraData: other.extraData,
|
extraData: other.extraData,
|
||||||
team: other.team,
|
team: other.team,
|
||||||
|
cooldown: other.cooldown,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ void main() {
|
|||||||
expect(channel.cid, equals('livestream:test'));
|
expect(channel.cid, equals('livestream:test'));
|
||||||
expect(channel.extraData['cats'], equals(true));
|
expect(channel.extraData['cats'], equals(true));
|
||||||
expect(channel.extraData['fruit'], equals(['bananas', 'apples']));
|
expect(channel.extraData['fruit'], equals(['bananas', 'apples']));
|
||||||
|
expect(channel.cooldown, equals(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should serialize to json correctly', () {
|
test('should serialize to json correctly', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user