mirror of https://github.com/oxen-io/session-ios
Partially implement feedback
parent
294d44c773
commit
7b0e2d06b0
@ -0,0 +1,39 @@
|
||||
|
||||
@objc(LKDisplayNameUtilities)
|
||||
public final class DisplayNameUtilities : NSObject {
|
||||
|
||||
override private init() { }
|
||||
|
||||
private static var userHexEncodedPublicKey: String {
|
||||
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
||||
}
|
||||
|
||||
private static var userDisplayName: String? {
|
||||
return OWSProfileManager.shared().localProfileName()
|
||||
}
|
||||
|
||||
@objc public static func getPrivateChatDisplayName(for hexEncodedPublicKey: String) -> String? {
|
||||
if hexEncodedPublicKey == userHexEncodedPublicKey {
|
||||
return userDisplayName
|
||||
} else {
|
||||
return OWSProfileManager.shared().profileName(forRecipientId: hexEncodedPublicKey)
|
||||
}
|
||||
}
|
||||
|
||||
@objc public static func getGroupChatDisplayName(for hexEncodedPublicKey: String, in channel: UInt64, on server: String) -> String? {
|
||||
var result: String?
|
||||
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
|
||||
result = getGroupChatDisplayName(for: hexEncodedPublicKey, in: channel, on: server, using: transaction)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public static func getGroupChatDisplayName(for hexEncodedPublicKey: String, in channel: UInt64, on server: String, using transaction: YapDatabaseReadTransaction) -> String? {
|
||||
if hexEncodedPublicKey == userHexEncodedPublicKey {
|
||||
return userDisplayName
|
||||
} else {
|
||||
let collection = "\(server).\(channel)"
|
||||
return transaction.object(forKey: hexEncodedPublicKey, inCollection: collection) as! String?
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue