From c3a3be0807b29d9f5c3e0cd1e18c3ebd62f94986 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 30 Nov 2025 21:57:35 +0800 Subject: [PATCH] :alien: Update message db to support server changes --- lib/database/drift_db.dart | 22 +- lib/database/drift_db.g.dart | 338 +++++----------------- lib/database/message.dart | 5 +- lib/models/chat.dart | 3 +- lib/models/chat.freezed.dart | 89 +++--- lib/models/chat.g.dart | 6 +- lib/pods/chat/chat_summary.g.dart | 2 +- lib/screens/chat/chat.dart | 21 +- lib/screens/chat/chat.g.dart | 2 +- lib/screens/chat/room_detail.dart | 169 +---------- lib/screens/notification.g.dart | 2 +- lib/widgets/chat/message_sender_info.dart | 22 +- 12 files changed, 148 insertions(+), 533 deletions(-) diff --git a/lib/database/drift_db.dart b/lib/database/drift_db.dart index 20a29bd7..7c030137 100644 --- a/lib/database/drift_db.dart +++ b/lib/database/drift_db.dart @@ -14,7 +14,7 @@ class AppDatabase extends _$AppDatabase { AppDatabase(super.e); @override - int get schemaVersion => 8; + int get schemaVersion => 9; @override MigrationStrategy get migration => MigrationStrategy( @@ -62,6 +62,15 @@ class AppDatabase extends _$AppDatabase { await m.createTable(chatRooms); await m.createTable(chatMembers); } + if (from < 9) { + // Remove unused columns from chat_members + await customStatement('ALTER TABLE chat_members DROP COLUMN role'); + await customStatement('ALTER TABLE chat_members DROP COLUMN is_bot'); + await customStatement('ALTER TABLE chat_members DROP COLUMN status'); + await customStatement( + 'ALTER TABLE chat_members DROP COLUMN last_typed', + ); + } }, ); @@ -237,14 +246,11 @@ class AppDatabase extends _$AppDatabase { accountId: senderRow.accountId, account: senderAccount, nick: senderRow.nick, - role: senderRow.role, notify: senderRow.notify, joinedAt: senderRow.joinedAt, breakUntil: senderRow.breakUntil, timeoutUntil: senderRow.timeoutUntil, - isBot: senderRow.isBot, status: null, - lastTyped: senderRow.lastTyped, createdAt: senderRow.createdAt, updatedAt: senderRow.updatedAt, deletedAt: senderRow.deletedAt, @@ -281,12 +287,10 @@ class AppDatabase extends _$AppDatabase { updatedAt: DateTime.now(), ), nick: dbMessage.senderId, // Show the senderId as fallback - role: 0, notify: 0, joinedAt: null, breakUntil: null, timeoutUntil: null, - isBot: false, status: null, lastTyped: null, createdAt: DateTime.now(), @@ -343,16 +347,10 @@ class AppDatabase extends _$AppDatabase { accountId: Value(member.accountId), account: Value(member.account.toJson()), nick: Value(member.nick), - role: Value(member.role), notify: Value(member.notify), joinedAt: Value(member.joinedAt), breakUntil: Value(member.breakUntil), timeoutUntil: Value(member.timeoutUntil), - isBot: Value(member.isBot), - status: Value( - member.status == null ? null : jsonEncode(member.status!.toJson()), - ), - lastTyped: Value(member.lastTyped), createdAt: Value(member.createdAt), updatedAt: Value(member.updatedAt), deletedAt: Value(member.deletedAt), diff --git a/lib/database/drift_db.g.dart b/lib/database/drift_db.g.dart index 1e7b60ff..0941217c 100644 --- a/lib/database/drift_db.g.dart +++ b/lib/database/drift_db.g.dart @@ -106,6 +106,17 @@ class $ChatRoomsTable extends ChatRooms type: DriftSqlType.string, requiredDuringInsert: false, ); + static const VerificationMeta _accountIdMeta = const VerificationMeta( + 'accountId', + ); + @override + late final GeneratedColumn accountId = GeneratedColumn( + 'account_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', ); @@ -150,6 +161,7 @@ class $ChatRoomsTable extends ChatRooms picture, background, realmId, + accountId, createdAt, updatedAt, deletedAt, @@ -215,6 +227,12 @@ class $ChatRoomsTable extends ChatRooms realmId.isAcceptableOrUnknown(data['realm_id']!, _realmIdMeta), ); } + if (data.containsKey('account_id')) { + context.handle( + _accountIdMeta, + accountId.isAcceptableOrUnknown(data['account_id']!, _accountIdMeta), + ); + } if (data.containsKey('created_at')) { context.handle( _createdAtMeta, @@ -288,6 +306,10 @@ class $ChatRoomsTable extends ChatRooms DriftSqlType.string, data['${effectivePrefix}realm_id'], ), + accountId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}account_id'], + ), createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, @@ -330,6 +352,7 @@ class ChatRoom extends DataClass implements Insertable { final Map? picture; final Map? background; final String? realmId; + final String? accountId; final DateTime createdAt; final DateTime updatedAt; final DateTime? deletedAt; @@ -343,6 +366,7 @@ class ChatRoom extends DataClass implements Insertable { this.picture, this.background, this.realmId, + this.accountId, required this.createdAt, required this.updatedAt, this.deletedAt, @@ -377,6 +401,9 @@ class ChatRoom extends DataClass implements Insertable { if (!nullToAbsent || realmId != null) { map['realm_id'] = Variable(realmId); } + if (!nullToAbsent || accountId != null) { + map['account_id'] = Variable(accountId); + } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || deletedAt != null) { @@ -414,6 +441,10 @@ class ChatRoom extends DataClass implements Insertable { realmId == null && nullToAbsent ? const Value.absent() : Value(realmId), + accountId: + accountId == null && nullToAbsent + ? const Value.absent() + : Value(accountId), createdAt: Value(createdAt), updatedAt: Value(updatedAt), deletedAt: @@ -440,6 +471,7 @@ class ChatRoom extends DataClass implements Insertable { json['background'], ), realmId: serializer.fromJson(json['realmId']), + accountId: serializer.fromJson(json['accountId']), createdAt: serializer.fromJson(json['createdAt']), updatedAt: serializer.fromJson(json['updatedAt']), deletedAt: serializer.fromJson(json['deletedAt']), @@ -458,6 +490,7 @@ class ChatRoom extends DataClass implements Insertable { 'picture': serializer.toJson?>(picture), 'background': serializer.toJson?>(background), 'realmId': serializer.toJson(realmId), + 'accountId': serializer.toJson(accountId), 'createdAt': serializer.toJson(createdAt), 'updatedAt': serializer.toJson(updatedAt), 'deletedAt': serializer.toJson(deletedAt), @@ -474,6 +507,7 @@ class ChatRoom extends DataClass implements Insertable { Value?> picture = const Value.absent(), Value?> background = const Value.absent(), Value realmId = const Value.absent(), + Value accountId = const Value.absent(), DateTime? createdAt, DateTime? updatedAt, Value deletedAt = const Value.absent(), @@ -487,6 +521,7 @@ class ChatRoom extends DataClass implements Insertable { picture: picture.present ? picture.value : this.picture, background: background.present ? background.value : this.background, realmId: realmId.present ? realmId.value : this.realmId, + accountId: accountId.present ? accountId.value : this.accountId, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, @@ -505,6 +540,7 @@ class ChatRoom extends DataClass implements Insertable { background: data.background.present ? data.background.value : this.background, realmId: data.realmId.present ? data.realmId.value : this.realmId, + accountId: data.accountId.present ? data.accountId.value : this.accountId, createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, @@ -523,6 +559,7 @@ class ChatRoom extends DataClass implements Insertable { ..write('picture: $picture, ') ..write('background: $background, ') ..write('realmId: $realmId, ') + ..write('accountId: $accountId, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') ..write('deletedAt: $deletedAt') @@ -541,6 +578,7 @@ class ChatRoom extends DataClass implements Insertable { picture, background, realmId, + accountId, createdAt, updatedAt, deletedAt, @@ -558,6 +596,7 @@ class ChatRoom extends DataClass implements Insertable { other.picture == this.picture && other.background == this.background && other.realmId == this.realmId && + other.accountId == this.accountId && other.createdAt == this.createdAt && other.updatedAt == this.updatedAt && other.deletedAt == this.deletedAt); @@ -573,6 +612,7 @@ class ChatRoomsCompanion extends UpdateCompanion { final Value?> picture; final Value?> background; final Value realmId; + final Value accountId; final Value createdAt; final Value updatedAt; final Value deletedAt; @@ -587,6 +627,7 @@ class ChatRoomsCompanion extends UpdateCompanion { this.picture = const Value.absent(), this.background = const Value.absent(), this.realmId = const Value.absent(), + this.accountId = const Value.absent(), this.createdAt = const Value.absent(), this.updatedAt = const Value.absent(), this.deletedAt = const Value.absent(), @@ -602,6 +643,7 @@ class ChatRoomsCompanion extends UpdateCompanion { this.picture = const Value.absent(), this.background = const Value.absent(), this.realmId = const Value.absent(), + this.accountId = const Value.absent(), required DateTime createdAt, required DateTime updatedAt, this.deletedAt = const Value.absent(), @@ -620,6 +662,7 @@ class ChatRoomsCompanion extends UpdateCompanion { Expression? picture, Expression? background, Expression? realmId, + Expression? accountId, Expression? createdAt, Expression? updatedAt, Expression? deletedAt, @@ -635,6 +678,7 @@ class ChatRoomsCompanion extends UpdateCompanion { if (picture != null) 'picture': picture, if (background != null) 'background': background, if (realmId != null) 'realm_id': realmId, + if (accountId != null) 'account_id': accountId, if (createdAt != null) 'created_at': createdAt, if (updatedAt != null) 'updated_at': updatedAt, if (deletedAt != null) 'deleted_at': deletedAt, @@ -652,6 +696,7 @@ class ChatRoomsCompanion extends UpdateCompanion { Value?>? picture, Value?>? background, Value? realmId, + Value? accountId, Value? createdAt, Value? updatedAt, Value? deletedAt, @@ -667,6 +712,7 @@ class ChatRoomsCompanion extends UpdateCompanion { picture: picture ?? this.picture, background: background ?? this.background, realmId: realmId ?? this.realmId, + accountId: accountId ?? this.accountId, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, deletedAt: deletedAt ?? this.deletedAt, @@ -708,6 +754,9 @@ class ChatRoomsCompanion extends UpdateCompanion { if (realmId.present) { map['realm_id'] = Variable(realmId.value); } + if (accountId.present) { + map['account_id'] = Variable(accountId.value); + } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); } @@ -735,6 +784,7 @@ class ChatRoomsCompanion extends UpdateCompanion { ..write('picture: $picture, ') ..write('background: $background, ') ..write('realmId: $realmId, ') + ..write('accountId: $accountId, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') ..write('deletedAt: $deletedAt, ') @@ -802,15 +852,6 @@ class $ChatMembersTable extends ChatMembers type: DriftSqlType.string, requiredDuringInsert: false, ); - static const VerificationMeta _roleMeta = const VerificationMeta('role'); - @override - late final GeneratedColumn role = GeneratedColumn( - 'role', - aliasedName, - false, - type: DriftSqlType.int, - requiredDuringInsert: true, - ); static const VerificationMeta _notifyMeta = const VerificationMeta('notify'); @override late final GeneratedColumn notify = GeneratedColumn( @@ -853,38 +894,6 @@ class $ChatMembersTable extends ChatMembers type: DriftSqlType.dateTime, requiredDuringInsert: false, ); - static const VerificationMeta _isBotMeta = const VerificationMeta('isBot'); - @override - late final GeneratedColumn isBot = GeneratedColumn( - 'is_bot', - aliasedName, - false, - type: DriftSqlType.bool, - requiredDuringInsert: true, - defaultConstraints: GeneratedColumn.constraintIsAlways( - 'CHECK ("is_bot" IN (0, 1))', - ), - ); - static const VerificationMeta _statusMeta = const VerificationMeta('status'); - @override - late final GeneratedColumn status = GeneratedColumn( - 'status', - aliasedName, - true, - type: DriftSqlType.string, - requiredDuringInsert: false, - ); - static const VerificationMeta _lastTypedMeta = const VerificationMeta( - 'lastTyped', - ); - @override - late final GeneratedColumn lastTyped = GeneratedColumn( - 'last_typed', - aliasedName, - true, - type: DriftSqlType.dateTime, - requiredDuringInsert: false, - ); static const VerificationMeta _createdAtMeta = const VerificationMeta( 'createdAt', ); @@ -925,14 +934,10 @@ class $ChatMembersTable extends ChatMembers accountId, account, nick, - role, notify, joinedAt, breakUntil, timeoutUntil, - isBot, - status, - lastTyped, createdAt, updatedAt, deletedAt, @@ -979,14 +984,6 @@ class $ChatMembersTable extends ChatMembers nick.isAcceptableOrUnknown(data['nick']!, _nickMeta), ); } - if (data.containsKey('role')) { - context.handle( - _roleMeta, - role.isAcceptableOrUnknown(data['role']!, _roleMeta), - ); - } else if (isInserting) { - context.missing(_roleMeta); - } if (data.containsKey('notify')) { context.handle( _notifyMeta, @@ -1016,26 +1013,6 @@ class $ChatMembersTable extends ChatMembers ), ); } - if (data.containsKey('is_bot')) { - context.handle( - _isBotMeta, - isBot.isAcceptableOrUnknown(data['is_bot']!, _isBotMeta), - ); - } else if (isInserting) { - context.missing(_isBotMeta); - } - if (data.containsKey('status')) { - context.handle( - _statusMeta, - status.isAcceptableOrUnknown(data['status']!, _statusMeta), - ); - } - if (data.containsKey('last_typed')) { - context.handle( - _lastTypedMeta, - lastTyped.isAcceptableOrUnknown(data['last_typed']!, _lastTypedMeta), - ); - } if (data.containsKey('created_at')) { context.handle( _createdAtMeta, @@ -1092,11 +1069,6 @@ class $ChatMembersTable extends ChatMembers DriftSqlType.string, data['${effectivePrefix}nick'], ), - role: - attachedDatabase.typeMapping.read( - DriftSqlType.int, - data['${effectivePrefix}role'], - )!, notify: attachedDatabase.typeMapping.read( DriftSqlType.int, @@ -1114,19 +1086,6 @@ class $ChatMembersTable extends ChatMembers DriftSqlType.dateTime, data['${effectivePrefix}timeout_until'], ), - isBot: - attachedDatabase.typeMapping.read( - DriftSqlType.bool, - data['${effectivePrefix}is_bot'], - )!, - status: attachedDatabase.typeMapping.read( - DriftSqlType.string, - data['${effectivePrefix}status'], - ), - lastTyped: attachedDatabase.typeMapping.read( - DriftSqlType.dateTime, - data['${effectivePrefix}last_typed'], - ), createdAt: attachedDatabase.typeMapping.read( DriftSqlType.dateTime, @@ -1159,14 +1118,10 @@ class ChatMember extends DataClass implements Insertable { final String accountId; final Map account; final String? nick; - final int role; final int notify; final DateTime? joinedAt; final DateTime? breakUntil; final DateTime? timeoutUntil; - final bool isBot; - final String? status; - final DateTime? lastTyped; final DateTime createdAt; final DateTime updatedAt; final DateTime? deletedAt; @@ -1176,14 +1131,10 @@ class ChatMember extends DataClass implements Insertable { required this.accountId, required this.account, this.nick, - required this.role, required this.notify, this.joinedAt, this.breakUntil, this.timeoutUntil, - required this.isBot, - this.status, - this.lastTyped, required this.createdAt, required this.updatedAt, this.deletedAt, @@ -1202,7 +1153,6 @@ class ChatMember extends DataClass implements Insertable { if (!nullToAbsent || nick != null) { map['nick'] = Variable(nick); } - map['role'] = Variable(role); map['notify'] = Variable(notify); if (!nullToAbsent || joinedAt != null) { map['joined_at'] = Variable(joinedAt); @@ -1213,13 +1163,6 @@ class ChatMember extends DataClass implements Insertable { if (!nullToAbsent || timeoutUntil != null) { map['timeout_until'] = Variable(timeoutUntil); } - map['is_bot'] = Variable(isBot); - if (!nullToAbsent || status != null) { - map['status'] = Variable(status); - } - if (!nullToAbsent || lastTyped != null) { - map['last_typed'] = Variable(lastTyped); - } map['created_at'] = Variable(createdAt); map['updated_at'] = Variable(updatedAt); if (!nullToAbsent || deletedAt != null) { @@ -1235,7 +1178,6 @@ class ChatMember extends DataClass implements Insertable { accountId: Value(accountId), account: Value(account), nick: nick == null && nullToAbsent ? const Value.absent() : Value(nick), - role: Value(role), notify: Value(notify), joinedAt: joinedAt == null && nullToAbsent @@ -1249,13 +1191,6 @@ class ChatMember extends DataClass implements Insertable { timeoutUntil == null && nullToAbsent ? const Value.absent() : Value(timeoutUntil), - isBot: Value(isBot), - status: - status == null && nullToAbsent ? const Value.absent() : Value(status), - lastTyped: - lastTyped == null && nullToAbsent - ? const Value.absent() - : Value(lastTyped), createdAt: Value(createdAt), updatedAt: Value(updatedAt), deletedAt: @@ -1276,14 +1211,10 @@ class ChatMember extends DataClass implements Insertable { accountId: serializer.fromJson(json['accountId']), account: serializer.fromJson>(json['account']), nick: serializer.fromJson(json['nick']), - role: serializer.fromJson(json['role']), notify: serializer.fromJson(json['notify']), joinedAt: serializer.fromJson(json['joinedAt']), breakUntil: serializer.fromJson(json['breakUntil']), timeoutUntil: serializer.fromJson(json['timeoutUntil']), - isBot: serializer.fromJson(json['isBot']), - status: serializer.fromJson(json['status']), - lastTyped: serializer.fromJson(json['lastTyped']), createdAt: serializer.fromJson(json['createdAt']), updatedAt: serializer.fromJson(json['updatedAt']), deletedAt: serializer.fromJson(json['deletedAt']), @@ -1298,14 +1229,10 @@ class ChatMember extends DataClass implements Insertable { 'accountId': serializer.toJson(accountId), 'account': serializer.toJson>(account), 'nick': serializer.toJson(nick), - 'role': serializer.toJson(role), 'notify': serializer.toJson(notify), 'joinedAt': serializer.toJson(joinedAt), 'breakUntil': serializer.toJson(breakUntil), 'timeoutUntil': serializer.toJson(timeoutUntil), - 'isBot': serializer.toJson(isBot), - 'status': serializer.toJson(status), - 'lastTyped': serializer.toJson(lastTyped), 'createdAt': serializer.toJson(createdAt), 'updatedAt': serializer.toJson(updatedAt), 'deletedAt': serializer.toJson(deletedAt), @@ -1318,14 +1245,10 @@ class ChatMember extends DataClass implements Insertable { String? accountId, Map? account, Value nick = const Value.absent(), - int? role, int? notify, Value joinedAt = const Value.absent(), Value breakUntil = const Value.absent(), Value timeoutUntil = const Value.absent(), - bool? isBot, - Value status = const Value.absent(), - Value lastTyped = const Value.absent(), DateTime? createdAt, DateTime? updatedAt, Value deletedAt = const Value.absent(), @@ -1335,14 +1258,10 @@ class ChatMember extends DataClass implements Insertable { accountId: accountId ?? this.accountId, account: account ?? this.account, nick: nick.present ? nick.value : this.nick, - role: role ?? this.role, notify: notify ?? this.notify, joinedAt: joinedAt.present ? joinedAt.value : this.joinedAt, breakUntil: breakUntil.present ? breakUntil.value : this.breakUntil, timeoutUntil: timeoutUntil.present ? timeoutUntil.value : this.timeoutUntil, - isBot: isBot ?? this.isBot, - status: status.present ? status.value : this.status, - lastTyped: lastTyped.present ? lastTyped.value : this.lastTyped, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt, @@ -1355,7 +1274,6 @@ class ChatMember extends DataClass implements Insertable { accountId: data.accountId.present ? data.accountId.value : this.accountId, account: data.account.present ? data.account.value : this.account, nick: data.nick.present ? data.nick.value : this.nick, - role: data.role.present ? data.role.value : this.role, notify: data.notify.present ? data.notify.value : this.notify, joinedAt: data.joinedAt.present ? data.joinedAt.value : this.joinedAt, breakUntil: @@ -1364,9 +1282,6 @@ class ChatMember extends DataClass implements Insertable { data.timeoutUntil.present ? data.timeoutUntil.value : this.timeoutUntil, - isBot: data.isBot.present ? data.isBot.value : this.isBot, - status: data.status.present ? data.status.value : this.status, - lastTyped: data.lastTyped.present ? data.lastTyped.value : this.lastTyped, createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt, @@ -1381,14 +1296,10 @@ class ChatMember extends DataClass implements Insertable { ..write('accountId: $accountId, ') ..write('account: $account, ') ..write('nick: $nick, ') - ..write('role: $role, ') ..write('notify: $notify, ') ..write('joinedAt: $joinedAt, ') ..write('breakUntil: $breakUntil, ') ..write('timeoutUntil: $timeoutUntil, ') - ..write('isBot: $isBot, ') - ..write('status: $status, ') - ..write('lastTyped: $lastTyped, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') ..write('deletedAt: $deletedAt') @@ -1403,14 +1314,10 @@ class ChatMember extends DataClass implements Insertable { accountId, account, nick, - role, notify, joinedAt, breakUntil, timeoutUntil, - isBot, - status, - lastTyped, createdAt, updatedAt, deletedAt, @@ -1424,14 +1331,10 @@ class ChatMember extends DataClass implements Insertable { other.accountId == this.accountId && other.account == this.account && other.nick == this.nick && - other.role == this.role && other.notify == this.notify && other.joinedAt == this.joinedAt && other.breakUntil == this.breakUntil && other.timeoutUntil == this.timeoutUntil && - other.isBot == this.isBot && - other.status == this.status && - other.lastTyped == this.lastTyped && other.createdAt == this.createdAt && other.updatedAt == this.updatedAt && other.deletedAt == this.deletedAt); @@ -1443,14 +1346,10 @@ class ChatMembersCompanion extends UpdateCompanion { final Value accountId; final Value> account; final Value nick; - final Value role; final Value notify; final Value joinedAt; final Value breakUntil; final Value timeoutUntil; - final Value isBot; - final Value status; - final Value lastTyped; final Value createdAt; final Value updatedAt; final Value deletedAt; @@ -1461,14 +1360,10 @@ class ChatMembersCompanion extends UpdateCompanion { this.accountId = const Value.absent(), this.account = const Value.absent(), this.nick = const Value.absent(), - this.role = const Value.absent(), this.notify = const Value.absent(), this.joinedAt = const Value.absent(), this.breakUntil = const Value.absent(), this.timeoutUntil = const Value.absent(), - this.isBot = const Value.absent(), - this.status = const Value.absent(), - this.lastTyped = const Value.absent(), this.createdAt = const Value.absent(), this.updatedAt = const Value.absent(), this.deletedAt = const Value.absent(), @@ -1480,14 +1375,10 @@ class ChatMembersCompanion extends UpdateCompanion { required String accountId, required Map account, this.nick = const Value.absent(), - required int role, required int notify, this.joinedAt = const Value.absent(), this.breakUntil = const Value.absent(), this.timeoutUntil = const Value.absent(), - required bool isBot, - this.status = const Value.absent(), - this.lastTyped = const Value.absent(), required DateTime createdAt, required DateTime updatedAt, this.deletedAt = const Value.absent(), @@ -1496,9 +1387,7 @@ class ChatMembersCompanion extends UpdateCompanion { chatRoomId = Value(chatRoomId), accountId = Value(accountId), account = Value(account), - role = Value(role), notify = Value(notify), - isBot = Value(isBot), createdAt = Value(createdAt), updatedAt = Value(updatedAt); static Insertable custom({ @@ -1507,14 +1396,10 @@ class ChatMembersCompanion extends UpdateCompanion { Expression? accountId, Expression? account, Expression? nick, - Expression? role, Expression? notify, Expression? joinedAt, Expression? breakUntil, Expression? timeoutUntil, - Expression? isBot, - Expression? status, - Expression? lastTyped, Expression? createdAt, Expression? updatedAt, Expression? deletedAt, @@ -1526,14 +1411,10 @@ class ChatMembersCompanion extends UpdateCompanion { if (accountId != null) 'account_id': accountId, if (account != null) 'account': account, if (nick != null) 'nick': nick, - if (role != null) 'role': role, if (notify != null) 'notify': notify, if (joinedAt != null) 'joined_at': joinedAt, if (breakUntil != null) 'break_until': breakUntil, if (timeoutUntil != null) 'timeout_until': timeoutUntil, - if (isBot != null) 'is_bot': isBot, - if (status != null) 'status': status, - if (lastTyped != null) 'last_typed': lastTyped, if (createdAt != null) 'created_at': createdAt, if (updatedAt != null) 'updated_at': updatedAt, if (deletedAt != null) 'deleted_at': deletedAt, @@ -1547,14 +1428,10 @@ class ChatMembersCompanion extends UpdateCompanion { Value? accountId, Value>? account, Value? nick, - Value? role, Value? notify, Value? joinedAt, Value? breakUntil, Value? timeoutUntil, - Value? isBot, - Value? status, - Value? lastTyped, Value? createdAt, Value? updatedAt, Value? deletedAt, @@ -1566,14 +1443,10 @@ class ChatMembersCompanion extends UpdateCompanion { accountId: accountId ?? this.accountId, account: account ?? this.account, nick: nick ?? this.nick, - role: role ?? this.role, notify: notify ?? this.notify, joinedAt: joinedAt ?? this.joinedAt, breakUntil: breakUntil ?? this.breakUntil, timeoutUntil: timeoutUntil ?? this.timeoutUntil, - isBot: isBot ?? this.isBot, - status: status ?? this.status, - lastTyped: lastTyped ?? this.lastTyped, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, deletedAt: deletedAt ?? this.deletedAt, @@ -1601,9 +1474,6 @@ class ChatMembersCompanion extends UpdateCompanion { if (nick.present) { map['nick'] = Variable(nick.value); } - if (role.present) { - map['role'] = Variable(role.value); - } if (notify.present) { map['notify'] = Variable(notify.value); } @@ -1616,15 +1486,6 @@ class ChatMembersCompanion extends UpdateCompanion { if (timeoutUntil.present) { map['timeout_until'] = Variable(timeoutUntil.value); } - if (isBot.present) { - map['is_bot'] = Variable(isBot.value); - } - if (status.present) { - map['status'] = Variable(status.value); - } - if (lastTyped.present) { - map['last_typed'] = Variable(lastTyped.value); - } if (createdAt.present) { map['created_at'] = Variable(createdAt.value); } @@ -1648,14 +1509,10 @@ class ChatMembersCompanion extends UpdateCompanion { ..write('accountId: $accountId, ') ..write('account: $account, ') ..write('nick: $nick, ') - ..write('role: $role, ') ..write('notify: $notify, ') ..write('joinedAt: $joinedAt, ') ..write('breakUntil: $breakUntil, ') ..write('timeoutUntil: $timeoutUntil, ') - ..write('isBot: $isBot, ') - ..write('status: $status, ') - ..write('lastTyped: $lastTyped, ') ..write('createdAt: $createdAt, ') ..write('updatedAt: $updatedAt, ') ..write('deletedAt: $deletedAt, ') @@ -3327,6 +3184,7 @@ typedef $$ChatRoomsTableCreateCompanionBuilder = Value?> picture, Value?> background, Value realmId, + Value accountId, required DateTime createdAt, required DateTime updatedAt, Value deletedAt, @@ -3343,6 +3201,7 @@ typedef $$ChatRoomsTableUpdateCompanionBuilder = Value?> picture, Value?> background, Value realmId, + Value accountId, Value createdAt, Value updatedAt, Value deletedAt, @@ -3454,6 +3313,11 @@ class $$ChatRoomsTableFilterComposer builder: (column) => ColumnFilters(column), ); + ColumnFilters get accountId => $composableBuilder( + column: $table.accountId, + builder: (column) => ColumnFilters(column), + ); + ColumnFilters get createdAt => $composableBuilder( column: $table.createdAt, builder: (column) => ColumnFilters(column), @@ -3574,6 +3438,11 @@ class $$ChatRoomsTableOrderingComposer builder: (column) => ColumnOrderings(column), ); + ColumnOrderings get accountId => $composableBuilder( + column: $table.accountId, + builder: (column) => ColumnOrderings(column), + ); + ColumnOrderings get createdAt => $composableBuilder( column: $table.createdAt, builder: (column) => ColumnOrderings(column), @@ -3633,6 +3502,9 @@ class $$ChatRoomsTableAnnotationComposer GeneratedColumn get realmId => $composableBuilder(column: $table.realmId, builder: (column) => column); + GeneratedColumn get accountId => + $composableBuilder(column: $table.accountId, builder: (column) => column); + GeneratedColumn get createdAt => $composableBuilder(column: $table.createdAt, builder: (column) => column); @@ -3730,6 +3602,7 @@ class $$ChatRoomsTableTableManager Value?> picture = const Value.absent(), Value?> background = const Value.absent(), Value realmId = const Value.absent(), + Value accountId = const Value.absent(), Value createdAt = const Value.absent(), Value updatedAt = const Value.absent(), Value deletedAt = const Value.absent(), @@ -3744,6 +3617,7 @@ class $$ChatRoomsTableTableManager picture: picture, background: background, realmId: realmId, + accountId: accountId, createdAt: createdAt, updatedAt: updatedAt, deletedAt: deletedAt, @@ -3760,6 +3634,7 @@ class $$ChatRoomsTableTableManager Value?> picture = const Value.absent(), Value?> background = const Value.absent(), Value realmId = const Value.absent(), + Value accountId = const Value.absent(), required DateTime createdAt, required DateTime updatedAt, Value deletedAt = const Value.absent(), @@ -3774,6 +3649,7 @@ class $$ChatRoomsTableTableManager picture: picture, background: background, realmId: realmId, + accountId: accountId, createdAt: createdAt, updatedAt: updatedAt, deletedAt: deletedAt, @@ -3874,14 +3750,10 @@ typedef $$ChatMembersTableCreateCompanionBuilder = required String accountId, required Map account, Value nick, - required int role, required int notify, Value joinedAt, Value breakUntil, Value timeoutUntil, - required bool isBot, - Value status, - Value lastTyped, required DateTime createdAt, required DateTime updatedAt, Value deletedAt, @@ -3894,14 +3766,10 @@ typedef $$ChatMembersTableUpdateCompanionBuilder = Value accountId, Value> account, Value nick, - Value role, Value notify, Value joinedAt, Value breakUntil, Value timeoutUntil, - Value isBot, - Value status, - Value lastTyped, Value createdAt, Value updatedAt, Value deletedAt, @@ -3987,11 +3855,6 @@ class $$ChatMembersTableFilterComposer builder: (column) => ColumnFilters(column), ); - ColumnFilters get role => $composableBuilder( - column: $table.role, - builder: (column) => ColumnFilters(column), - ); - ColumnFilters get notify => $composableBuilder( column: $table.notify, builder: (column) => ColumnFilters(column), @@ -4012,21 +3875,6 @@ class $$ChatMembersTableFilterComposer builder: (column) => ColumnFilters(column), ); - ColumnFilters get isBot => $composableBuilder( - column: $table.isBot, - builder: (column) => ColumnFilters(column), - ); - - ColumnFilters get status => $composableBuilder( - column: $table.status, - builder: (column) => ColumnFilters(column), - ); - - ColumnFilters get lastTyped => $composableBuilder( - column: $table.lastTyped, - builder: (column) => ColumnFilters(column), - ); - ColumnFilters get createdAt => $composableBuilder( column: $table.createdAt, builder: (column) => ColumnFilters(column), @@ -4120,11 +3968,6 @@ class $$ChatMembersTableOrderingComposer builder: (column) => ColumnOrderings(column), ); - ColumnOrderings get role => $composableBuilder( - column: $table.role, - builder: (column) => ColumnOrderings(column), - ); - ColumnOrderings get notify => $composableBuilder( column: $table.notify, builder: (column) => ColumnOrderings(column), @@ -4145,21 +3988,6 @@ class $$ChatMembersTableOrderingComposer builder: (column) => ColumnOrderings(column), ); - ColumnOrderings get isBot => $composableBuilder( - column: $table.isBot, - builder: (column) => ColumnOrderings(column), - ); - - ColumnOrderings get status => $composableBuilder( - column: $table.status, - builder: (column) => ColumnOrderings(column), - ); - - ColumnOrderings get lastTyped => $composableBuilder( - column: $table.lastTyped, - builder: (column) => ColumnOrderings(column), - ); - ColumnOrderings get createdAt => $composableBuilder( column: $table.createdAt, builder: (column) => ColumnOrderings(column), @@ -4220,9 +4048,6 @@ class $$ChatMembersTableAnnotationComposer GeneratedColumn get nick => $composableBuilder(column: $table.nick, builder: (column) => column); - GeneratedColumn get role => - $composableBuilder(column: $table.role, builder: (column) => column); - GeneratedColumn get notify => $composableBuilder(column: $table.notify, builder: (column) => column); @@ -4239,15 +4064,6 @@ class $$ChatMembersTableAnnotationComposer builder: (column) => column, ); - GeneratedColumn get isBot => - $composableBuilder(column: $table.isBot, builder: (column) => column); - - GeneratedColumn get status => - $composableBuilder(column: $table.status, builder: (column) => column); - - GeneratedColumn get lastTyped => - $composableBuilder(column: $table.lastTyped, builder: (column) => column); - GeneratedColumn get createdAt => $composableBuilder(column: $table.createdAt, builder: (column) => column); @@ -4340,14 +4156,10 @@ class $$ChatMembersTableTableManager Value accountId = const Value.absent(), Value> account = const Value.absent(), Value nick = const Value.absent(), - Value role = const Value.absent(), Value notify = const Value.absent(), Value joinedAt = const Value.absent(), Value breakUntil = const Value.absent(), Value timeoutUntil = const Value.absent(), - Value isBot = const Value.absent(), - Value status = const Value.absent(), - Value lastTyped = const Value.absent(), Value createdAt = const Value.absent(), Value updatedAt = const Value.absent(), Value deletedAt = const Value.absent(), @@ -4358,14 +4170,10 @@ class $$ChatMembersTableTableManager accountId: accountId, account: account, nick: nick, - role: role, notify: notify, joinedAt: joinedAt, breakUntil: breakUntil, timeoutUntil: timeoutUntil, - isBot: isBot, - status: status, - lastTyped: lastTyped, createdAt: createdAt, updatedAt: updatedAt, deletedAt: deletedAt, @@ -4378,14 +4186,10 @@ class $$ChatMembersTableTableManager required String accountId, required Map account, Value nick = const Value.absent(), - required int role, required int notify, Value joinedAt = const Value.absent(), Value breakUntil = const Value.absent(), Value timeoutUntil = const Value.absent(), - required bool isBot, - Value status = const Value.absent(), - Value lastTyped = const Value.absent(), required DateTime createdAt, required DateTime updatedAt, Value deletedAt = const Value.absent(), @@ -4396,14 +4200,10 @@ class $$ChatMembersTableTableManager accountId: accountId, account: account, nick: nick, - role: role, notify: notify, joinedAt: joinedAt, breakUntil: breakUntil, timeoutUntil: timeoutUntil, - isBot: isBot, - status: status, - lastTyped: lastTyped, createdAt: createdAt, updatedAt: updatedAt, deletedAt: deletedAt, diff --git a/lib/database/message.dart b/lib/database/message.dart index f3e8ec89..578d046d 100644 --- a/lib/database/message.dart +++ b/lib/database/message.dart @@ -48,6 +48,7 @@ class ChatRooms extends Table { TextColumn get picture => text().map(const MapConverter()).nullable()(); TextColumn get background => text().map(const MapConverter()).nullable()(); TextColumn get realmId => text().nullable()(); + TextColumn get accountId => text().nullable()(); DateTimeColumn get createdAt => dateTime()(); DateTimeColumn get updatedAt => dateTime()(); DateTimeColumn get deletedAt => dateTime().nullable()(); @@ -62,14 +63,10 @@ class ChatMembers extends Table { TextColumn get accountId => text()(); TextColumn get account => text().map(const MapConverter())(); TextColumn get nick => text().nullable()(); - IntColumn get role => integer()(); IntColumn get notify => integer()(); DateTimeColumn get joinedAt => dateTime().nullable()(); DateTimeColumn get breakUntil => dateTime().nullable()(); DateTimeColumn get timeoutUntil => dateTime().nullable()(); - BoolColumn get isBot => boolean()(); - TextColumn get status => text().nullable()(); - DateTimeColumn get lastTyped => dateTime().nullable()(); DateTimeColumn get createdAt => dateTime()(); DateTimeColumn get updatedAt => dateTime()(); DateTimeColumn get deletedAt => dateTime().nullable()(); diff --git a/lib/models/chat.dart b/lib/models/chat.dart index 4dac1325..242ff669 100644 --- a/lib/models/chat.dart +++ b/lib/models/chat.dart @@ -18,6 +18,7 @@ sealed class SnChatRoom with _$SnChatRoom { required SnCloudFile? picture, required SnCloudFile? background, required String? realmId, + required String? accountId, required SnRealm? realm, required DateTime createdAt, required DateTime updatedAt, @@ -85,12 +86,10 @@ sealed class SnChatMember with _$SnChatMember { required String accountId, required SnAccount account, required String? nick, - required int role, required int notify, required DateTime? joinedAt, required DateTime? breakUntil, required DateTime? timeoutUntil, - required bool isBot, required SnAccountStatus? status, // Frontend data DateTime? lastTyped, diff --git a/lib/models/chat.freezed.dart b/lib/models/chat.freezed.dart index 74540e24..4bd27cab 100644 --- a/lib/models/chat.freezed.dart +++ b/lib/models/chat.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SnChatRoom { - String get id; String? get name; String? get description; int get type; bool get isPublic; bool get isCommunity; SnCloudFile? get picture; SnCloudFile? get background; String? get realmId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; List? get members; + String get id; String? get name; String? get description; int get type; bool get isPublic; bool get isCommunity; SnCloudFile? get picture; SnCloudFile? get background; String? get realmId; String? get accountId; SnRealm? get realm; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; List? get members; /// Create a copy of SnChatRoom /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $SnChatRoomCopyWith get copyWith => _$SnChatRoomCopyWithImpl Object.hash(runtimeType,id,name,description,type,isPublic,isCommunity,picture,background,realmId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(members)); +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,isCommunity,picture,background,realmId,accountId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(members)); @override String toString() { - return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, isCommunity: $isCommunity, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)'; + return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, isCommunity: $isCommunity, picture: $picture, background: $background, realmId: $realmId, accountId: $accountId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)'; } @@ -48,7 +48,7 @@ abstract mixin class $SnChatRoomCopyWith<$Res> { factory $SnChatRoomCopyWith(SnChatRoom value, $Res Function(SnChatRoom) _then) = _$SnChatRoomCopyWithImpl; @useResult $Res call({ - String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members + String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, String? accountId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members }); @@ -65,7 +65,7 @@ class _$SnChatRoomCopyWithImpl<$Res> /// Create a copy of SnChatRoom /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = freezed,Object? description = freezed,Object? type = null,Object? isPublic = null,Object? isCommunity = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = freezed,Object? description = freezed,Object? type = null,Object? isPublic = null,Object? isCommunity = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? accountId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable @@ -76,6 +76,7 @@ as bool,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ig 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 SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable +as String?,accountId: freezed == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as String?,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 as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -199,10 +200,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, String? accountId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _SnChatRoom() when $default != null: -return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);case _: +return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.accountId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);case _: return orElse(); } @@ -220,10 +221,10 @@ return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic, /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, String? accountId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members) $default,) {final _that = this; switch (_that) { case _SnChatRoom(): -return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);} +return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.accountId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);} } /// A variant of `when` that fallback to returning `null` /// @@ -237,10 +238,10 @@ return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic, /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, String? accountId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members)? $default,) {final _that = this; switch (_that) { case _SnChatRoom() when $default != null: -return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);case _: +return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic,_that.isCommunity,_that.picture,_that.background,_that.realmId,_that.accountId,_that.realm,_that.createdAt,_that.updatedAt,_that.deletedAt,_that.members);case _: return null; } @@ -252,7 +253,7 @@ return $default(_that.id,_that.name,_that.description,_that.type,_that.isPublic, @JsonSerializable() class _SnChatRoom implements SnChatRoom { - const _SnChatRoom({required this.id, required this.name, required this.description, required this.type, this.isPublic = false, this.isCommunity = false, required this.picture, required this.background, required this.realmId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt, required final List? members}): _members = members; + const _SnChatRoom({required this.id, required this.name, required this.description, required this.type, this.isPublic = false, this.isCommunity = false, required this.picture, required this.background, required this.realmId, required this.accountId, required this.realm, required this.createdAt, required this.updatedAt, required this.deletedAt, required final List? members}): _members = members; factory _SnChatRoom.fromJson(Map json) => _$SnChatRoomFromJson(json); @override final String id; @@ -264,6 +265,7 @@ class _SnChatRoom implements SnChatRoom { @override final SnCloudFile? picture; @override final SnCloudFile? background; @override final String? realmId; +@override final String? accountId; @override final SnRealm? realm; @override final DateTime createdAt; @override final DateTime updatedAt; @@ -291,16 +293,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChatRoom&&(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.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(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)&&const DeepCollectionEquality().equals(other._members, _members)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnChatRoom&&(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.isCommunity, isCommunity) || other.isCommunity == isCommunity)&&(identical(other.picture, picture) || other.picture == picture)&&(identical(other.background, background) || other.background == background)&&(identical(other.realmId, realmId) || other.realmId == realmId)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(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)&&const DeepCollectionEquality().equals(other._members, _members)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,isCommunity,picture,background,realmId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(_members)); +int get hashCode => Object.hash(runtimeType,id,name,description,type,isPublic,isCommunity,picture,background,realmId,accountId,realm,createdAt,updatedAt,deletedAt,const DeepCollectionEquality().hash(_members)); @override String toString() { - return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, isCommunity: $isCommunity, picture: $picture, background: $background, realmId: $realmId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)'; + return 'SnChatRoom(id: $id, name: $name, description: $description, type: $type, isPublic: $isPublic, isCommunity: $isCommunity, picture: $picture, background: $background, realmId: $realmId, accountId: $accountId, realm: $realm, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, members: $members)'; } @@ -311,7 +313,7 @@ abstract mixin class _$SnChatRoomCopyWith<$Res> implements $SnChatRoomCopyWith<$ factory _$SnChatRoomCopyWith(_SnChatRoom value, $Res Function(_SnChatRoom) _then) = __$SnChatRoomCopyWithImpl; @override @useResult $Res call({ - String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members + String id, String? name, String? description, int type, bool isPublic, bool isCommunity, SnCloudFile? picture, SnCloudFile? background, String? realmId, String? accountId, SnRealm? realm, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, List? members }); @@ -328,7 +330,7 @@ class __$SnChatRoomCopyWithImpl<$Res> /// Create a copy of SnChatRoom /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = freezed,Object? description = freezed,Object? type = null,Object? isPublic = null,Object? isCommunity = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = freezed,Object? description = freezed,Object? type = null,Object? isPublic = null,Object? isCommunity = null,Object? picture = freezed,Object? background = freezed,Object? realmId = freezed,Object? accountId = freezed,Object? realm = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? members = freezed,}) { return _then(_SnChatRoom( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable @@ -339,6 +341,7 @@ as bool,isCommunity: null == isCommunity ? _self.isCommunity : isCommunity // ig 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 SnCloudFile?,realmId: freezed == realmId ? _self.realmId : realmId // ignore: cast_nullable_to_non_nullable +as String?,accountId: freezed == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as String?,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 as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -1037,7 +1040,7 @@ $SnChatMemberCopyWith<$Res> get sender { /// @nodoc mixin _$SnChatMember { - DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; String get chatRoomId; SnChatRoom? get chatRoom; String get accountId; SnAccount get account; String? get nick; int get role; int get notify; DateTime? get joinedAt; DateTime? get breakUntil; DateTime? get timeoutUntil; bool get isBot; SnAccountStatus? get status;// Frontend data + DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; String get id; String get chatRoomId; SnChatRoom? get chatRoom; String get accountId; SnAccount get account; String? get nick; int get notify; DateTime? get joinedAt; DateTime? get breakUntil; DateTime? get timeoutUntil; SnAccountStatus? get status;// Frontend data DateTime? get lastTyped; /// Create a copy of SnChatMember /// with the given fields replaced by the non-null parameter values. @@ -1051,16 +1054,16 @@ $SnChatMemberCopyWith get copyWith => _$SnChatMemberCopyWithImpl Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,chatRoom,accountId,account,nick,role,notify,joinedAt,breakUntil,timeoutUntil,isBot,status,lastTyped); +int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,chatRoom,accountId,account,nick,notify,joinedAt,breakUntil,timeoutUntil,status,lastTyped); @override String toString() { - return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, chatRoom: $chatRoom, accountId: $accountId, account: $account, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, breakUntil: $breakUntil, timeoutUntil: $timeoutUntil, isBot: $isBot, status: $status, lastTyped: $lastTyped)'; + return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, chatRoom: $chatRoom, accountId: $accountId, account: $account, nick: $nick, notify: $notify, joinedAt: $joinedAt, breakUntil: $breakUntil, timeoutUntil: $timeoutUntil, status: $status, lastTyped: $lastTyped)'; } @@ -1071,7 +1074,7 @@ 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, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, bool isBot, SnAccountStatus? status, DateTime? lastTyped + DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, SnAccountStatus? status, DateTime? lastTyped }); @@ -1088,7 +1091,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? chatRoom = freezed,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? breakUntil = freezed,Object? timeoutUntil = freezed,Object? isBot = null,Object? status = freezed,Object? lastTyped = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? chatRoom = freezed,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? notify = null,Object? joinedAt = freezed,Object? breakUntil = freezed,Object? timeoutUntil = freezed,Object? status = freezed,Object? lastTyped = freezed,}) { 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 @@ -1099,13 +1102,11 @@ as String,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: c as SnChatRoom?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as String,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 String?,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 as DateTime?,breakUntil: freezed == breakUntil ? _self.breakUntil : breakUntil // ignore: cast_nullable_to_non_nullable as DateTime?,timeoutUntil: freezed == timeoutUntil ? _self.timeoutUntil : timeoutUntil // ignore: cast_nullable_to_non_nullable -as DateTime?,isBot: null == isBot ? _self.isBot : isBot // ignore: cast_nullable_to_non_nullable -as bool,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as DateTime?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable as SnAccountStatus?,lastTyped: freezed == lastTyped ? _self.lastTyped : lastTyped // ignore: cast_nullable_to_non_nullable as DateTime?, )); @@ -1222,10 +1223,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, bool isBot, SnAccountStatus? status, DateTime? lastTyped)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, SnAccountStatus? status, DateTime? lastTyped)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _SnChatMember() when $default != null: -return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.role,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.isBot,_that.status,_that.lastTyped);case _: +return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.status,_that.lastTyped);case _: return orElse(); } @@ -1243,10 +1244,10 @@ return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.c /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, bool isBot, SnAccountStatus? status, DateTime? lastTyped) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, SnAccountStatus? status, DateTime? lastTyped) $default,) {final _that = this; switch (_that) { case _SnChatMember(): -return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.role,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.isBot,_that.status,_that.lastTyped);} +return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.status,_that.lastTyped);} } /// A variant of `when` that fallback to returning `null` /// @@ -1260,10 +1261,10 @@ return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.c /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, bool isBot, SnAccountStatus? status, DateTime? lastTyped)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, SnAccountStatus? status, DateTime? lastTyped)? $default,) {final _that = this; switch (_that) { case _SnChatMember() when $default != null: -return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.role,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.isBot,_that.status,_that.lastTyped);case _: +return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.chatRoomId,_that.chatRoom,_that.accountId,_that.account,_that.nick,_that.notify,_that.joinedAt,_that.breakUntil,_that.timeoutUntil,_that.status,_that.lastTyped);case _: return null; } @@ -1275,7 +1276,7 @@ return $default(_that.createdAt,_that.updatedAt,_that.deletedAt,_that.id,_that.c @JsonSerializable() class _SnChatMember implements SnChatMember { - const _SnChatMember({required this.createdAt, required this.updatedAt, required this.deletedAt, required this.id, required this.chatRoomId, required this.chatRoom, required this.accountId, required this.account, required this.nick, required this.role, required this.notify, required this.joinedAt, required this.breakUntil, required this.timeoutUntil, required this.isBot, required this.status, this.lastTyped}); + const _SnChatMember({required this.createdAt, required this.updatedAt, required this.deletedAt, required this.id, required this.chatRoomId, required this.chatRoom, required this.accountId, required this.account, required this.nick, required this.notify, required this.joinedAt, required this.breakUntil, required this.timeoutUntil, required this.status, this.lastTyped}); factory _SnChatMember.fromJson(Map json) => _$SnChatMemberFromJson(json); @override final DateTime createdAt; @@ -1287,12 +1288,10 @@ class _SnChatMember implements SnChatMember { @override final String accountId; @override final SnAccount account; @override final String? nick; -@override final int role; @override final int notify; @override final DateTime? joinedAt; @override final DateTime? breakUntil; @override final DateTime? timeoutUntil; -@override final bool isBot; @override final SnAccountStatus? status; // Frontend data @override final DateTime? lastTyped; @@ -1310,16 +1309,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.chatRoom, chatRoom) || other.chatRoom == chatRoom)&&(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.breakUntil, breakUntil) || other.breakUntil == breakUntil)&&(identical(other.timeoutUntil, timeoutUntil) || other.timeoutUntil == timeoutUntil)&&(identical(other.isBot, isBot) || other.isBot == isBot)&&(identical(other.status, status) || other.status == status)&&(identical(other.lastTyped, lastTyped) || other.lastTyped == lastTyped)); + 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.chatRoom, chatRoom) || other.chatRoom == chatRoom)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.account, account) || other.account == account)&&(identical(other.nick, nick) || other.nick == nick)&&(identical(other.notify, notify) || other.notify == notify)&&(identical(other.joinedAt, joinedAt) || other.joinedAt == joinedAt)&&(identical(other.breakUntil, breakUntil) || other.breakUntil == breakUntil)&&(identical(other.timeoutUntil, timeoutUntil) || other.timeoutUntil == timeoutUntil)&&(identical(other.status, status) || other.status == status)&&(identical(other.lastTyped, lastTyped) || other.lastTyped == lastTyped)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,chatRoom,accountId,account,nick,role,notify,joinedAt,breakUntil,timeoutUntil,isBot,status,lastTyped); +int get hashCode => Object.hash(runtimeType,createdAt,updatedAt,deletedAt,id,chatRoomId,chatRoom,accountId,account,nick,notify,joinedAt,breakUntil,timeoutUntil,status,lastTyped); @override String toString() { - return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, chatRoom: $chatRoom, accountId: $accountId, account: $account, nick: $nick, role: $role, notify: $notify, joinedAt: $joinedAt, breakUntil: $breakUntil, timeoutUntil: $timeoutUntil, isBot: $isBot, status: $status, lastTyped: $lastTyped)'; + return 'SnChatMember(createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, id: $id, chatRoomId: $chatRoomId, chatRoom: $chatRoom, accountId: $accountId, account: $account, nick: $nick, notify: $notify, joinedAt: $joinedAt, breakUntil: $breakUntil, timeoutUntil: $timeoutUntil, status: $status, lastTyped: $lastTyped)'; } @@ -1330,7 +1329,7 @@ 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, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int role, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, bool isBot, SnAccountStatus? status, DateTime? lastTyped + DateTime createdAt, DateTime updatedAt, DateTime? deletedAt, String id, String chatRoomId, SnChatRoom? chatRoom, String accountId, SnAccount account, String? nick, int notify, DateTime? joinedAt, DateTime? breakUntil, DateTime? timeoutUntil, SnAccountStatus? status, DateTime? lastTyped }); @@ -1347,7 +1346,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? chatRoom = freezed,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? role = null,Object? notify = null,Object? joinedAt = freezed,Object? breakUntil = freezed,Object? timeoutUntil = freezed,Object? isBot = null,Object? status = freezed,Object? lastTyped = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,Object? id = null,Object? chatRoomId = null,Object? chatRoom = freezed,Object? accountId = null,Object? account = null,Object? nick = freezed,Object? notify = null,Object? joinedAt = freezed,Object? breakUntil = freezed,Object? timeoutUntil = freezed,Object? status = freezed,Object? lastTyped = freezed,}) { 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 @@ -1358,13 +1357,11 @@ as String,chatRoom: freezed == chatRoom ? _self.chatRoom : chatRoom // ignore: c as SnChatRoom?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable as String,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 String?,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 as DateTime?,breakUntil: freezed == breakUntil ? _self.breakUntil : breakUntil // ignore: cast_nullable_to_non_nullable as DateTime?,timeoutUntil: freezed == timeoutUntil ? _self.timeoutUntil : timeoutUntil // ignore: cast_nullable_to_non_nullable -as DateTime?,isBot: null == isBot ? _self.isBot : isBot // ignore: cast_nullable_to_non_nullable -as bool,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as DateTime?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable as SnAccountStatus?,lastTyped: freezed == lastTyped ? _self.lastTyped : lastTyped // ignore: cast_nullable_to_non_nullable as DateTime?, )); diff --git a/lib/models/chat.g.dart b/lib/models/chat.g.dart index 40e59081..60c3bc0c 100644 --- a/lib/models/chat.g.dart +++ b/lib/models/chat.g.dart @@ -22,6 +22,7 @@ _SnChatRoom _$SnChatRoomFromJson(Map json) => _SnChatRoom( ? null : SnCloudFile.fromJson(json['background'] as Map), realmId: json['realm_id'] as String?, + accountId: json['account_id'] as String?, realm: json['realm'] == null ? null @@ -49,6 +50,7 @@ Map _$SnChatRoomToJson(_SnChatRoom instance) => 'picture': instance.picture?.toJson(), 'background': instance.background?.toJson(), 'realm_id': instance.realmId, + 'account_id': instance.accountId, 'realm': instance.realm?.toJson(), 'created_at': instance.createdAt.toIso8601String(), 'updated_at': instance.updatedAt.toIso8601String(), @@ -162,7 +164,6 @@ _SnChatMember _$SnChatMemberFromJson(Map json) => accountId: json['account_id'] as String, account: SnAccount.fromJson(json['account'] as Map), nick: json['nick'] as String?, - role: (json['role'] as num).toInt(), notify: (json['notify'] as num).toInt(), joinedAt: json['joined_at'] == null @@ -176,7 +177,6 @@ _SnChatMember _$SnChatMemberFromJson(Map json) => json['timeout_until'] == null ? null : DateTime.parse(json['timeout_until'] as String), - isBot: json['is_bot'] as bool, status: json['status'] == null ? null @@ -200,12 +200,10 @@ Map _$SnChatMemberToJson(_SnChatMember instance) => 'account_id': instance.accountId, 'account': instance.account.toJson(), 'nick': instance.nick, - 'role': instance.role, 'notify': instance.notify, 'joined_at': instance.joinedAt?.toIso8601String(), 'break_until': instance.breakUntil?.toIso8601String(), 'timeout_until': instance.timeoutUntil?.toIso8601String(), - 'is_bot': instance.isBot, 'status': instance.status?.toJson(), 'last_typed': instance.lastTyped?.toIso8601String(), }; diff --git a/lib/pods/chat/chat_summary.g.dart b/lib/pods/chat/chat_summary.g.dart index c51a7276..d2cfc93f 100644 --- a/lib/pods/chat/chat_summary.g.dart +++ b/lib/pods/chat/chat_summary.g.dart @@ -24,7 +24,7 @@ final chatUnreadCountNotifierProvider = ); typedef _$ChatUnreadCountNotifier = AutoDisposeAsyncNotifier; -String _$chatSummaryHash() => r'33815a3bd81d20902b7063e8194fe336930df9b4'; +String _$chatSummaryHash() => r'8479ef53cfb0b698b800d0117d04774b6f78b3cc'; /// See also [ChatSummary]. @ProviderFor(ChatSummary) diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index 3b301d79..29276f37 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -199,24 +198,17 @@ Future> chatroomsJoined(Ref ref) async { final members = membersRows.map((mRow) { final account = SnAccount.fromJson(mRow.account); - SnAccountStatus? status; - if (mRow.status != null) { - status = SnAccountStatus.fromJson(jsonDecode(mRow.status!)); - } return SnChatMember( id: mRow.id, chatRoomId: mRow.chatRoomId, accountId: mRow.accountId, account: account, nick: mRow.nick, - role: mRow.role, notify: mRow.notify, joinedAt: mRow.joinedAt, breakUntil: mRow.breakUntil, timeoutUntil: mRow.timeoutUntil, - isBot: mRow.isBot, - status: status, - lastTyped: mRow.lastTyped, + status: null, createdAt: mRow.createdAt, updatedAt: mRow.updatedAt, deletedAt: mRow.deletedAt, @@ -237,6 +229,7 @@ Future> chatroomsJoined(Ref ref) async { ? SnCloudFile.fromJson(row.background!) : null, realmId: row.realmId, + accountId: row.accountId, realm: null, createdAt: row.createdAt, updatedAt: row.updatedAt, @@ -709,16 +702,6 @@ class _ChatInvitesSheet extends HookConsumerWidget { subtitle: Row( spacing: 6, children: [ - Flexible( - child: - Text( - invite.role >= 100 - ? 'permissionOwner' - : invite.role >= 50 - ? 'permissionModerator' - : 'permissionMember', - ).tr(), - ), if (invite.chatRoom!.type == 1) Badge( label: const Text('directMessage').tr(), diff --git a/lib/screens/chat/chat.g.dart b/lib/screens/chat/chat.g.dart index 0c7dcdc0..4b91d400 100644 --- a/lib/screens/chat/chat.g.dart +++ b/lib/screens/chat/chat.g.dart @@ -6,7 +6,7 @@ part of 'chat.dart'; // RiverpodGenerator // ************************************************************************** -String _$chatroomsJoinedHash() => r'9523efecd1869e7dd26adfc8ec87be48db19ee1c'; +String _$chatroomsJoinedHash() => r'20a970e8456df088f41e783aa4443a59f56847db'; /// See also [chatroomsJoined]. @ProviderFor(chatroomsJoined) diff --git a/lib/screens/chat/room_detail.dart b/lib/screens/chat/room_detail.dart index 765060e2..90043dfa 100644 --- a/lib/screens/chat/room_detail.dart +++ b/lib/screens/chat/room_detail.dart @@ -440,12 +440,17 @@ class _ChatRoomActionMenu extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final chatIdentity = ref.watch(chatroomIdentityProvider(id)); + final chatRoom = ref.watch(chatroomProvider(id)); + + final isManagable = + chatIdentity.value?.accountId == chatRoom.value?.accountId || + chatRoom.value?.type == 1; return PopupMenuButton( icon: Icon(Icons.more_vert, shadows: [iconShadow]), itemBuilder: (context) => [ - if ((chatIdentity.value?.role ?? 0) >= 50) + if (isManagable) PopupMenuItem( onTap: () { showModalBottomSheet( @@ -471,7 +476,7 @@ class _ChatRoomActionMenu extends HookConsumerWidget { ], ), ), - if ((chatIdentity.value?.role ?? 0) >= 100) + if (isManagable) PopupMenuItem( child: Row( children: [ @@ -644,6 +649,11 @@ class _ChatMemberListSheet extends HookConsumerWidget { final memberNotifier = ref.read(chatMemberStateProvider(roomId).notifier); final roomIdentity = ref.watch(chatroomIdentityProvider(roomId)); + final chatRoom = ref.watch(chatroomProvider(roomId)); + + final isManagable = + chatRoom.value?.accountId == roomIdentity.value?.accountId || + chatRoom.value?.type == 1; useEffect(() { Future(() { @@ -752,45 +762,11 @@ class _ChatMemberListSheet extends HookConsumerWidget { const Icon(Symbols.pending_actions, size: 20), ], ), - subtitle: Row( - children: [ - Text( - member.role >= 100 - ? 'permissionOwner' - : member.role >= 50 - ? 'permissionModerator' - : 'permissionMember', - ).tr(), - Text('ยท').bold().padding(horizontal: 6), - Expanded(child: Text("@${member.account.name}")), - ], - ), + subtitle: Text("@${member.account.name}"), trailing: Row( mainAxisSize: MainAxisSize.min, children: [ - if ((roomIdentity.value?.role ?? 0) >= 50) - IconButton( - icon: const Icon(Symbols.edit), - onPressed: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: - (context) => _ChatMemberRoleSheet( - roomId: roomId, - member: member, - ), - ).then((value) { - if (value != null) { - // Refresh both providers - memberNotifier.reset(); - memberNotifier.loadMore(); - ref.invalidate(memberListProvider); - } - }); - }, - ), - if ((roomIdentity.value?.role ?? 0) >= 50) + if (isManagable) IconButton( icon: const Icon(Symbols.delete), onPressed: () { @@ -829,120 +805,3 @@ class _ChatMemberListSheet extends HookConsumerWidget { ); } } - -class _ChatMemberRoleSheet extends HookConsumerWidget { - final String roomId; - final SnChatMember member; - - const _ChatMemberRoleSheet({required this.roomId, required this.member}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final roleController = useTextEditingController( - text: member.role.toString(), - ); - - return Container( - padding: EdgeInsets.only( - bottom: MediaQuery.of(context).viewInsets.bottom, - ), - child: SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: EdgeInsets.only( - top: 16, - left: 20, - right: 16, - bottom: 12, - ), - child: Row( - children: [ - Text( - 'memberRoleEdit'.tr(args: [member.account.name]), - style: Theme.of(context).textTheme.headlineSmall?.copyWith( - fontWeight: FontWeight.w600, - letterSpacing: -0.5, - ), - ), - const Spacer(), - IconButton( - icon: const Icon(Symbols.close), - onPressed: () => Navigator.pop(context), - style: IconButton.styleFrom( - minimumSize: const Size(36, 36), - ), - ), - ], - ), - ), - const Divider(height: 1), - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Autocomplete( - optionsBuilder: (TextEditingValue textEditingValue) { - if (textEditingValue.text.isEmpty) { - return const [100, 50, 0]; - } - final int? value = int.tryParse(textEditingValue.text); - if (value == null) return const [100, 50, 0]; - return [100, 50, 0].where( - (option) => - option.toString().contains(textEditingValue.text), - ); - }, - onSelected: (int selection) { - roleController.text = selection.toString(); - }, - fieldViewBuilder: ( - context, - controller, - focusNode, - onFieldSubmitted, - ) { - return TextField( - controller: controller, - focusNode: focusNode, - keyboardType: TextInputType.number, - decoration: InputDecoration( - labelText: 'memberRole'.tr(), - helperText: 'memberRoleHint'.tr(), - ), - onTapOutside: (event) => focusNode.unfocus(), - ); - }, - ), - const Gap(16), - FilledButton.icon( - onPressed: () async { - try { - final newRole = int.parse(roleController.text); - if (newRole < 0 || newRole > 100) { - throw 'roleValidationHint'.tr(); - } - - final apiClient = ref.read(apiClientProvider); - await apiClient.patch( - '/sphere/chat/$roomId/members/${member.accountId}/role', - data: newRole, - ); - - if (context.mounted) Navigator.pop(context, true); - } catch (err) { - showErrorAlert(err); - } - }, - icon: const Icon(Symbols.save), - label: const Text('saveChanges').tr(), - ), - ], - ).padding(vertical: 16, horizontal: 24), - ], - ), - ), - ); - } -} diff --git a/lib/screens/notification.g.dart b/lib/screens/notification.g.dart index 381a30f4..a0ea5b6b 100644 --- a/lib/screens/notification.g.dart +++ b/lib/screens/notification.g.dart @@ -7,7 +7,7 @@ part of 'notification.dart'; // ************************************************************************** String _$notificationUnreadCountNotifierHash() => - r'08c773809958d96a7ce82acf04af1f9e0b23e119'; + r'8bff5ad3b65389589b4112add3246afd9b8e38f9'; /// See also [NotificationUnreadCountNotifier]. @ProviderFor(NotificationUnreadCountNotifier) diff --git a/lib/widgets/chat/message_sender_info.dart b/lib/widgets/chat/message_sender_info.dart index eaf4a9ab..1479ce12 100644 --- a/lib/widgets/chat/message_sender_info.dart +++ b/lib/widgets/chat/message_sender_info.dart @@ -115,25 +115,9 @@ class MessageSenderInfo extends StatelessWidget { spacing: 2, children: [ Text(timestamp, style: TextStyle(fontSize: 10, color: textColor)), - Row( - mainAxisSize: MainAxisSize.min, - spacing: 5, - children: [ - AccountName( - account: sender.account, - style: Theme.of(context).textTheme.bodySmall, - ), - Badge( - label: - Text( - sender.role >= 100 - ? 'permissionOwner' - : sender.role >= 50 - ? 'permissionModerator' - : 'permissionMember', - ).tr(), - ), - ], + AccountName( + account: sender.account, + style: Theme.of(context).textTheme.bodySmall, ), ], ),