fix(settings): nullable userId in contact-lists DTO
The /devices/:id/contact-lists endpoint returns items with type='app-contacts' that have userId nested in each contact instead of at item level. Required userId on ContactListItemResponseDto was making the parse throw, surfacing as a generic error toast on the sos_agenda screen (and previously on block_phone). userId is not consumed downstream — repos filter by type and map only name/phone — so making it nullable is safe.
This commit is contained in:
@@ -17,7 +17,7 @@ abstract class GetContactListsResponseDto with _$GetContactListsResponseDto {
|
||||
abstract class ContactListItemResponseDto with _$ContactListItemResponseDto {
|
||||
const factory ContactListItemResponseDto({
|
||||
required String id,
|
||||
required String userId,
|
||||
String? userId,
|
||||
required String deviceId,
|
||||
required String type,
|
||||
required List<ContactListContactResponseDto> contacts,
|
||||
|
||||
@@ -284,7 +284,7 @@ as List<ContactListItemResponseDto>,
|
||||
/// @nodoc
|
||||
mixin _$ContactListItemResponseDto {
|
||||
|
||||
String get id; String get userId; String get deviceId; String get type; List<ContactListContactResponseDto> get contacts; int get createdAt; int? get updatedAt;
|
||||
String get id; String? get userId; String get deviceId; String get type; List<ContactListContactResponseDto> get contacts; int get createdAt; int? get updatedAt;
|
||||
/// Create a copy of ContactListItemResponseDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -317,7 +317,7 @@ abstract mixin class $ContactListItemResponseDtoCopyWith<$Res> {
|
||||
factory $ContactListItemResponseDtoCopyWith(ContactListItemResponseDto value, $Res Function(ContactListItemResponseDto) _then) = _$ContactListItemResponseDtoCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt
|
||||
String id, String? userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt
|
||||
});
|
||||
|
||||
|
||||
@@ -334,11 +334,11 @@ class _$ContactListItemResponseDtoCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ContactListItemResponseDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = null,Object? deviceId = null,Object? type = null,Object? contacts = null,Object? createdAt = null,Object? updatedAt = freezed,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = freezed,Object? deviceId = null,Object? type = null,Object? contacts = null,Object? createdAt = null,Object? updatedAt = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,contacts: null == contacts ? _self.contacts : contacts // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactListContactResponseDto>,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
@@ -428,7 +428,7 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactListItemResponseDto() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_that.createdAt,_that.updatedAt);case _:
|
||||
@@ -449,7 +449,7 @@ return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactListItemResponseDto():
|
||||
return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_that.createdAt,_that.updatedAt);case _:
|
||||
@@ -469,7 +469,7 @@ return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactListItemResponseDto() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_that.createdAt,_that.updatedAt);case _:
|
||||
@@ -484,11 +484,11 @@ return $default(_that.id,_that.userId,_that.deviceId,_that.type,_that.contacts,_
|
||||
@JsonSerializable()
|
||||
|
||||
class _ContactListItemResponseDto implements ContactListItemResponseDto {
|
||||
const _ContactListItemResponseDto({required this.id, required this.userId, required this.deviceId, required this.type, required final List<ContactListContactResponseDto> contacts, required this.createdAt, this.updatedAt}): _contacts = contacts;
|
||||
const _ContactListItemResponseDto({required this.id, this.userId, required this.deviceId, required this.type, required final List<ContactListContactResponseDto> contacts, required this.createdAt, this.updatedAt}): _contacts = contacts;
|
||||
factory _ContactListItemResponseDto.fromJson(Map<String, dynamic> json) => _$ContactListItemResponseDtoFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String userId;
|
||||
@override final String? userId;
|
||||
@override final String deviceId;
|
||||
@override final String type;
|
||||
final List<ContactListContactResponseDto> _contacts;
|
||||
@@ -534,7 +534,7 @@ abstract mixin class _$ContactListItemResponseDtoCopyWith<$Res> implements $Cont
|
||||
factory _$ContactListItemResponseDtoCopyWith(_ContactListItemResponseDto value, $Res Function(_ContactListItemResponseDto) _then) = __$ContactListItemResponseDtoCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt
|
||||
String id, String? userId, String deviceId, String type, List<ContactListContactResponseDto> contacts, int createdAt, int? updatedAt
|
||||
});
|
||||
|
||||
|
||||
@@ -551,11 +551,11 @@ class __$ContactListItemResponseDtoCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ContactListItemResponseDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = null,Object? deviceId = null,Object? type = null,Object? contacts = null,Object? createdAt = null,Object? updatedAt = freezed,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = freezed,Object? deviceId = null,Object? type = null,Object? contacts = null,Object? createdAt = null,Object? updatedAt = freezed,}) {
|
||||
return _then(_ContactListItemResponseDto(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
|
||||
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as String,contacts: null == contacts ? _self._contacts : contacts // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactListContactResponseDto>,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
|
||||
@@ -24,7 +24,7 @@ _ContactListItemResponseDto _$ContactListItemResponseDtoFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ContactListItemResponseDto(
|
||||
id: json['id'] as String,
|
||||
userId: json['userId'] as String,
|
||||
userId: json['userId'] as String?,
|
||||
deviceId: json['deviceId'] as String,
|
||||
type: json['type'] as String,
|
||||
contacts: (json['contacts'] as List<dynamic>)
|
||||
|
||||
Reference in New Issue
Block a user