migrate code

This commit is contained in:
Salvatore Giordano
2021-04-20 12:44:22 +02:00
parent 987da10cba
commit bc9e0d0285
4 changed files with 47 additions and 60 deletions
@@ -27,7 +27,7 @@ class ChannelModel {
createdAt = createdAt ?? DateTime.now(),
updatedAt = updatedAt ?? DateTime.now(),
assert(
cid != null || (id != null && type != null),
(cid != null && cid.contains(':')) || (id != null && type != null),
'provide either a cid or an id and type',
),
id = id ?? cid!.split(':')[1],
+2 -14
View File
@@ -8,7 +8,7 @@ part 'user.g.dart';
class User {
/// Constructor used for json serialization
User({
this.id = '',
required this.id,
this.role = '',
DateTime? createdAt,
DateTime? updatedAt,
@@ -24,18 +24,6 @@ class User {
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(
Serialization.moveToExtraDataFromRoot(json, topLevelFields));
/// Use this named constructor to create a new user instance
User.init(
this.id, {
this.online = false,
this.extraData = const {},
required this.createdAt,
required this.updatedAt,
this.teams = const [],
required this.role,
}) : lastActive = null,
banned = false;
/// Known top level fields.
/// Useful for [Serialization] methods.
static const topLevelFields = [
@@ -94,7 +82,7 @@ class User {
int get hashCode => id.hashCode;
/// Shortcut for user name
String? get name =>
String get name =>
(extraData.containsKey('name') == true && extraData['name'] != '')
? extraData['name']
: id;