feat(llc): create disabled, hidden, truncatedAt a field in channel
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -195,6 +195,42 @@ class Channel {
|
|||||||
return state!.channelStateStream.map((cs) => cs.channel?.frozen == true);
|
return state!.channelStateStream.map((cs) => cs.channel?.frozen == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Channel disabled status.
|
||||||
|
bool get disabled {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!._channelState.channel?.disabled == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Channel disabled status as a stream.
|
||||||
|
Stream<bool> get disabledStream {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!.channelStateStream.map((cs) => cs.channel?.disabled == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Channel hidden status.
|
||||||
|
bool get hidden {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!._channelState.channel?.hidden == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Channel hidden status as a stream.
|
||||||
|
Stream<bool> get hiddenStream {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!.channelStateStream.map((cs) => cs.channel?.hidden == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The last date at which the channel got truncated.
|
||||||
|
DateTime? get truncatedAt {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!._channelState.channel?.truncatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The last date at which the channel got truncated as a stream.
|
||||||
|
Stream<DateTime?> get truncatedAtStream {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!.channelStateStream.map((cs) => cs.channel?.truncatedAt);
|
||||||
|
}
|
||||||
|
|
||||||
/// Cooldown count
|
/// Cooldown count
|
||||||
int get cooldown {
|
int get cooldown {
|
||||||
_checkInitialized();
|
_checkInitialized();
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class ChannelModel {
|
|||||||
this.extraData = const {},
|
this.extraData = const {},
|
||||||
this.team,
|
this.team,
|
||||||
this.cooldown = 0,
|
this.cooldown = 0,
|
||||||
|
this.disabled = false,
|
||||||
|
this.hidden = false,
|
||||||
|
this.truncatedAt,
|
||||||
}) : 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',
|
||||||
@@ -92,6 +95,15 @@ class ChannelModel {
|
|||||||
@JsonKey(includeIfNull: false)
|
@JsonKey(includeIfNull: false)
|
||||||
final int cooldown;
|
final int cooldown;
|
||||||
|
|
||||||
|
/// True if the channel is disabled
|
||||||
|
final bool disabled;
|
||||||
|
|
||||||
|
/// True if the channel is hidden
|
||||||
|
final bool hidden;
|
||||||
|
|
||||||
|
/// The date of the last time channel got truncated
|
||||||
|
final DateTime? truncatedAt;
|
||||||
|
|
||||||
/// Map of custom channel extraData
|
/// Map of custom channel extraData
|
||||||
@JsonKey(includeIfNull: false)
|
@JsonKey(includeIfNull: false)
|
||||||
final Map<String, Object?> extraData;
|
final Map<String, Object?> extraData;
|
||||||
@@ -117,6 +129,9 @@ class ChannelModel {
|
|||||||
'member_count',
|
'member_count',
|
||||||
'team',
|
'team',
|
||||||
'cooldown',
|
'cooldown',
|
||||||
|
'disabled',
|
||||||
|
'hidden',
|
||||||
|
'truncated_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Shortcut for channel name
|
/// Shortcut for channel name
|
||||||
@@ -145,6 +160,9 @@ class ChannelModel {
|
|||||||
Map<String, Object?>? extraData,
|
Map<String, Object?>? extraData,
|
||||||
String? team,
|
String? team,
|
||||||
int? cooldown,
|
int? cooldown,
|
||||||
|
bool? disabled,
|
||||||
|
bool? hidden,
|
||||||
|
DateTime? truncatedAt,
|
||||||
}) =>
|
}) =>
|
||||||
ChannelModel(
|
ChannelModel(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -162,6 +180,9 @@ class ChannelModel {
|
|||||||
extraData: extraData ?? this.extraData,
|
extraData: extraData ?? this.extraData,
|
||||||
team: team ?? this.team,
|
team: team ?? this.team,
|
||||||
cooldown: cooldown ?? this.cooldown,
|
cooldown: cooldown ?? this.cooldown,
|
||||||
|
disabled: disabled ?? this.disabled,
|
||||||
|
hidden: hidden ?? this.hidden,
|
||||||
|
truncatedAt: truncatedAt ?? this.truncatedAt,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Returns a new [ChannelModel] that is a combination of this channelModel
|
/// Returns a new [ChannelModel] that is a combination of this channelModel
|
||||||
@@ -181,9 +202,12 @@ class ChannelModel {
|
|||||||
updatedAt: other.updatedAt,
|
updatedAt: other.updatedAt,
|
||||||
deletedAt: other.deletedAt,
|
deletedAt: other.deletedAt,
|
||||||
memberCount: other.memberCount,
|
memberCount: other.memberCount,
|
||||||
extraData: {...extraData, ...other.extraData},
|
extraData: other.extraData,
|
||||||
team: other.team,
|
team: other.team,
|
||||||
cooldown: other.cooldown,
|
cooldown: other.cooldown,
|
||||||
|
disabled: other.disabled,
|
||||||
|
hidden: other.hidden,
|
||||||
|
truncatedAt: other.truncatedAt,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ ChannelModel _$ChannelModelFromJson(Map<String, dynamic> json) => ChannelModel(
|
|||||||
extraData: json['extra_data'] as Map<String, dynamic>? ?? const {},
|
extraData: json['extra_data'] as Map<String, dynamic>? ?? const {},
|
||||||
team: json['team'] as String?,
|
team: json['team'] as String?,
|
||||||
cooldown: json['cooldown'] as int? ?? 0,
|
cooldown: json['cooldown'] as int? ?? 0,
|
||||||
|
disabled: json['disabled'] as bool? ?? false,
|
||||||
|
hidden: json['hidden'] as bool? ?? false,
|
||||||
|
truncatedAt: json['truncated_at'] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json['truncated_at'] as String),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$ChannelModelToJson(ChannelModel instance) {
|
Map<String, dynamic> _$ChannelModelToJson(ChannelModel instance) {
|
||||||
@@ -61,6 +66,9 @@ Map<String, dynamic> _$ChannelModelToJson(ChannelModel instance) {
|
|||||||
writeNotNull('deleted_at', readonly(instance.deletedAt));
|
writeNotNull('deleted_at', readonly(instance.deletedAt));
|
||||||
writeNotNull('member_count', readonly(instance.memberCount));
|
writeNotNull('member_count', readonly(instance.memberCount));
|
||||||
val['cooldown'] = instance.cooldown;
|
val['cooldown'] = instance.cooldown;
|
||||||
|
val['disabled'] = instance.disabled;
|
||||||
|
val['hidden'] = instance.hidden;
|
||||||
|
val['truncated_at'] = instance.truncatedAt?.toIso8601String();
|
||||||
val['extra_data'] = instance.extraData;
|
val['extra_data'] = instance.extraData;
|
||||||
writeNotNull('team', readonly(instance.team));
|
writeNotNull('team', readonly(instance.team));
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
Reference in New Issue
Block a user