core, ios: include contact addresses in profiles (#2328)

* core: include contact links in profiles

* add connection request link to contact and group profiles

* set group link on update, view, api

* core: include contact addresses in profiles

* remove id from UserContactLink

* schema, fix test

* remove address from profile when deleting link, tests

* remove diff

* remove diff

* fix

* ios wip

* learn more, confirm save, reset on delete

* re-use in create link view

* remove obsolete files

* color

* revert scheme

* learn more with create

* layout

* layout

* progress indicator

* delete text

* save on change, layout

---------

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
spaced4ndy
2023-04-27 17:19:21 +04:00
committed by GitHub
parent 8630d1ab12
commit 0b57cc08a7
24 changed files with 757 additions and 375 deletions
+3
View File
@@ -85,6 +85,7 @@ public enum ChatCommand {
case apiCreateMyAddress(userId: Int64)
case apiDeleteMyAddress(userId: Int64)
case apiShowMyAddress(userId: Int64)
case apiSetProfileAddress(userId: Int64, on: Bool)
case apiAddressAutoAccept(userId: Int64, autoAccept: AutoAccept?)
case apiAcceptContact(contactReqId: Int64)
case apiRejectContact(contactReqId: Int64)
@@ -189,6 +190,7 @@ public enum ChatCommand {
case let .apiCreateMyAddress(userId): return "/_address \(userId)"
case let .apiDeleteMyAddress(userId): return "/_delete_address \(userId)"
case let .apiShowMyAddress(userId): return "/_show_address \(userId)"
case let .apiSetProfileAddress(userId, on): return "/_profile_address \(userId) \(onOff(on))"
case let .apiAddressAutoAccept(userId, autoAccept): return "/_auto_accept \(userId) \(AutoAccept.cmdString(autoAccept))"
case let .apiAcceptContact(contactReqId): return "/_accept \(contactReqId)"
case let .apiRejectContact(contactReqId): return "/_reject \(contactReqId)"
@@ -290,6 +292,7 @@ public enum ChatCommand {
case .apiCreateMyAddress: return "apiCreateMyAddress"
case .apiDeleteMyAddress: return "apiDeleteMyAddress"
case .apiShowMyAddress: return "apiShowMyAddress"
case .apiSetProfileAddress: return "apiSetProfileAddress"
case .apiAddressAutoAccept: return "apiAddressAutoAccept"
case .apiAcceptContact: return "apiAcceptContact"
case .apiRejectContact: return "apiRejectContact"
+28 -4
View File
@@ -33,6 +33,10 @@ public struct User: Decodable, NamedChat, Identifiable {
activeUser || showNtfs
}
public var addressShared: Bool {
profile.contactLink != nil
}
public static let sampleData = User(
userId: 1,
userContactId: 1,
@@ -71,16 +75,24 @@ public typealias ContactName = String
public typealias GroupName = String
public struct Profile: Codable, NamedChat {
public init(displayName: String, fullName: String, image: String? = nil, preferences: Preferences? = nil) {
public init(
displayName: String,
fullName: String,
image: String? = nil,
contactLink: String? = nil,
preferences: Preferences? = nil
) {
self.displayName = displayName
self.fullName = fullName
self.image = image
self.contactLink = contactLink
self.preferences = preferences
}
public var displayName: String
public var fullName: String
public var image: String?
public var contactLink: String?
public var preferences: Preferences?
public var localAlias: String { get { "" } }
@@ -95,11 +107,20 @@ public struct Profile: Codable, NamedChat {
}
public struct LocalProfile: Codable, NamedChat {
public init(profileId: Int64, displayName: String, fullName: String, image: String? = nil, preferences: Preferences? = nil, localAlias: String) {
public init(
profileId: Int64,
displayName: String,
fullName: String,
image: String? = nil,
contactLink: String? = nil,
preferences: Preferences? = nil,
localAlias: String
) {
self.profileId = profileId
self.displayName = displayName
self.fullName = fullName
self.image = image
self.contactLink = contactLink
self.preferences = preferences
self.localAlias = localAlias
}
@@ -108,6 +129,7 @@ public struct LocalProfile: Codable, NamedChat {
public var displayName: String
public var fullName: String
public var image: String?
public var contactLink: String?
public var preferences: Preferences?
public var localAlias: String
@@ -127,11 +149,11 @@ public struct LocalProfile: Codable, NamedChat {
}
public func toLocalProfile (_ profileId: Int64, _ profile: Profile, _ localAlias: String) -> LocalProfile {
LocalProfile(profileId: profileId, displayName: profile.displayName, fullName: profile.fullName, image: profile.image, preferences: profile.preferences, localAlias: localAlias)
LocalProfile(profileId: profileId, displayName: profile.displayName, fullName: profile.fullName, image: profile.image, contactLink: profile.contactLink, preferences: profile.preferences, localAlias: localAlias)
}
public func fromLocalProfile (_ profile: LocalProfile) -> Profile {
Profile(displayName: profile.displayName, fullName: profile.fullName, image: profile.image, preferences: profile.preferences)
Profile(displayName: profile.displayName, fullName: profile.fullName, image: profile.image, contactLink: profile.contactLink, preferences: profile.preferences)
}
public enum ChatType: String {
@@ -1164,6 +1186,7 @@ public struct Contact: Identifiable, Decodable, NamedChat {
public var displayName: String { localAlias == "" ? profile.displayName : localAlias }
public var fullName: String { get { profile.fullName } }
public var image: String? { get { profile.image } }
public var contactLink: String? { get { profile.contactLink } }
public var localAlias: String { profile.localAlias }
public var verified: Bool { activeConn.connectionCode != nil }
@@ -1508,6 +1531,7 @@ public struct GroupMember: Identifiable, Decodable {
}
public var fullName: String { get { memberProfile.fullName } }
public var image: String? { get { memberProfile.image } }
public var contactLink: String? { get { memberProfile.contactLink } }
public var verified: Bool { activeConn?.connectionCode != nil }
var directChatId: ChatId? {