fromDb static method

DtoUser fromDb(
  1. UserRow e
)

Constructs a DtoUser from the provided UserRow.

Implementation

static DtoUser fromDb(UserRow e) {
  return DtoUser(
    User(
      UserId(e.id),
      UserNum(e.num),
      name: e.name == null ? null : UserName(e.name!),
      bio: e.bio == null ? null : UserBio(e.bio!),
      avatar: e.avatar == null
          ? null
          : UserAvatar.fromJson(jsonDecode(e.avatar!)),
      callCover: e.callCover == null
          ? null
          : UserCallCover.fromJson(jsonDecode(e.callCover!)),
      mutualContactsCount: e.mutualContactsCount,
      online: e.online,
      presenceIndex: e.presenceIndex,
      status: e.status == null ? null : UserTextStatus(e.status!),
      isDeleted: e.isDeleted,
      dialog: e.dialog == null ? null : ChatId(e.dialog!),
      isBlocked: e.isBlocked == null
          ? null
          : BlocklistRecord.fromJson(jsonDecode(e.isBlocked!)),
      lastSeenAt: e.lastSeenAt,
      contacts: (jsonDecode(e.contacts) as List)
          .map((e) => NestedChatContact.fromJson(e))
          .cast<NestedChatContact>()
          .toList(),
      welcomeMessage: e.welcomeMessage == null
          ? null
          : WelcomeMessage.fromJson(jsonDecode(e.welcomeMessage!)),
    ),
    UserVersion(e.ver),
    BlocklistVersion(e.blockedVer),
  );
}