diff --git a/lib/database/drift_db.dart b/lib/database/drift_db.dart index 1e822e6..8c60424 100644 --- a/lib/database/drift_db.dart +++ b/lib/database/drift_db.dart @@ -75,7 +75,7 @@ class AppDatabase extends _$AppDatabase { LazyDatabase _openConnection() { return LazyDatabase(() async { final dbFolder = await getApplicationDocumentsDirectory(); - final file = File(p.join(dbFolder.path, 'island_chat.sqlite')); + final file = File(p.join(dbFolder.path, 'solar_network_data.sqlite')); return NativeDatabase(file); }); } diff --git a/lib/database/message_repository.dart b/lib/database/message_repository.dart index 24498af..862ca90 100644 --- a/lib/database/message_repository.dart +++ b/lib/database/message_repository.dart @@ -12,7 +12,7 @@ class MessageRepository { SnChatMember? _identity; - final Map _pendingMessages = {}; + final Map pendingMessages = {}; MessageRepository(this.room, this._apiClient, this._database) { initialize(); @@ -84,7 +84,7 @@ class MessageRepository { // Combine with pending messages final pendingForRoom = - _pendingMessages.values.where((msg) => msg.roomId == roomId).toList(); + pendingMessages.values.where((msg) => msg.roomId == roomId).toList(); // Sort by timestamp descending (newest first) final allMessages = [...pendingForRoom, ...dbLocalMessages]; @@ -127,7 +127,7 @@ class MessageRepository { for (final message in messages) { await _database.saveMessage(_database.messageToCompanion(message)); if (message.nonce != null) { - _pendingMessages.removeWhere( + pendingMessages.removeWhere( (_, pendingMsg) => pendingMsg.nonce == message.nonce, ); } @@ -138,11 +138,12 @@ class MessageRepository { Future sendMessage( int roomId, - String content, { + String content, + String nonce, { List? attachments, Map? meta, }) async { - if (!initialized) { + if (!initialized || _identity == null) { throw UnsupportedError( "The message repository is not ready for send message.", ); @@ -169,7 +170,7 @@ class MessageRepository { ); // Store in memory and database - _pendingMessages[localMessage.id] = localMessage; + pendingMessages[localMessage.id] = localMessage; await _database.saveMessage(_database.messageToCompanion(localMessage)); try { @@ -192,7 +193,7 @@ class MessageRepository { ); // Remove from pending and update in database - _pendingMessages.remove(localMessage.id); + pendingMessages.remove(localMessage.id); await _database.deleteMessage(localMessage.id); await _database.saveMessage(_database.messageToCompanion(updatedMessage)); @@ -200,7 +201,7 @@ class MessageRepository { } catch (e) { // Update status to failed localMessage.status = MessageStatus.failed; - _pendingMessages[localMessage.id] = localMessage; + pendingMessages[localMessage.id] = localMessage; await _database.updateMessageStatus( localMessage.id, MessageStatus.failed, @@ -210,14 +211,14 @@ class MessageRepository { } Future retryMessage(String pendingMessageId) async { - final message = _pendingMessages[pendingMessageId]; + final message = pendingMessages[pendingMessageId]; if (message == null) { throw Exception('Message not found'); } // Update status back to pending message.status = MessageStatus.pending; - _pendingMessages[pendingMessageId] = message; + pendingMessages[pendingMessageId] = message; await _database.updateMessageStatus( pendingMessageId, MessageStatus.pending, @@ -244,7 +245,7 @@ class MessageRepository { ); // Remove from pending and update in database - _pendingMessages.remove(pendingMessageId); + pendingMessages.remove(pendingMessageId); await _database.deleteMessage(pendingMessageId); await _database.saveMessage(_database.messageToCompanion(updatedMessage)); @@ -252,7 +253,7 @@ class MessageRepository { } catch (e) { // Update status to failed message.status = MessageStatus.failed; - _pendingMessages[pendingMessageId] = message; + pendingMessages[pendingMessageId] = message; await _database.updateMessageStatus( pendingMessageId, MessageStatus.failed, diff --git a/lib/models/chat.dart b/lib/models/chat.dart index 652b531..02e9db4 100644 --- a/lib/models/chat.dart +++ b/lib/models/chat.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:island/models/file.dart'; import 'package:island/models/realm.dart'; +import 'package:island/models/user.dart'; part 'chat.freezed.dart'; part 'chat.g.dart'; @@ -13,7 +14,9 @@ abstract class SnChat with _$SnChat { required String description, required int type, required bool isPublic, + required String? pictureId, required SnCloudFile? picture, + required String? backgroundId, required SnCloudFile? background, required int? realmId, required SnRealm? realm, @@ -79,6 +82,7 @@ abstract class SnChatMember with _$SnChatMember { required String id, required int chatRoomId, required int accountId, + required SnAccount account, required String? nick, required int role, required int notify, diff --git a/lib/models/chat.freezed.dart b/lib/models/chat.freezed.dart index 0fd4724..7e723bd 100644 --- a/lib/models/chat.freezed.dart +++ b/lib/models/chat.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SnChat { - int get id; String get name; String get description; int get type; bool get isPublic; SnCloudFile? get picture; SnCloudFile? get background; int? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + int get id; String get name; String get description; int get type; bool get isPublic; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; int? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnChat /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -29,16 +29,16 @@ $SnChatCopyWith get copyWith => _$SnChatCopyWithImpl(this as SnC @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,picture,background,realmId,realm,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -49,7 +49,7 @@ abstract mixin class $SnChatCopyWith<$Res> { factory $SnChatCopyWith(SnChat value, $Res Function(SnChat) _then) = _$SnChatCopyWithImpl; @useResult $Res call({ - int id, String name, String description, int type, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -66,15 +66,17 @@ class _$SnChatCopyWithImpl<$Res> /// Create a copy of SnChat /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable -as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as bool,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_to_non_nullable as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable @@ -127,7 +129,7 @@ $SnRealmCopyWith<$Res>? get realm { @JsonSerializable() class _SnChat implements SnChat { - const _SnChat({required this.id, required this.name, required this.description, required this.type, required this.isPublic, required this.picture, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt}); + const _SnChat({required this.id, required this.name, required this.description, required this.type, required this.isPublic, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt}); factory _SnChat.fromJson(Map json) => _$SnChatFromJson(json); @override final int id; @@ -135,7 +137,9 @@ class _SnChat implements SnChat { @override final String description; @override final int type; @override final bool isPublic; +@override final String? pictureId; @override final SnCloudFile? picture; +@override final String? backgroundId; @override final SnCloudFile? background; @override final int? realmId; @override final SnRealm? realm; @@ -156,16 +160,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChat&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.type, type) || other.type == type)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.realm, realm) || other.realm == realm)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,picture,background,realmId,realm,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,pictureId,picture,backgroundId,background,realmId,realm,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnChat(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -176,7 +180,7 @@ abstract mixin class _$SnChatCopyWith<$Res> implements $SnChatCopyWith<$Res> { factory _$SnChatCopyWith(_SnChat value, $Res Function(_SnChat) _then) = __$SnChatCopyWithImpl; @override @useResult $Res call({ - int id, String name, String description, int type, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String name, String description, int type, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -193,15 +197,17 @@ class __$SnChatCopyWithImpl<$Res> /// Create a copy of SnChat /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? description = null,Object? type = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnChat( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable -as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as bool,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable as int?,realm: freezed == realm ? _self.realm : realm // ignore: cast_nullable_to_non_nullable as SnRealm?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable @@ -703,7 +709,7 @@ $SnChatMemberCopyWith<$Res> get sender { /// @nodoc mixin _$SnChatMember { - DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; int get chatRoomId; int get accountId; String? get nick; int get role; int get notify; DateTime? get joinedAt; bool get isBot; + DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; int get chatRoomId; int get accountId; SnAccount get account; String? get nick; int get role; int get notify; DateTime? get joinedAt; bool get isBot; /// Create a copy of SnChatMember /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -716,16 +722,16 @@ $SnChatMemberCopyWith get copyWith => _$SnChatMemberCopyWithImpl Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,accountId,nick,role,notify,joinedAt,isBot); +int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,accountId,account,nick,role,notify,joinedAt,isBot); @override String toString() { - return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, accountId: $accountId, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, isBot: $isBot)'; + return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, accountId: $accountId, account: $account, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, isBot: $isBot)'; } @@ -736,11 +742,11 @@ abstract mixin class $SnChatMemberCopyWith<$Res> { factory $SnChatMemberCopyWith(SnChatMember value, $Res Function(SnChatMember) _then) = _$SnChatMemberCopyWithImpl; @useResult $Res call({ - DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, int accountId, String? nick, int role, int notify, DateTime? joinedAt, bool isBot + DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot }); - +$SnAccountCopyWith<$Res> get account; } /// @nodoc @@ -753,7 +759,7 @@ class _$SnChatMemberCopyWithImpl<$Res> /// Create a copy of SnChatMember /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? accountId = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? isBot = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? isBot = null,}) { return _then(_self.copyWith( createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -761,7 +767,8 @@ as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ign as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable as int,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable -as int,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable +as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable +as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as int,notify: null == notify ? _self.notify : notify // ignore: cast_nullable_to_non_nullable as int,joinedAt: freezed == joinedAt ? _self.joinedAt : joinedAt // ignore: cast_nullable_to_non_nullable @@ -769,7 +776,16 @@ as DateTime?,isBot: null == isBot ? _self.isBot : isBot // ignore: cast_nullable as bool, )); } - +/// Create a copy of SnChatMember +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnAccountCopyWith<$Res> get account { + + return $SnAccountCopyWith<$Res>(_self.account, (value) { + return _then(_self.copyWith(account: value)); + }); +} } @@ -777,7 +793,7 @@ as bool, @JsonSerializable() class _SnChatMember implements SnChatMember { - const _SnChatMember({required this.createdAt, required this.updatedAt, required this.deletedAt, required this.id, required this.chatRoomId, required this.accountId, required this.nick, required this.role, required this.notify, required this.joinedAt, required this.isBot}); + const _SnChatMember({required this.createdAt, required this.updatedAt, required this.deletedAt, required this.id, required this.chatRoomId, required this.accountId, required this.account, required this.nick, required this.role, required this.notify, required this.joinedAt, required this.isBot}); factory _SnChatMember.fromJson(Map json) => _$SnChatMemberFromJson(json); @override final DateTime createdAt; @@ -786,6 +802,7 @@ class _SnChatMember implements SnChatMember { @override final String id; @override final int chatRoomId; @override final int accountId; +@override final SnAccount account; @override final String? nick; @override final int role; @override final int notify; @@ -805,16 +822,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChatMember&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&(identical(other.id, id) || other.id == id)&&(identical(other.chatRoomId, chatRoomId) || other.chatRoomId == chatRoomId)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.role, role) || other.role == role)&&(identical(other.notify, notify) || other.notify == notify)&&(identical(other.joinedAt, joinedAt) || other.joinedAt == joinedAt)&&(identical(other.isBot, isBot) || other.isBot == isBot)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChatMember&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)&&(identical(other.id, id) || other.id == id)&&(identical(other.chatRoomId, chatRoomId) || other.chatRoomId == chatRoomId)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.account, account) || other.account == account)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.role, role) || other.role == role)&&(identical(other.notify, notify) || other.notify == notify)&&(identical(other.joinedAt, joinedAt) || other.joinedAt == joinedAt)&&(identical(other.isBot, isBot) || other.isBot == isBot)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,accountId,nick,role,notify,joinedAt,isBot); +int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,accountId,account,nick,role,notify,joinedAt,isBot); @override String toString() { - return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, accountId: $accountId, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, isBot: $isBot)'; + return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, accountId: $accountId, account: $account, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, isBot: $isBot)'; } @@ -825,11 +842,11 @@ abstract mixin class _$SnChatMemberCopyWith<$Res> implements $SnChatMemberCopyWi factory _$SnChatMemberCopyWith(_SnChatMember value, $Res Function(_SnChatMember) _then) = __$SnChatMemberCopyWithImpl; @override @useResult $Res call({ - DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, int accountId, String? nick, int role, int notify, DateTime? joinedAt, bool isBot + DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, int chatRoomId, int accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, bool isBot }); - +@override $SnAccountCopyWith<$Res> get account; } /// @nodoc @@ -842,7 +859,7 @@ class __$SnChatMemberCopyWithImpl<$Res> /// Create a copy of SnChatMember /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? accountId = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? isBot = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? isBot = null,}) { return _then(_SnChatMember( createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -850,7 +867,8 @@ as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ign as DateTime?,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,chatRoomId: null == chatRoomId ? _self.chatRoomId : chatRoomId // ignore: cast_nullable_to_non_nullable as int,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable -as int,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable +as int,account: null == account ? _self.account : account // ignore: cast_nullable_to_non_nullable +as SnAccount,nick: freezed == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as int,notify: null == notify ? _self.notify : notify // ignore: cast_nullable_to_non_nullable as int,joinedAt: freezed == joinedAt ? _self.joinedAt : joinedAt // ignore: cast_nullable_to_non_nullable @@ -859,7 +877,16 @@ as bool, )); } - +/// Create a copy of SnChatMember +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SnAccountCopyWith<$Res> get account { + + return $SnAccountCopyWith<$Res>(_self.account, (value) { + return _then(_self.copyWith(account: value)); + }); +} } // dart format on diff --git a/lib/models/chat.g.dart b/lib/models/chat.g.dart index a09e382..2aa0cc7 100644 --- a/lib/models/chat.g.dart +++ b/lib/models/chat.g.dart @@ -12,10 +12,12 @@ _SnChat _$SnChatFromJson(Map json) => _SnChat( description: json['description'] as String, type: (json['type'] as num).toInt(), isPublic: json['is_public'] as bool, + pictureId: json['picture_id'] as String?, picture: json['picture'] == null ? null : SnCloudFile.fromJson(json['picture'] as Map), + backgroundId: json['background_id'] as String?, background: json['background'] == null ? null @@ -39,7 +41,9 @@ Map _$SnChatToJson(_SnChat instance) => { 'description': instance.description, 'type': instance.type, 'is_public': instance.isPublic, + 'picture_id': instance.pictureId, 'picture': instance.picture?.toJson(), + 'background_id': instance.backgroundId, 'background': instance.background?.toJson(), 'realm_id': instance.realmId, 'realm': instance.realm?.toJson(), @@ -160,6 +164,7 @@ _SnChatMember _$SnChatMemberFromJson(Map json) => id: json['id'] as String, chatRoomId: (json['chat_room_id'] as num).toInt(), accountId: (json['account_id'] as num).toInt(), + account: SnAccount.fromJson(json['account'] as Map), nick: json['nick'] as String?, role: (json['role'] as num).toInt(), notify: (json['notify'] as num).toInt(), @@ -178,6 +183,7 @@ Map _$SnChatMemberToJson(_SnChatMember instance) => 'id': instance.id, 'chat_room_id': instance.chatRoomId, 'account_id': instance.accountId, + 'account': instance.account.toJson(), 'nick': instance.nick, 'role': instance.role, 'notify': instance.notify, diff --git a/lib/models/post.dart b/lib/models/post.dart index e0b1c6e..ec10366 100644 --- a/lib/models/post.dart +++ b/lib/models/post.dart @@ -49,7 +49,9 @@ abstract class SnPublisher with _$SnPublisher { required String name, required String nick, required String bio, + required String? pictureId, required SnCloudFile? picture, + required String? backgroundId, required SnCloudFile? background, required int accountId, required DateTime createdAt, diff --git a/lib/models/post.freezed.dart b/lib/models/post.freezed.dart index 3a811e6..4ab2eb8 100644 --- a/lib/models/post.freezed.dart +++ b/lib/models/post.freezed.dart @@ -297,7 +297,7 @@ $SnPublisherCopyWith<$Res> get publisher { /// @nodoc mixin _$SnPublisher { - int get id; int get publisherType; String get name; String get nick; String get bio; SnCloudFile? get picture; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + int get id; int get publisherType; String get name; String get nick; String get bio; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -310,16 +310,16 @@ $SnPublisherCopyWith get copyWith => _$SnPublisherCopyWithImpl Object.hash(runtimeType,id,publisherType,name,nick,bio,picture,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,publisherType,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -330,7 +330,7 @@ abstract mixin class $SnPublisherCopyWith<$Res> { factory $SnPublisherCopyWith(SnPublisher value, $Res Function(SnPublisher) _then) = _$SnPublisherCopyWithImpl; @useResult $Res call({ - int id, int publisherType, String name, String nick, String bio, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, int publisherType, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -347,15 +347,17 @@ class _$SnPublisherCopyWithImpl<$Res> /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable -as String,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as String,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -395,7 +397,7 @@ $SnCloudFileCopyWith<$Res>? get background { @JsonSerializable() class _SnPublisher implements SnPublisher { - const _SnPublisher({required this.id, required this.publisherType, required this.name, required this.nick, required this.bio, required this.picture, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); + const _SnPublisher({required this.id, required this.publisherType, required this.name, required this.nick, required this.bio, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); factory _SnPublisher.fromJson(Map json) => _$SnPublisherFromJson(json); @override final int id; @@ -403,7 +405,9 @@ class _SnPublisher implements SnPublisher { @override final String name; @override final String nick; @override final String bio; +@override final String? pictureId; @override final SnCloudFile? picture; +@override final String? backgroundId; @override final SnCloudFile? background; @override final int accountId; @override final DateTime createdAt; @@ -423,16 +427,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPublisher&&(identical(other.id, id) || other.id == id)&&(identical(other.publisherType, publisherType) || other.publisherType == publisherType)&&(identical(other.name, name) || other.name == name)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnPublisher&&(identical(other.id, id) || other.id == id)&&(identical(other.publisherType, publisherType) || other.publisherType == publisherType)&&(identical(other.name, name) || other.name == name)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,publisherType,name,nick,bio,picture,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,publisherType,name,nick,bio,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnPublisher(id: $id, publisherType: $publisherType, name: $name, nick: $nick, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -443,7 +447,7 @@ abstract mixin class _$SnPublisherCopyWith<$Res> implements $SnPublisherCopyWith factory _$SnPublisherCopyWith(_SnPublisher value, $Res Function(_SnPublisher) _then) = __$SnPublisherCopyWithImpl; @override @useResult $Res call({ - int id, int publisherType, String name, String nick, String bio, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, int publisherType, String name, String nick, String bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -460,15 +464,17 @@ class __$SnPublisherCopyWithImpl<$Res> /// Create a copy of SnPublisher /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? publisherType = null,Object? name = null,Object? nick = null,Object? bio = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnPublisher( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,publisherType: null == publisherType ? _self.publisherType : publisherType // ignore: cast_nullable_to_non_nullable as int,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,nick: null == nick ? _self.nick : nick // ignore: cast_nullable_to_non_nullable as String,bio: null == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable -as String,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as String,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable diff --git a/lib/models/post.g.dart b/lib/models/post.g.dart index 322a0e8..46eb161 100644 --- a/lib/models/post.g.dart +++ b/lib/models/post.g.dart @@ -85,10 +85,12 @@ _SnPublisher _$SnPublisherFromJson(Map json) => _SnPublisher( name: json['name'] as String, nick: json['nick'] as String, bio: json['bio'] as String, + pictureId: json['picture_id'] as String?, picture: json['picture'] == null ? null : SnCloudFile.fromJson(json['picture'] as Map), + backgroundId: json['background_id'] as String?, background: json['background'] == null ? null @@ -109,7 +111,9 @@ Map _$SnPublisherToJson(_SnPublisher instance) => 'name': instance.name, 'nick': instance.nick, 'bio': instance.bio, + 'picture_id': instance.pictureId, 'picture': instance.picture?.toJson(), + 'background_id': instance.backgroundId, 'background': instance.background?.toJson(), 'account_id': instance.accountId, 'created_at': instance.createdAt.toIso8601String(), diff --git a/lib/models/realm.dart b/lib/models/realm.dart index 0c131ef..34a6b7e 100644 --- a/lib/models/realm.dart +++ b/lib/models/realm.dart @@ -15,7 +15,9 @@ abstract class SnRealm with _$SnRealm { required DateTime? verifiedAt, required bool isCommunity, required bool isPublic, + required String? pictureId, required SnCloudFile? picture, + required String? backgroundId, required SnCloudFile? background, required int accountId, required DateTime createdAt, diff --git a/lib/models/realm.freezed.dart b/lib/models/realm.freezed.dart index 7643b5b..ed12b2a 100644 --- a/lib/models/realm.freezed.dart +++ b/lib/models/realm.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SnRealm { - int get id; String get slug; String get name; String get description; String? get verifiedAs; DateTime? get verifiedAt; bool get isCommunity; bool get isPublic; SnCloudFile? get picture; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + int get id; String get slug; String get name; String get description; String? get verifiedAs; DateTime? get verifiedAt; bool get isCommunity; bool get isPublic; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; int get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnRealm /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -29,16 +29,16 @@ $SnRealmCopyWith get copyWith => _$SnRealmCopyWithImpl(this as @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,picture,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -49,7 +49,7 @@ abstract mixin class $SnRealmCopyWith<$Res> { factory $SnRealmCopyWith(SnRealm value, $Res Function(SnRealm) _then) = _$SnRealmCopyWithImpl; @useResult $Res call({ - int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -66,7 +66,7 @@ class _$SnRealmCopyWithImpl<$Res> /// Create a copy of SnRealm /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable @@ -76,8 +76,10 @@ as String,verifiedAs: freezed == verifiedAs ? _self.verifiedAs : verifiedAs // i as String?,verifiedAt: freezed == verifiedAt ? _self.verifiedAt : verifiedAt // ignore: cast_nullable_to_non_nullable as DateTime?,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ignore: cast_nullable_to_non_nullable as bool,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable -as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as bool,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -117,7 +119,7 @@ $SnCloudFileCopyWith<$Res>? get background { @JsonSerializable() class _SnRealm implements SnRealm { - const _SnRealm({required this.id, required this.slug, required this.name, required this.description, required this.verifiedAs, required this.verifiedAt, required this.isCommunity, required this.isPublic, required this.picture, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); + const _SnRealm({required this.id, required this.slug, required this.name, required this.description, required this.verifiedAs, required this.verifiedAt, required this.isCommunity, required this.isPublic, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}); factory _SnRealm.fromJson(Map json) => _$SnRealmFromJson(json); @override final int id; @@ -128,7 +130,9 @@ class _SnRealm implements SnRealm { @override final DateTime? verifiedAt; @override final bool isCommunity; @override final bool isPublic; +@override final String? pictureId; @override final SnCloudFile? picture; +@override final String? backgroundId; @override final SnCloudFile? background; @override final int accountId; @override final DateTime createdAt; @@ -148,16 +152,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnRealm&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.verifiedAs, verifiedAs) || other.verifiedAs == verifiedAs)&&(identical(other.verifiedAt, verifiedAt) || other.verifiedAt == verifiedAt)&&(identical(other.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.isPublic, isPublic) || other.isPublic == isPublic)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,picture,background,accountId,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,slug,name,description,verifiedAs,verifiedAt,isCommunity,isPublic,pictureId,picture,backgroundId,background,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, picture: $picture, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnRealm(id: $id, slug: $slug, name: $name, description: $description, verifiedAs: $verifiedAs, verifiedAt: $verifiedAt, isCommunity: $isCommunity, isPublic: $isPublic, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -168,7 +172,7 @@ abstract mixin class _$SnRealmCopyWith<$Res> implements $SnRealmCopyWith<$Res> { factory _$SnRealmCopyWith(_SnRealm value, $Res Function(_SnRealm) _then) = __$SnRealmCopyWithImpl; @override @useResult $Res call({ - int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, SnCloudFile? picture, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String slug, String name, String description, String? verifiedAs, DateTime? verifiedAt, bool isCommunity, bool isPublic, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, int accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -185,7 +189,7 @@ class __$SnRealmCopyWithImpl<$Res> /// Create a copy of SnRealm /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? picture = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? name = null,Object? description = null,Object? verifiedAs = freezed,Object? verifiedAt = freezed,Object? isCommunity = null,Object? isPublic = null,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnRealm( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable @@ -195,8 +199,10 @@ as String,verifiedAs: freezed == verifiedAs ? _self.verifiedAs : verifiedAs // i as String?,verifiedAt: freezed == verifiedAt ? _self.verifiedAt : verifiedAt // ignore: cast_nullable_to_non_nullable as DateTime?,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ignore: cast_nullable_to_non_nullable as bool,isPublic: null == isPublic ? _self.isPublic : isPublic // ignore: cast_nullable_to_non_nullable -as bool,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as bool,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable +as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable diff --git a/lib/models/realm.g.dart b/lib/models/realm.g.dart index 3932969..9b3834f 100644 --- a/lib/models/realm.g.dart +++ b/lib/models/realm.g.dart @@ -18,10 +18,12 @@ _SnRealm _$SnRealmFromJson(Map json) => _SnRealm( : DateTime.parse(json['verified_at'] as String), isCommunity: json['is_community'] as bool, isPublic: json['is_public'] as bool, + pictureId: json['picture_id'] as String?, picture: json['picture'] == null ? null : SnCloudFile.fromJson(json['picture'] as Map), + backgroundId: json['background_id'] as String?, background: json['background'] == null ? null @@ -44,7 +46,9 @@ Map _$SnRealmToJson(_SnRealm instance) => { 'verified_at': instance.verifiedAt?.toIso8601String(), 'is_community': instance.isCommunity, 'is_public': instance.isPublic, + 'picture_id': instance.pictureId, 'picture': instance.picture?.toJson(), + 'background_id': instance.backgroundId, 'background': instance.background?.toJson(), 'account_id': instance.accountId, 'created_at': instance.createdAt.toIso8601String(), diff --git a/lib/models/user.dart b/lib/models/user.dart index a83efda..5480fb7 100644 --- a/lib/models/user.dart +++ b/lib/models/user.dart @@ -30,7 +30,9 @@ abstract class SnAccountProfile with _$SnAccountProfile { required String? middleName, required String? lastName, required String? bio, + required String? pictureId, required SnCloudFile? picture, + required String? backgroundId, required SnCloudFile? background, required DateTime createdAt, required DateTime updatedAt, diff --git a/lib/models/user.freezed.dart b/lib/models/user.freezed.dart index c8fb0dd..59b156e 100644 --- a/lib/models/user.freezed.dart +++ b/lib/models/user.freezed.dart @@ -191,7 +191,7 @@ $SnAccountProfileCopyWith<$Res> get profile { /// @nodoc mixin _$SnAccountProfile { - int get id; String? get firstName; String? get middleName; String? get lastName; String? get bio; SnCloudFile? get picture; SnCloudFile? get background; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + int get id; String? get firstName; String? get middleName; String? get lastName; String? get bio; String? get pictureId; SnCloudFile? get picture; String? get backgroundId; SnCloudFile? get background; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnAccountProfile /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -204,16 +204,16 @@ $SnAccountProfileCopyWith get copyWith => _$SnAccountProfileCo @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,firstName,middleName,lastName,bio,picture,background,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,firstName,middleName,lastName,bio,pictureId,picture,backgroundId,background,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, picture: $picture, background: $background, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -224,7 +224,7 @@ abstract mixin class $SnAccountProfileCopyWith<$Res> { factory $SnAccountProfileCopyWith(SnAccountProfile value, $Res Function(SnAccountProfile) _then) = _$SnAccountProfileCopyWithImpl; @useResult $Res call({ - int id, String? firstName, String? middleName, String? lastName, String? bio, SnCloudFile? picture, SnCloudFile? background, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String? firstName, String? middleName, String? lastName, String? bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -241,15 +241,17 @@ class _$SnAccountProfileCopyWithImpl<$Res> /// Create a copy of SnAccountProfile /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = freezed,Object? middleName = freezed,Object? lastName = freezed,Object? bio = freezed,Object? picture = freezed,Object? background = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = freezed,Object? middleName = freezed,Object? lastName = freezed,Object? bio = freezed,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String?,middleName: freezed == middleName ? _self.middleName : middleName // ignore: cast_nullable_to_non_nullable as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String?,bio: freezed == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable +as String?,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable @@ -288,7 +290,7 @@ $SnCloudFileCopyWith<$Res>? get background { @JsonSerializable() class _SnAccountProfile implements SnAccountProfile { - const _SnAccountProfile({required this.id, required this.firstName, required this.middleName, required this.lastName, required this.bio, required this.picture, required this.background, required this.createdAt, required this.updatedAt, required this.deletedAt}); + const _SnAccountProfile({required this.id, required this.firstName, required this.middleName, required this.lastName, required this.bio, required this.pictureId, required this.picture, required this.backgroundId, required this.background, required this.createdAt, required this.updatedAt, required this.deletedAt}); factory _SnAccountProfile.fromJson(Map json) => _$SnAccountProfileFromJson(json); @override final int id; @@ -296,7 +298,9 @@ class _SnAccountProfile implements SnAccountProfile { @override final String? middleName; @override final String? lastName; @override final String? bio; +@override final String? pictureId; @override final SnCloudFile? picture; +@override final String? backgroundId; @override final SnCloudFile? background; @override final DateTime createdAt; @override final DateTime updatedAt; @@ -315,16 +319,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAccountProfile&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.middleName, middleName) || other.middleName == middleName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bio, bio) || other.bio == bio)&&(identical(other.pictureId, pictureId) || other.pictureId == pictureId)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.backgroundId, backgroundId) || other.backgroundId == backgroundId)&&(identical(other.background, background) || other.background == background)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,firstName,middleName,lastName,bio,picture,background,createdAt,updatedAt,deletedAt); +int get hashCode => Object.hash(runtimeType,id,firstName,middleName,lastName,bio,pictureId,picture,backgroundId,background,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, picture: $picture, background: $background, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnAccountProfile(id: $id, firstName: $firstName, middleName: $middleName, lastName: $lastName, bio: $bio, pictureId: $pictureId, picture: $picture, backgroundId: $backgroundId, background: $background, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -335,7 +339,7 @@ abstract mixin class _$SnAccountProfileCopyWith<$Res> implements $SnAccountProfi factory _$SnAccountProfileCopyWith(_SnAccountProfile value, $Res Function(_SnAccountProfile) _then) = __$SnAccountProfileCopyWithImpl; @override @useResult $Res call({ - int id, String? firstName, String? middleName, String? lastName, String? bio, SnCloudFile? picture, SnCloudFile? background, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + int id, String? firstName, String? middleName, String? lastName, String? bio, String? pictureId, SnCloudFile? picture, String? backgroundId, SnCloudFile? background, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -352,15 +356,17 @@ class __$SnAccountProfileCopyWithImpl<$Res> /// Create a copy of SnAccountProfile /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = freezed,Object? middleName = freezed,Object? lastName = freezed,Object? bio = freezed,Object? picture = freezed,Object? background = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = freezed,Object? middleName = freezed,Object? lastName = freezed,Object? bio = freezed,Object? pictureId = freezed,Object? picture = freezed,Object? backgroundId = freezed,Object? background = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnAccountProfile( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String?,middleName: freezed == middleName ? _self.middleName : middleName // ignore: cast_nullable_to_non_nullable as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String?,bio: freezed == bio ? _self.bio : bio // ignore: cast_nullable_to_non_nullable +as String?,pictureId: freezed == pictureId ? _self.pictureId : pictureId // ignore: cast_nullable_to_non_nullable as String?,picture: freezed == picture ? _self.picture : picture // ignore: cast_nullable_to_non_nullable -as SnCloudFile?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable +as SnCloudFile?,backgroundId: freezed == backgroundId ? _self.backgroundId : backgroundId // ignore: cast_nullable_to_non_nullable +as String?,background: freezed == background ? _self.background : background // ignore: cast_nullable_to_non_nullable as SnCloudFile?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable as DateTime,deletedAt: freezed == deletedAt ? _self.deletedAt : deletedAt // ignore: cast_nullable_to_non_nullable diff --git a/lib/models/user.g.dart b/lib/models/user.g.dart index 2d25894..db9a296 100644 --- a/lib/models/user.g.dart +++ b/lib/models/user.g.dart @@ -41,10 +41,12 @@ _SnAccountProfile _$SnAccountProfileFromJson(Map json) => middleName: json['middle_name'] as String?, lastName: json['last_name'] as String?, bio: json['bio'] as String?, + pictureId: json['picture_id'] as String?, picture: json['picture'] == null ? null : SnCloudFile.fromJson(json['picture'] as Map), + backgroundId: json['background_id'] as String?, background: json['background'] == null ? null @@ -66,7 +68,9 @@ Map _$SnAccountProfileToJson(_SnAccountProfile instance) => 'middle_name': instance.middleName, 'last_name': instance.lastName, 'bio': instance.bio, + 'picture_id': instance.pictureId, 'picture': instance.picture?.toJson(), + 'background_id': instance.backgroundId, 'background': instance.background?.toJson(), 'created_at': instance.createdAt.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(), diff --git a/lib/pods/message.dart b/lib/pods/message.dart index d230ed1..fc95f60 100644 --- a/lib/pods/message.dart +++ b/lib/pods/message.dart @@ -1,100 +1,32 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/database/drift_db.dart'; -import 'package:island/database/message.dart'; -import 'package:island/database/message_repository.dart'; -import 'package:island/models/chat.dart'; -import 'package:island/pods/network.dart'; -import 'package:island/widgets/alert.dart'; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; -// Global database instance final databaseProvider = Provider((ref) { final db = AppDatabase(); ref.onDispose(() => db.close()); return db; }); -final messageRepositoryProvider = - FutureProvider.family((ref, chat) async { - final apiClient = ref.watch(apiClientProvider); - final database = ref.watch(databaseProvider); - return MessageRepository(chat, apiClient, database); - }); +Future resetDatabase(WidgetRef ref) async { + if (kIsWeb) return; -final chatMessagesProvider = - FutureProvider.family, SnChat>((ref, room) async { - final repository = await ref.watch( - messageRepositoryProvider(room).future, - ); - return repository.listMessages(); - }); + final db = ref.read(databaseProvider); + final basepath = await getApplicationSupportDirectory(); + final file = File(join(basepath.path, 'solar_network_data.sqlite')); -class ChatMessageNotifier - extends StateNotifier>> { - final MessageRepository _repository; - final int roomId; - int _currentOffset = 0; - final int _pageSize = 20; - bool _hasMore = true; + // Close current database connection + db.close(); - ChatMessageNotifier(this._repository, this.roomId) - : super(const AsyncValue.loading()) { - loadInitial(); + // Delete database file + if (await file.exists()) { + await file.delete(); } - Future loadInitial() async { - state = const AsyncValue.loading(); - try { - final messages = await _repository.listMessages( - offset: 0, - take: _pageSize, - ); - _currentOffset = messages.length; - _hasMore = messages.length >= _pageSize; - state = AsyncValue.data(messages); - } catch (e, stack) { - state = AsyncValue.error(e, stack); - } - } - - Future loadMore() async { - if (!_hasMore) return; - - try { - final newMessages = await _repository.listMessages( - offset: _currentOffset, - take: _pageSize, - ); - - if (newMessages.isEmpty) { - _hasMore = false; - return; - } - - _currentOffset += newMessages.length; - _hasMore = newMessages.length >= _pageSize; - - state = AsyncValue.data([...state.value ?? [], ...newMessages]); - } catch (err) { - showErrorAlert(err); - } - } - - Future sendMessage(String content) async { - try { - final message = await _repository.sendMessage(roomId, content); - - final currentMessages = state.value ?? []; - state = AsyncValue.data([message, ...currentMessages]); - } catch (err) { - showErrorAlert(err); - } - } - - bool get hasMore => _hasMore; + // Force refresh the database provider + ref.invalidate(databaseProvider); } - -final chatMessageNotifierProvider = StateNotifierProvider.family< - ChatMessageNotifier, - AsyncValue>, - MessageRepository ->((ref, repository) => ChatMessageNotifier(repository, repository.room.id)); diff --git a/lib/pods/userinfo.dart b/lib/pods/userinfo.dart index aa778a6..87143df 100644 --- a/lib/pods/userinfo.dart +++ b/lib/pods/userinfo.dart @@ -21,7 +21,6 @@ class UserInfoNotifier extends StateNotifier> { final user = SnAccount.fromJson(response.data); state = AsyncValue.data(user); } catch (error, stackTrace) { - print('Failed to fetch user: $error'); state = AsyncValue.error(error, stackTrace); } } diff --git a/lib/screens/account.dart b/lib/screens/account.dart index a8389ff..bab8584 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:island/pods/message.dart'; import 'package:island/pods/network.dart'; import 'package:island/pods/userinfo.dart'; import 'package:island/route.gr.dart'; @@ -51,7 +52,7 @@ class AccountScreen extends HookConsumerWidget { spacing: 16, children: [ ProfilePictureWidget( - item: user.value!.profile.picture, + fileId: user.value!.profile.pictureId, radius: 24, ), Column( @@ -110,6 +111,17 @@ class AccountScreen extends HookConsumerWidget { Clipboard.setData(ClipboardData(text: tk!.accessToken)); }, ), + if (kDebugMode) + ListTile( + minTileHeight: 48, + leading: const Icon(Symbols.delete), + trailing: const Icon(Symbols.chevron_right), + contentPadding: EdgeInsets.symmetric(horizontal: 24), + title: Text('Reset database'), + onTap: () async { + resetDatabase(ref); + }, + ), const Divider(height: 1).padding(vertical: 8), ListTile( minTileHeight: 48, diff --git a/lib/screens/account/me/publishers.dart b/lib/screens/account/me/publishers.dart index 36f733b..286b817 100644 --- a/lib/screens/account/me/publishers.dart +++ b/lib/screens/account/me/publishers.dart @@ -69,7 +69,7 @@ class ManagedPublisherScreen extends HookConsumerWidget { itemBuilder: (context, item) { return ListTile( leading: ProfilePictureWidget( - item: value[item].picture, + fileId: value[item].pictureId, ), title: Text(value[item].nick), subtitle: Text('@${value[item].name}'), @@ -299,7 +299,7 @@ class EditPublisherScreen extends HookConsumerWidget { bottom: -32, child: GestureDetector( child: ProfilePictureWidget( - item: picture.value, + fileId: picture.value?.id, radius: 40, ), onTap: () { diff --git a/lib/screens/account/me/update.dart b/lib/screens/account/me/update.dart index ed69a6d..6bceeb4 100644 --- a/lib/screens/account/me/update.dart +++ b/lib/screens/account/me/update.dart @@ -151,7 +151,7 @@ class UpdateProfileScreen extends HookConsumerWidget { bottom: -32, child: GestureDetector( child: ProfilePictureWidget( - item: user.value!.profile.picture, + fileId: user.value!.profile.pictureId, radius: 40, ), onTap: () { diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index 6a182b2..bc5a751 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -38,6 +38,7 @@ class ChatListScreen extends HookConsumerWidget { return AppScaffold( appBar: AppBar(title: Text('chat').tr()), floatingActionButton: FloatingActionButton( + key: Key("chat-page-fab"), onPressed: () { context.pushRoute(NewChatRoute()); }, @@ -61,7 +62,7 @@ class ChatListScreen extends HookConsumerWidget { ? CircleAvatar( child: Text(item.name[0].toUpperCase()), ) - : ProfilePictureWidget(item: item.picture), + : ProfilePictureWidget(fileId: item.pictureId), title: Text(item.name), subtitle: Text(item.description), onTap: () { @@ -225,7 +226,7 @@ class EditChatScreen extends HookConsumerWidget { bottom: -32, child: GestureDetector( child: ProfilePictureWidget( - item: picture.value, + fileId: picture.value?.id, radius: 40, fallbackIcon: Symbols.group, ), diff --git a/lib/screens/chat/room.dart b/lib/screens/chat/room.dart index 11ce5c0..f95c5d3 100644 --- a/lib/screens/chat/room.dart +++ b/lib/screens/chat/room.dart @@ -1,4 +1,5 @@ import 'package:auto_route/annotations.dart'; +import 'package:collection/collection.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -12,11 +13,12 @@ import 'package:island/widgets/alert.dart'; import 'package:island/widgets/content/cloud_files.dart'; import 'package:material_symbols_icons/material_symbols_icons.dart'; import 'package:styled_widget/styled_widget.dart'; +import 'package:uuid/uuid.dart'; import 'chat.dart'; final messageRepositoryProvider = FutureProvider.family( (ref, roomId) async { - final room = ref.watch(chatroomProvider(roomId)).value; + final room = await ref.watch(chatroomProvider(roomId).future); final apiClient = ref.watch(apiClientProvider); final database = ref.watch(databaseProvider); return MessageRepository(room!, apiClient, database); @@ -90,11 +92,33 @@ class MessagesNotifier final repository = await _ref.read( messageRepositoryProvider(_roomId).future, ); - final message = await repository.sendMessage(_roomId, content); - // Add the new message to the list - final currentMessages = state.value ?? []; - state = AsyncValue.data([message, ...currentMessages]); + final nonce = const Uuid().v4(); + + final messageTask = repository.sendMessage(_roomId, content, nonce); + final pendingMessage = repository.pendingMessages.values.firstWhereOrNull( + (m) => m.roomId == _roomId && m.nonce == nonce, + ); + if (pendingMessage != null) { + final currentMessages = state.value ?? []; + state = AsyncValue.data([pendingMessage, ...currentMessages]); + } + + final message = await messageTask; + + final updatedMessages = state.value ?? []; + if (pendingMessage != null) { + final index = updatedMessages.indexWhere( + (m) => m.id == pendingMessage.id, + ); + if (index >= 0) { + final newList = [...updatedMessages]; + newList[index] = message; + state = AsyncValue.data(newList); + } + } else { + state = AsyncValue.data([message, ...updatedMessages]); + } } catch (err) { showErrorAlert(err); } @@ -163,7 +187,7 @@ class ChatRoomScreen extends HookConsumerWidget { child: room?.picture != null ? ProfilePictureWidget( - item: room?.picture, + fileId: room?.pictureId, fallbackIcon: Symbols.chat, ) : CircleAvatar( @@ -293,9 +317,10 @@ class MessageBubble extends StatelessWidget { isCurrentUser ? MainAxisAlignment.end : MainAxisAlignment.start, children: [ if (!isCurrentUser) - CircleAvatar( + ProfilePictureWidget( + fileId: + message.toRemoteMessage().sender.account.profile.pictureId, radius: 16, - child: Text(message.senderId[0].toUpperCase()), ), const Gap(8), Flexible( @@ -322,7 +347,7 @@ class MessageBubble extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - DateFormat.Hm().format(message.createdAt), + DateFormat.Hm().format(message.createdAt.toLocal()), style: TextStyle( fontSize: 10, color: diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index b7bae45..f178aa6 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -21,6 +21,7 @@ class ExploreScreen extends ConsumerWidget { return AppScaffold( appBar: AppBar(title: const Text('Explore')), floatingActionButton: FloatingActionButton( + key: Key("explore-page-fab"), onPressed: () { context.router.push(PostComposeRoute()).then((value) { if (value != null) { diff --git a/lib/screens/posts/compose.dart b/lib/screens/posts/compose.dart index bfc44cf..3441383 100644 --- a/lib/screens/posts/compose.dart +++ b/lib/screens/posts/compose.dart @@ -254,7 +254,7 @@ class PostComposeScreen extends HookConsumerWidget { children: [ GestureDetector( child: ProfilePictureWidget( - item: currentPublisher.value?.picture, + fileId: currentPublisher.value?.pictureId, radius: 24, ), onTap: () { diff --git a/lib/screens/realm/realms.dart b/lib/screens/realm/realms.dart index 5b22dc1..75dad21 100644 --- a/lib/screens/realm/realms.dart +++ b/lib/screens/realm/realms.dart @@ -39,6 +39,7 @@ class RealmListScreen extends HookConsumerWidget { return AppScaffold( appBar: AppBar(title: const Text('realms').tr()), floatingActionButton: FloatingActionButton( + key: Key("realms-page-fab"), child: const Icon(Symbols.add), onPressed: () { context.router.push(NewRealmRoute()); @@ -58,7 +59,7 @@ class RealmListScreen extends HookConsumerWidget { itemBuilder: (context, item) { return ListTile( leading: ProfilePictureWidget( - item: value[item].picture, + fileId: value[item].pictureId, fallbackIcon: Symbols.group, ), title: Text(value[item].name), @@ -98,7 +99,9 @@ class RealmListScreen extends HookConsumerWidget { ) .then((value) { if (value != null) { - ref.invalidate(realmsJoinedProvider); + ref.refresh( + realmsJoinedProvider.future, + ); } }); }, @@ -280,7 +283,7 @@ class EditRealmScreen extends HookConsumerWidget { bottom: -32, child: GestureDetector( child: ProfilePictureWidget( - item: picture.value, + fileId: picture.value?.id, radius: 40, fallbackIcon: Symbols.group, ), diff --git a/lib/widgets/content/cloud_files.dart b/lib/widgets/content/cloud_files.dart index d382091..b0e0a81 100644 --- a/lib/widgets/content/cloud_files.dart +++ b/lib/widgets/content/cloud_files.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:island/models/file.dart'; @@ -42,18 +43,21 @@ class CloudFileWidget extends ConsumerWidget { } class ProfilePictureWidget extends ConsumerWidget { - final SnCloudFile? item; + final String? fileId; final double radius; final IconData? fallbackIcon; const ProfilePictureWidget({ super.key, - required this.item, + required this.fileId, this.radius = 20, this.fallbackIcon, }); @override Widget build(BuildContext context, WidgetRef ref) { + final serverUrl = ref.watch(serverUrlProvider); + final uri = '$serverUrl/files/$fileId'; + return ClipRRect( borderRadius: BorderRadius.all(Radius.circular(radius)), child: Container( @@ -61,12 +65,12 @@ class ProfilePictureWidget extends ConsumerWidget { height: radius * 2, color: Theme.of(context).colorScheme.primaryContainer, child: - item == null + fileId == null ? Icon( fallbackIcon ?? Symbols.account_circle, size: radius, ).center() - : CloudFileWidget(item: item!), + : CachedNetworkImage(imageUrl: uri, fit: BoxFit.cover), ), ); } diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 93db2fa..517714c 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -105,7 +105,7 @@ class PostItem extends HookConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, spacing: 12, children: [ - ProfilePictureWidget(item: item.publisher.picture), + ProfilePictureWidget(fileId: item.publisher.pictureId), Expanded( child: GestureDetector( child: Column( diff --git a/lib/widgets/post/post_quick_reply.dart b/lib/widgets/post/post_quick_reply.dart index d7f6771..9b473d4 100644 --- a/lib/widgets/post/post_quick_reply.dart +++ b/lib/widgets/post/post_quick_reply.dart @@ -66,7 +66,7 @@ class PostQuickReply extends HookConsumerWidget { children: [ GestureDetector( child: ProfilePictureWidget( - item: currentPublisher.value?.picture, + fileId: currentPublisher.value?.pictureId, radius: 16, ), onTap: () { diff --git a/lib/widgets/post/publishers_modal.dart b/lib/widgets/post/publishers_modal.dart index dfe2619..11ad7ae 100644 --- a/lib/widgets/post/publishers_modal.dart +++ b/lib/widgets/post/publishers_modal.dart @@ -68,7 +68,7 @@ class PublisherModal extends HookConsumerWidget { for (final publisher in value) ListTile( leading: ProfilePictureWidget( - item: publisher.picture, + fileId: publisher.picture?.id, ), title: Text(publisher.nick), subtitle: Text('@${publisher.name}'), diff --git a/pubspec.lock b/pubspec.lock index 9649f8a..5bd3629 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -282,7 +282,7 @@ packages: source: hosted version: "4.10.1" collection: - dependency: transitive + dependency: "direct main" description: name: collection sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" diff --git a/pubspec.yaml b/pubspec.yaml index 257fcbf..0afe0b7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -88,6 +88,7 @@ dependencies: drift: ^2.26.0 drift_flutter: ^0.2.4 path: ^1.9.1 + collection: ^1.19.1 dev_dependencies: flutter_test: