fix(llc): ChannelEvent.membersCount default to 0

This commit is contained in:
Salvatore Giordano
2021-11-26 10:36:57 +01:00
parent 2cd7c44e24
commit e5abb8fffe
6 changed files with 66 additions and 40 deletions
@@ -14,7 +14,7 @@ final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
UploadState _$UploadStateFromJson(Map<String, dynamic> json) { UploadState _$UploadStateFromJson(Map<String, dynamic> json) {
switch (json['runtimeType'] as String?) { switch (json['type']) {
case 'preparing': case 'preparing':
return Preparing.fromJson(json); return Preparing.fromJson(json);
case 'inProgress': case 'inProgress':
@@ -25,8 +25,8 @@ UploadState _$UploadStateFromJson(Map<String, dynamic> json) {
return Failed.fromJson(json); return Failed.fromJson(json);
default: default:
throw CheckedFromJsonException(json, 'runtimeType', 'UploadState', throw CheckedFromJsonException(
'Invalid union type "${json['runtimeType']}"!'); json, 'type', 'UploadState', 'Invalid union type "${json['type']}"!');
} }
} }
@@ -55,7 +55,7 @@ class _$UploadStateTearOff {
); );
} }
UploadState fromJson(Map<String, Object> json) { UploadState fromJson(Map<String, Object?> json) {
return UploadState.fromJson(json); return UploadState.fromJson(json);
} }
} }
@@ -153,11 +153,14 @@ class _$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$Preparing implements Preparing { class _$Preparing implements Preparing {
const _$Preparing(); const _$Preparing({String? $type}) : $type = $type ?? 'preparing';
factory _$Preparing.fromJson(Map<String, dynamic> json) => factory _$Preparing.fromJson(Map<String, dynamic> json) =>
_$$PreparingFromJson(json); _$$PreparingFromJson(json);
@JsonKey(name: 'type')
final String $type;
@override @override
String toString() { String toString() {
return 'UploadState.preparing()'; return 'UploadState.preparing()';
@@ -165,7 +168,8 @@ class _$Preparing implements Preparing {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || (other is Preparing); return identical(this, other) ||
(other.runtimeType == runtimeType && other is Preparing);
} }
@override @override
@@ -247,7 +251,7 @@ class _$Preparing implements Preparing {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$PreparingToJson(this)..['runtimeType'] = 'preparing'; return _$$PreparingToJson(this);
} }
} }
@@ -295,7 +299,9 @@ class _$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$InProgress implements InProgress { class _$InProgress implements InProgress {
const _$InProgress({required this.uploaded, required this.total}); const _$InProgress(
{required this.uploaded, required this.total, String? $type})
: $type = $type ?? 'inProgress';
factory _$InProgress.fromJson(Map<String, dynamic> json) => factory _$InProgress.fromJson(Map<String, dynamic> json) =>
_$$InProgressFromJson(json); _$$InProgressFromJson(json);
@@ -305,6 +311,9 @@ class _$InProgress implements InProgress {
@override @override
final int total; final int total;
@JsonKey(name: 'type')
final String $type;
@override @override
String toString() { String toString() {
return 'UploadState.inProgress(uploaded: $uploaded, total: $total)'; return 'UploadState.inProgress(uploaded: $uploaded, total: $total)';
@@ -313,19 +322,15 @@ class _$InProgress implements InProgress {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || return identical(this, other) ||
(other is InProgress && (other.runtimeType == runtimeType &&
other is InProgress &&
(identical(other.uploaded, uploaded) || (identical(other.uploaded, uploaded) ||
const DeepCollectionEquality() other.uploaded == uploaded) &&
.equals(other.uploaded, uploaded)) && (identical(other.total, total) || other.total == total));
(identical(other.total, total) ||
const DeepCollectionEquality().equals(other.total, total)));
} }
@override @override
int get hashCode => int get hashCode => Object.hash(runtimeType, uploaded, total);
runtimeType.hashCode ^
const DeepCollectionEquality().hash(uploaded) ^
const DeepCollectionEquality().hash(total);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -408,7 +413,7 @@ class _$InProgress implements InProgress {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$InProgressToJson(this)..['runtimeType'] = 'inProgress'; return _$$InProgressToJson(this);
} }
} }
@@ -419,8 +424,8 @@ abstract class InProgress implements UploadState {
factory InProgress.fromJson(Map<String, dynamic> json) = factory InProgress.fromJson(Map<String, dynamic> json) =
_$InProgress.fromJson; _$InProgress.fromJson;
int get uploaded => throw _privateConstructorUsedError; int get uploaded;
int get total => throw _privateConstructorUsedError; int get total;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$InProgressCopyWith<InProgress> get copyWith => $InProgressCopyWith<InProgress> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@@ -445,11 +450,14 @@ class _$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$Success implements Success { class _$Success implements Success {
const _$Success(); const _$Success({String? $type}) : $type = $type ?? 'success';
factory _$Success.fromJson(Map<String, dynamic> json) => factory _$Success.fromJson(Map<String, dynamic> json) =>
_$$SuccessFromJson(json); _$$SuccessFromJson(json);
@JsonKey(name: 'type')
final String $type;
@override @override
String toString() { String toString() {
return 'UploadState.success()'; return 'UploadState.success()';
@@ -457,7 +465,8 @@ class _$Success implements Success {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || (other is Success); return identical(this, other) ||
(other.runtimeType == runtimeType && other is Success);
} }
@override @override
@@ -539,7 +548,7 @@ class _$Success implements Success {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$SuccessToJson(this)..['runtimeType'] = 'success'; return _$$SuccessToJson(this);
} }
} }
@@ -581,7 +590,8 @@ class _$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$Failed implements Failed { class _$Failed implements Failed {
const _$Failed({required this.error}); const _$Failed({required this.error, String? $type})
: $type = $type ?? 'failed';
factory _$Failed.fromJson(Map<String, dynamic> json) => factory _$Failed.fromJson(Map<String, dynamic> json) =>
_$$FailedFromJson(json); _$$FailedFromJson(json);
@@ -589,6 +599,9 @@ class _$Failed implements Failed {
@override @override
final String error; final String error;
@JsonKey(name: 'type')
final String $type;
@override @override
String toString() { String toString() {
return 'UploadState.failed(error: $error)'; return 'UploadState.failed(error: $error)';
@@ -597,14 +610,13 @@ class _$Failed implements Failed {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || return identical(this, other) ||
(other is Failed && (other.runtimeType == runtimeType &&
(identical(other.error, error) || other is Failed &&
const DeepCollectionEquality().equals(other.error, error))); (identical(other.error, error) || other.error == error));
} }
@override @override
int get hashCode => int get hashCode => Object.hash(runtimeType, error);
runtimeType.hashCode ^ const DeepCollectionEquality().hash(error);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
@@ -687,7 +699,7 @@ class _$Failed implements Failed {
@override @override
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return _$$FailedToJson(this)..['runtimeType'] = 'failed'; return _$$FailedToJson(this);
} }
} }
@@ -696,7 +708,7 @@ abstract class Failed implements UploadState {
factory Failed.fromJson(Map<String, dynamic> json) = _$Failed.fromJson; factory Failed.fromJson(Map<String, dynamic> json) = _$Failed.fromJson;
String get error => throw _privateConstructorUsedError; String get error;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$FailedCopyWith<Failed> get copyWith => throw _privateConstructorUsedError; $FailedCopyWith<Failed> get copyWith => throw _privateConstructorUsedError;
} }
@@ -22,31 +22,42 @@ Map<String, dynamic> _$AttachmentFileToJson(AttachmentFile instance) =>
'size': instance.size, 'size': instance.size,
}; };
_$Preparing _$$PreparingFromJson(Map<String, dynamic> json) => _$Preparing(); _$Preparing _$$PreparingFromJson(Map<String, dynamic> json) => _$Preparing(
$type: json['type'] as String?,
);
Map<String, dynamic> _$$PreparingToJson(_$Preparing instance) => Map<String, dynamic> _$$PreparingToJson(_$Preparing instance) =>
<String, dynamic>{}; <String, dynamic>{
'type': instance.$type,
};
_$InProgress _$$InProgressFromJson(Map<String, dynamic> json) => _$InProgress( _$InProgress _$$InProgressFromJson(Map<String, dynamic> json) => _$InProgress(
uploaded: json['uploaded'] as int, uploaded: json['uploaded'] as int,
total: json['total'] as int, total: json['total'] as int,
$type: json['type'] as String?,
); );
Map<String, dynamic> _$$InProgressToJson(_$InProgress instance) => Map<String, dynamic> _$$InProgressToJson(_$InProgress instance) =>
<String, dynamic>{ <String, dynamic>{
'uploaded': instance.uploaded, 'uploaded': instance.uploaded,
'total': instance.total, 'total': instance.total,
'type': instance.$type,
}; };
_$Success _$$SuccessFromJson(Map<String, dynamic> json) => _$Success(); _$Success _$$SuccessFromJson(Map<String, dynamic> json) => _$Success(
$type: json['type'] as String?,
);
Map<String, dynamic> _$$SuccessToJson(_$Success instance) => Map<String, dynamic> _$$SuccessToJson(_$Success instance) => <String, dynamic>{
<String, dynamic>{}; 'type': instance.$type,
};
_$Failed _$$FailedFromJson(Map<String, dynamic> json) => _$Failed( _$Failed _$$FailedFromJson(Map<String, dynamic> json) => _$Failed(
error: json['error'] as String, error: json['error'] as String,
$type: json['type'] as String?,
); );
Map<String, dynamic> _$$FailedToJson(_$Failed instance) => <String, dynamic>{ Map<String, dynamic> _$$FailedToJson(_$Failed instance) => <String, dynamic>{
'error': instance.error, 'error': instance.error,
'type': instance.$type,
}; };
@@ -181,7 +181,7 @@ class EventChannel extends ChannelModel {
required DateTime createdAt, required DateTime createdAt,
required DateTime updatedAt, required DateTime updatedAt,
DateTime? deletedAt, DateTime? deletedAt,
required int memberCount, int memberCount = 0,
Map<String, Object?>? extraData, Map<String, Object?>? extraData,
int cooldown = 0, int cooldown = 0,
String? team, String? team,
@@ -82,7 +82,7 @@ EventChannel _$EventChannelFromJson(Map<String, dynamic> json) => EventChannel(
deletedAt: json['deleted_at'] == null deletedAt: json['deleted_at'] == null
? null ? null
: DateTime.parse(json['deleted_at'] as String), : DateTime.parse(json['deleted_at'] as String),
memberCount: json['member_count'] as int, memberCount: json['member_count'] as int? ?? 0,
extraData: json['extra_data'] as Map<String, dynamic>?, extraData: json['extra_data'] as Map<String, dynamic>?,
cooldown: json['cooldown'] as int? ?? 0, cooldown: json['cooldown'] as int? ?? 0,
team: json['team'] as String?, team: json['team'] as String?,
@@ -310,7 +310,10 @@ class WebSocket with TimerHelper {
Event? event; Event? event;
try { try {
event = Event.fromJson(jsonData); event = Event.fromJson(jsonData);
} catch (_) {} } catch (e, stk) {
_logger?.warning('Error parsing an event: $e');
_logger?.warning('Stack trace: $stk');
}
if (event == null) return; if (event == null) return;
+1 -1
View File
@@ -16,7 +16,7 @@ dependencies:
freezed_annotation: ^0.15.0 freezed_annotation: ^0.15.0
http_parser: ^4.0.0 http_parser: ^4.0.0
jose: ^0.3.2 jose: ^0.3.2
json_annotation: ^4.0.1 json_annotation: ^4.3.0
logging: ^1.0.1 logging: ^1.0.1
meta: ^1.3.0 meta: ^1.3.0
mime: ^1.0.0 mime: ^1.0.0