migrate code
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user