forked from signalapp/Signal-iOS
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
294d44c
commit 7b0e2d0
Showing
19 changed files
with
112 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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? | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.