RecentChatData.fromJson constructor

RecentChatData.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory RecentChatData.fromJson(Map<String, dynamic> json) => RecentChatData(
      contactType: Platform.isAndroid
          ? json["contactType"] == "unknown"
              ? "unknown_contact"
              : json["contactType"] == "live"
                  ? "live_contact"
                  : json["contactType"] == "local"
                      ? "local_contact"
                      : json["contactType"] == "deleted"
                          ? "deleted_contact"
                          : json["contactType"]
          : json["isItSavedContact"] == true
              ? "live_contact"
              : json["isDeletedUser"] == true
                  ? "deleted_contact"
                  : "unknown_contact",
      isAdminBlocked: json["isAdminBlocked"],
      isBlocked: json["isBlocked"],
      isBlockedMe: json["isBlockedMe"],
      isBroadCast: json["isBroadCast"],
      isChatArchived: json["isChatArchived"],
      isChatPinned: json["isChatPinned"],
      isConversationUnRead: json["isConversationUnRead"],
      isGroup: json["isGroup"],
      isGroupInOfflineMode: json["isGroupInOfflineMode"],
      isItSavedContact: json["isItSavedContact"],
      isLastMessageRecalledByUser: json["isLastMessageRecalledByUser"],
      isLastMessageSentByMe: json["isLastMessageSentByMe"],
      isMuted: json["isMuted"],
      isSelected: json["isSelected"],
      jid: json["jid"],
      lastMessageContent: json["lastMessageContent"],
      lastMessageId: json["lastMessageId"],
      lastMessageStatus: Platform.isAndroid
          ? json["lastMessageStatus"]
          : json["lastMessageStatus"] == 2//acknowledge
              ? "A"
              : json["lastMessageStatus"] == 3//delivered
                  ? "D"
                  : json["lastMessageStatus"] == 4//seen
                      ? "S"
                      : json["lastMessageStatus"] == 5//received
                          ? "R"
                          : "N", //"N" for "notAcknowledged" in iOS,
      // lastMessageTime: Platform.isAndroid ? json["lastMessageTime"] : json["isGroup"] ? json["lastMessageTime"] * 1000 : json["lastMessageTime"],
      lastMessageTime: json["lastMessageTime"].toInt().toString().length == 13
          ? json["lastMessageTime"] * 1000
          : json["lastMessageTime"],
      lastMessageType: json["lastMessageType"],
      nickName: json["nickName"],
      profileImage: json["profileImage"],
      profileName: json["profileName"],
      unreadMessageCount: json["unreadMessageCount"],
    );