Friend management

This commit is contained in:
2024-11-30 22:39:49 +08:00
parent a2a42f66a2
commit 0c2df45337
14 changed files with 1060 additions and 37 deletions

View File

@ -70,3 +70,22 @@ class SnAccountProfile with _$SnAccountProfile {
factory SnAccountProfile.fromJson(Map<String, Object?> json) =>
_$SnAccountProfileFromJson(json);
}
@freezed
class SnRelationship with _$SnRelationship {
const factory SnRelationship({
required int id,
required DateTime createdAt,
required DateTime updatedAt,
required DateTime? deletedAt,
required int accountId,
required int relatedId,
required SnAccount? account,
required SnAccount? related,
required int status,
@Default({}) Map<String, dynamic> permNodes,
}) = _SnRelationship;
factory SnRelationship.fromJson(Map<String, Object?> json) =>
_$SnRelationshipFromJson(json);
}

View File

@ -1271,3 +1271,397 @@ abstract class _SnAccountProfile implements SnAccountProfile {
_$$SnAccountProfileImplCopyWith<_$SnAccountProfileImpl> get copyWith =>
throw _privateConstructorUsedError;
}
SnRelationship _$SnRelationshipFromJson(Map<String, dynamic> json) {
return _SnRelationship.fromJson(json);
}
/// @nodoc
mixin _$SnRelationship {
int get id => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
DateTime get updatedAt => throw _privateConstructorUsedError;
DateTime? get deletedAt => throw _privateConstructorUsedError;
int get accountId => throw _privateConstructorUsedError;
int get relatedId => throw _privateConstructorUsedError;
SnAccount? get account => throw _privateConstructorUsedError;
SnAccount? get related => throw _privateConstructorUsedError;
int get status => throw _privateConstructorUsedError;
Map<String, dynamic> get permNodes => throw _privateConstructorUsedError;
/// Serializes this SnRelationship to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SnRelationshipCopyWith<SnRelationship> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SnRelationshipCopyWith<$Res> {
factory $SnRelationshipCopyWith(
SnRelationship value, $Res Function(SnRelationship) then) =
_$SnRelationshipCopyWithImpl<$Res, SnRelationship>;
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
int accountId,
int relatedId,
SnAccount? account,
SnAccount? related,
int status,
Map<String, dynamic> permNodes});
$SnAccountCopyWith<$Res>? get account;
$SnAccountCopyWith<$Res>? get related;
}
/// @nodoc
class _$SnRelationshipCopyWithImpl<$Res, $Val extends SnRelationship>
implements $SnRelationshipCopyWith<$Res> {
_$SnRelationshipCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? accountId = null,
Object? relatedId = null,
Object? account = freezed,
Object? related = freezed,
Object? status = null,
Object? permNodes = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
deletedAt: freezed == deletedAt
? _value.deletedAt
: deletedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
accountId: null == accountId
? _value.accountId
: accountId // ignore: cast_nullable_to_non_nullable
as int,
relatedId: null == relatedId
? _value.relatedId
: relatedId // ignore: cast_nullable_to_non_nullable
as int,
account: freezed == account
? _value.account
: account // ignore: cast_nullable_to_non_nullable
as SnAccount?,
related: freezed == related
? _value.related
: related // ignore: cast_nullable_to_non_nullable
as SnAccount?,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as int,
permNodes: null == permNodes
? _value.permNodes
: permNodes // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
) as $Val);
}
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnAccountCopyWith<$Res>? get account {
if (_value.account == null) {
return null;
}
return $SnAccountCopyWith<$Res>(_value.account!, (value) {
return _then(_value.copyWith(account: value) as $Val);
});
}
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnAccountCopyWith<$Res>? get related {
if (_value.related == null) {
return null;
}
return $SnAccountCopyWith<$Res>(_value.related!, (value) {
return _then(_value.copyWith(related: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$SnRelationshipImplCopyWith<$Res>
implements $SnRelationshipCopyWith<$Res> {
factory _$$SnRelationshipImplCopyWith(_$SnRelationshipImpl value,
$Res Function(_$SnRelationshipImpl) then) =
__$$SnRelationshipImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
DateTime createdAt,
DateTime updatedAt,
DateTime? deletedAt,
int accountId,
int relatedId,
SnAccount? account,
SnAccount? related,
int status,
Map<String, dynamic> permNodes});
@override
$SnAccountCopyWith<$Res>? get account;
@override
$SnAccountCopyWith<$Res>? get related;
}
/// @nodoc
class __$$SnRelationshipImplCopyWithImpl<$Res>
extends _$SnRelationshipCopyWithImpl<$Res, _$SnRelationshipImpl>
implements _$$SnRelationshipImplCopyWith<$Res> {
__$$SnRelationshipImplCopyWithImpl(
_$SnRelationshipImpl _value, $Res Function(_$SnRelationshipImpl) _then)
: super(_value, _then);
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? deletedAt = freezed,
Object? accountId = null,
Object? relatedId = null,
Object? account = freezed,
Object? related = freezed,
Object? status = null,
Object? permNodes = null,
}) {
return _then(_$SnRelationshipImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
deletedAt: freezed == deletedAt
? _value.deletedAt
: deletedAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
accountId: null == accountId
? _value.accountId
: accountId // ignore: cast_nullable_to_non_nullable
as int,
relatedId: null == relatedId
? _value.relatedId
: relatedId // ignore: cast_nullable_to_non_nullable
as int,
account: freezed == account
? _value.account
: account // ignore: cast_nullable_to_non_nullable
as SnAccount?,
related: freezed == related
? _value.related
: related // ignore: cast_nullable_to_non_nullable
as SnAccount?,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as int,
permNodes: null == permNodes
? _value._permNodes
: permNodes // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$SnRelationshipImpl implements _SnRelationship {
const _$SnRelationshipImpl(
{required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.accountId,
required this.relatedId,
required this.account,
required this.related,
required this.status,
final Map<String, dynamic> permNodes = const {}})
: _permNodes = permNodes;
factory _$SnRelationshipImpl.fromJson(Map<String, dynamic> json) =>
_$$SnRelationshipImplFromJson(json);
@override
final int id;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
final DateTime? deletedAt;
@override
final int accountId;
@override
final int relatedId;
@override
final SnAccount? account;
@override
final SnAccount? related;
@override
final int status;
final Map<String, dynamic> _permNodes;
@override
@JsonKey()
Map<String, dynamic> get permNodes {
if (_permNodes is EqualUnmodifiableMapView) return _permNodes;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_permNodes);
}
@override
String toString() {
return 'SnRelationship(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, accountId: $accountId, relatedId: $relatedId, account: $account, related: $related, status: $status, permNodes: $permNodes)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SnRelationshipImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.deletedAt, deletedAt) ||
other.deletedAt == deletedAt) &&
(identical(other.accountId, accountId) ||
other.accountId == accountId) &&
(identical(other.relatedId, relatedId) ||
other.relatedId == relatedId) &&
(identical(other.account, account) || other.account == account) &&
(identical(other.related, related) || other.related == related) &&
(identical(other.status, status) || other.status == status) &&
const DeepCollectionEquality()
.equals(other._permNodes, _permNodes));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
createdAt,
updatedAt,
deletedAt,
accountId,
relatedId,
account,
related,
status,
const DeepCollectionEquality().hash(_permNodes));
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SnRelationshipImplCopyWith<_$SnRelationshipImpl> get copyWith =>
__$$SnRelationshipImplCopyWithImpl<_$SnRelationshipImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$SnRelationshipImplToJson(
this,
);
}
}
abstract class _SnRelationship implements SnRelationship {
const factory _SnRelationship(
{required final int id,
required final DateTime createdAt,
required final DateTime updatedAt,
required final DateTime? deletedAt,
required final int accountId,
required final int relatedId,
required final SnAccount? account,
required final SnAccount? related,
required final int status,
final Map<String, dynamic> permNodes}) = _$SnRelationshipImpl;
factory _SnRelationship.fromJson(Map<String, dynamic> json) =
_$SnRelationshipImpl.fromJson;
@override
int get id;
@override
DateTime get createdAt;
@override
DateTime get updatedAt;
@override
DateTime? get deletedAt;
@override
int get accountId;
@override
int get relatedId;
@override
SnAccount? get account;
@override
SnAccount? get related;
@override
int get status;
@override
Map<String, dynamic> get permNodes;
/// Create a copy of SnRelationship
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SnRelationshipImplCopyWith<_$SnRelationshipImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -129,3 +129,38 @@ Map<String, dynamic> _$$SnAccountProfileImplToJson(
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
};
_$SnRelationshipImpl _$$SnRelationshipImplFromJson(Map<String, dynamic> json) =>
_$SnRelationshipImpl(
id: (json['id'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
accountId: (json['account_id'] as num).toInt(),
relatedId: (json['related_id'] as num).toInt(),
account: json['account'] == null
? null
: SnAccount.fromJson(json['account'] as Map<String, dynamic>),
related: json['related'] == null
? null
: SnAccount.fromJson(json['related'] as Map<String, dynamic>),
status: (json['status'] as num).toInt(),
permNodes: json['perm_nodes'] as Map<String, dynamic>? ?? const {},
);
Map<String, dynamic> _$$SnRelationshipImplToJson(
_$SnRelationshipImpl instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'account_id': instance.accountId,
'related_id': instance.relatedId,
'account': instance.account?.toJson(),
'related': instance.related?.toJson(),
'status': instance.status,
'perm_nodes': instance.permNodes,
};

View File

@ -37,7 +37,6 @@ mixin _$SnChannel {
@HiveField(7)
List<dynamic>? get members => throw _privateConstructorUsedError;
List<SnChatMessage>? get messages => throw _privateConstructorUsedError;
dynamic get calls => throw _privateConstructorUsedError;
@HiveField(8)
int get type => throw _privateConstructorUsedError;
@HiveField(9)
@ -76,7 +75,6 @@ abstract class $SnChannelCopyWith<$Res> {
@HiveField(6) String description,
@HiveField(7) List<dynamic>? members,
List<SnChatMessage>? messages,
dynamic calls,
@HiveField(8) int type,
@HiveField(9) int accountId,
@HiveField(10) SnRealm? realm,
@ -111,7 +109,6 @@ class _$SnChannelCopyWithImpl<$Res, $Val extends SnChannel>
Object? description = null,
Object? members = freezed,
Object? messages = freezed,
Object? calls = freezed,
Object? type = null,
Object? accountId = null,
Object? realm = freezed,
@ -156,10 +153,6 @@ class _$SnChannelCopyWithImpl<$Res, $Val extends SnChannel>
? _value.messages
: messages // ignore: cast_nullable_to_non_nullable
as List<SnChatMessage>?,
calls: freezed == calls
? _value.calls
: calls // ignore: cast_nullable_to_non_nullable
as dynamic,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
@ -220,7 +213,6 @@ abstract class _$$SnChannelImplCopyWith<$Res>
@HiveField(6) String description,
@HiveField(7) List<dynamic>? members,
List<SnChatMessage>? messages,
dynamic calls,
@HiveField(8) int type,
@HiveField(9) int accountId,
@HiveField(10) SnRealm? realm,
@ -254,7 +246,6 @@ class __$$SnChannelImplCopyWithImpl<$Res>
Object? description = null,
Object? members = freezed,
Object? messages = freezed,
Object? calls = freezed,
Object? type = null,
Object? accountId = null,
Object? realm = freezed,
@ -299,10 +290,6 @@ class __$$SnChannelImplCopyWithImpl<$Res>
? _value._messages
: messages // ignore: cast_nullable_to_non_nullable
as List<SnChatMessage>?,
calls: freezed == calls
? _value.calls
: calls // ignore: cast_nullable_to_non_nullable
as dynamic,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
@ -345,7 +332,6 @@ class _$SnChannelImpl extends _SnChannel {
@HiveField(6) required this.description,
@HiveField(7) required final List<dynamic>? members,
final List<SnChatMessage>? messages,
this.calls,
@HiveField(8) required this.type,
@HiveField(9) required this.accountId,
@HiveField(10) required this.realm,
@ -401,8 +387,6 @@ class _$SnChannelImpl extends _SnChannel {
return EqualUnmodifiableListView(value);
}
@override
final dynamic calls;
@override
@HiveField(8)
final int type;
@ -424,7 +408,7 @@ class _$SnChannelImpl extends _SnChannel {
@override
String toString() {
return 'SnChannel(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, alias: $alias, name: $name, description: $description, members: $members, messages: $messages, calls: $calls, type: $type, accountId: $accountId, realm: $realm, realmId: $realmId, isPublic: $isPublic, isCommunity: $isCommunity)';
return 'SnChannel(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, alias: $alias, name: $name, description: $description, members: $members, messages: $messages, type: $type, accountId: $accountId, realm: $realm, realmId: $realmId, isPublic: $isPublic, isCommunity: $isCommunity)';
}
@override
@ -444,7 +428,6 @@ class _$SnChannelImpl extends _SnChannel {
other.description == description) &&
const DeepCollectionEquality().equals(other._members, _members) &&
const DeepCollectionEquality().equals(other._messages, _messages) &&
const DeepCollectionEquality().equals(other.calls, calls) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.accountId, accountId) ||
other.accountId == accountId) &&
@ -469,7 +452,6 @@ class _$SnChannelImpl extends _SnChannel {
description,
const DeepCollectionEquality().hash(_members),
const DeepCollectionEquality().hash(_messages),
const DeepCollectionEquality().hash(calls),
type,
accountId,
realm,
@ -504,7 +486,6 @@ abstract class _SnChannel extends SnChannel {
@HiveField(6) required final String description,
@HiveField(7) required final List<dynamic>? members,
final List<SnChatMessage>? messages,
final dynamic calls,
@HiveField(8) required final int type,
@HiveField(9) required final int accountId,
@HiveField(10) required final SnRealm? realm,
@ -543,8 +524,6 @@ abstract class _SnChannel extends SnChannel {
@override
List<SnChatMessage>? get messages;
@override
dynamic get calls;
@override
@HiveField(8)
int get type;
@override

View File

@ -227,7 +227,6 @@ _$SnChannelImpl _$$SnChannelImplFromJson(Map<String, dynamic> json) =>
messages: (json['messages'] as List<dynamic>?)
?.map((e) => SnChatMessage.fromJson(e as Map<String, dynamic>))
.toList(),
calls: json['calls'],
type: (json['type'] as num).toInt(),
accountId: (json['account_id'] as num).toInt(),
realm: json['realm'] == null
@ -249,7 +248,6 @@ Map<String, dynamic> _$$SnChannelImplToJson(_$SnChannelImpl instance) =>
'description': instance.description,
'members': instance.members,
'messages': instance.messages?.map((e) => e.toJson()).toList(),
'calls': instance.calls,
'type': instance.type,
'account_id': instance.accountId,
'realm': instance.realm?.toJson(),