large emojis, full contact names, contact createdAt, process profile updates, etc. (#268)

This commit is contained in:
Evgeny Poberezkin
2022-02-04 22:13:52 +00:00
committed by GitHub
parent 214ecf605b
commit e424e9328b
13 changed files with 270 additions and 92 deletions
+34 -6
View File
@@ -126,12 +126,26 @@ enum ChatInfo: Identifiable, Decodable {
var localDisplayName: String {
get {
switch self {
case let .direct(contact): return "@\(contact.localDisplayName)"
case let .group(groupInfo): return "#\(groupInfo.localDisplayName)"
case let .contactRequest(contactRequest): return "< @\(contactRequest.localDisplayName)"
case let .direct(contact): return contact.localDisplayName
case let .group(groupInfo): return groupInfo.localDisplayName
case let .contactRequest(contactRequest): return contactRequest.localDisplayName
}
}
}
var fullName: String {
get {
switch self {
case let .direct(contact): return contact.profile.fullName
case let .group(groupInfo): return groupInfo.groupProfile.fullName
case let .contactRequest(contactRequest): return contactRequest.profile.fullName
}
}
}
var chatViewName: String {
get { localDisplayName + (fullName == "" || fullName == localDisplayName ? "" : " / \(fullName)") }
}
var id: String {
get {
@@ -162,6 +176,14 @@ enum ChatInfo: Identifiable, Decodable {
}
}
}
var createdAt: Date {
switch self {
case let .direct(contact): return contact.createdAt
case let .group(groupInfo): return groupInfo.createdAt
case let .contactRequest(contactRequest): return contactRequest.createdAt
}
}
}
let sampleDirectChatInfo = ChatInfo.direct(contact: sampleContact)
@@ -200,6 +222,7 @@ struct Contact: Identifiable, Decodable {
var profile: Profile
var activeConn: Connection
var viaGroup: Int64?
var createdAt: Date
var id: String { get { "@\(contactId)" } }
var apiId: Int64 { get { contactId } }
@@ -210,7 +233,8 @@ let sampleContact = Contact(
contactId: 1,
localDisplayName: "alice",
profile: sampleProfile,
activeConn: sampleConnection
activeConn: sampleConnection,
createdAt: .now
)
struct Connection: Decodable {
@@ -223,6 +247,7 @@ struct UserContactRequest: Decodable {
var contactRequestId: Int64
var localDisplayName: ContactName
var profile: Profile
var createdAt: Date
var id: String { get { "<@\(contactRequestId)" } }
@@ -232,13 +257,15 @@ struct UserContactRequest: Decodable {
let sampleContactRequest = UserContactRequest(
contactRequestId: 1,
localDisplayName: "alice",
profile: sampleProfile
profile: sampleProfile,
createdAt: .now
)
struct GroupInfo: Identifiable, Decodable {
var groupId: Int64
var localDisplayName: GroupName
var groupProfile: GroupProfile
var createdAt: Date
var id: String { get { "#\(groupId)" } }
@@ -248,7 +275,8 @@ struct GroupInfo: Identifiable, Decodable {
let sampleGroupInfo = GroupInfo(
groupId: 1,
localDisplayName: "team",
groupProfile: sampleGroupProfile
groupProfile: sampleGroupProfile,
createdAt: .now
)
struct GroupProfile: Codable {