Fix build
This commit is contained in:
parent
7b0e2d06b0
commit
48883bf1f1
|
@ -568,7 +568,6 @@
|
|||
B82584A02315024B001B41CB /* RSSFeedPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = B825849F2315024B001B41CB /* RSSFeedPoller.swift */; };
|
||||
B846365B22B7418B00AF1514 /* Identicon+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */; };
|
||||
B84664F5235022F30083A1CD /* MentionUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B84664F4235022F30083A1CD /* MentionUtilities.swift */; };
|
||||
B84664F923541F070083A1CD /* DisplayNameUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B84664F823541F070083A1CD /* DisplayNameUtilities.swift */; };
|
||||
B86BD08123399883000F5AE3 /* QRCodeModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08023399883000F5AE3 /* QRCodeModal.swift */; };
|
||||
B86BD08423399ACF000F5AE3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08323399ACF000F5AE3 /* Modal.swift */; };
|
||||
B86BD08623399CEF000F5AE3 /* SeedModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08523399CEF000F5AE3 /* SeedModal.swift */; };
|
||||
|
@ -1381,7 +1380,6 @@
|
|||
B825849F2315024B001B41CB /* RSSFeedPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSSFeedPoller.swift; sourceTree = "<group>"; };
|
||||
B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Identicon+ObjC.swift"; sourceTree = "<group>"; };
|
||||
B84664F4235022F30083A1CD /* MentionUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MentionUtilities.swift; sourceTree = "<group>"; };
|
||||
B84664F823541F070083A1CD /* DisplayNameUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameUtilities.swift; sourceTree = "<group>"; };
|
||||
B86BD08023399883000F5AE3 /* QRCodeModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeModal.swift; sourceTree = "<group>"; };
|
||||
B86BD08323399ACF000F5AE3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
|
||||
B86BD08523399CEF000F5AE3 /* SeedModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedModal.swift; sourceTree = "<group>"; };
|
||||
|
@ -2673,7 +2671,6 @@
|
|||
B846365A22B7418B00AF1514 /* Identicon+ObjC.swift */,
|
||||
241C6312231F5F1D00B4198E /* CGFloat+Rounding.swift */,
|
||||
241C6310231F5C4400B4198E /* UIColor+Helper.swift */,
|
||||
B84664F823541F070083A1CD /* DisplayNameUtilities.swift */,
|
||||
);
|
||||
path = Loki;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3578,7 +3575,6 @@
|
|||
450998681FD8C0FF00D89EB3 /* AttachmentSharing.m in Sources */,
|
||||
347850711FDAEB17007B8332 /* OWSUserProfile.m in Sources */,
|
||||
346129F81FD5F31400532771 /* OWS100RemoveTSRecipientsMigration.m in Sources */,
|
||||
B84664F923541F070083A1CD /* DisplayNameUtilities.swift in Sources */,
|
||||
34AC09DF211B39B100997B47 /* OWSNavigationController.m in Sources */,
|
||||
34074F61203D0CBE004596AE /* OWSSounds.m in Sources */,
|
||||
34BEDB1721C80BCA007B0EAE /* OWSAnyTouchGestureRecognizer.m in Sources */,
|
||||
|
|
|
@ -707,7 +707,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSString *text = displayableText.displayText;
|
||||
|
||||
NSMutableAttributedString *attributedText = [LKMentionUtilities highlightMentionsIn:text isOutgoingMessage:isOutgoingMessage thread:thread attributes:@{ NSFontAttributeName : font, NSForegroundColorAttributeName : textColor }].mutableCopy;
|
||||
NSMutableAttributedString *attributedText = [LKMentionUtilities highlightMentionsIn:text isOutgoingMessage:isOutgoingMessage threadID:thread.uniqueId attributes:@{ NSFontAttributeName : font, NSForegroundColorAttributeName : textColor }].mutableCopy;
|
||||
|
||||
if (searchText.length >= ConversationSearchController.kMinimumSearchTextLength) {
|
||||
NSString *searchableText = [FullTextSearchFinder normalizeWithText:searchText];
|
||||
|
@ -1158,7 +1158,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (!self.viewItem.hasQuotedText) { return nil; }
|
||||
NSString *rawText = self.viewItem.displayableQuotedText.fullText;
|
||||
TSThread *thread = self.viewItem.interaction.thread;
|
||||
NSString *text = [LKMentionUtilities highlightMentionsIn:rawText thread:thread];
|
||||
NSString *text = [LKMentionUtilities highlightMentionsIn:rawText threadID:thread.uniqueId];
|
||||
return [DisplayableText displayableText:text];
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *displayableText = thread.lastMessageText;
|
||||
if (displayableText) {
|
||||
[LKAPI populateUserHexEncodedPublicKeyCacheIfNeededFor:thread.threadRecord.uniqueId in:nil]; // TODO: Terrible place to do this, but okay for now
|
||||
displayableText = [LKMentionUtilities highlightMentionsIn:displayableText thread:thread.threadRecord];
|
||||
displayableText = [LKMentionUtilities highlightMentionsIn:displayableText threadID:thread.threadRecord.uniqueId];
|
||||
[snippetText appendAttributedString:[[NSAttributedString alloc]
|
||||
initWithString:displayableText
|
||||
attributes:@{
|
||||
|
|
|
@ -8,6 +8,16 @@ public final class LokiGroupChat : NSObject, NSCoding {
|
|||
@objc public let displayName: String
|
||||
@objc public let isDeletable: Bool
|
||||
|
||||
@objc public static var defaultChats: [LokiGroupChat] {
|
||||
var chats = [LokiGroupChat(channel: UInt64(1), server: "https://chat.lokinet.org", displayName: NSLocalizedString("Loki Public Chat", comment: ""), isDeletable: true)!]
|
||||
|
||||
#if DEBUG
|
||||
chats.append(LokiGroupChat(channel: UInt64(1), server: "https://chat-dev.lokinet.org", displayName: "Loki Dev Chat", isDeletable: true)!)
|
||||
#endif
|
||||
|
||||
return chats
|
||||
}
|
||||
|
||||
@objc public init?(channel: UInt64, server: String, displayName: String, isDeletable: Bool) {
|
||||
let id = "\(server).\(channel)"
|
||||
self.id = id
|
||||
|
|
|
@ -5,6 +5,7 @@ public final class LokiPublicChatManager: NSObject {
|
|||
|
||||
// MARK: Error
|
||||
public enum Error : Swift.Error {
|
||||
case chatCreationFailed
|
||||
case userPublicKeyNotFound
|
||||
}
|
||||
|
||||
|
@ -47,21 +48,26 @@ public final class LokiPublicChatManager: NSObject {
|
|||
|
||||
public func addChat(server: String, channel: UInt64) -> Promise<LokiGroupChat> {
|
||||
if let existingChat = getChat(server: server, channel: channel) {
|
||||
return Promise.value(self.addChat(server: server, channel: channel, name: existingChat.displayName))
|
||||
if let chat = self.addChat(server: server, channel: channel, name: existingChat.displayName) {
|
||||
return Promise.value(chat)
|
||||
} else {
|
||||
return Promise(error: Error.chatCreationFailed)
|
||||
}
|
||||
}
|
||||
|
||||
return LokiGroupChatAPI.getAuthToken(for: server).then { token in
|
||||
return LokiGroupChatAPI.getChannelInfo(channel, on: server)
|
||||
}.map { channelInfo -> LokiGroupChat in
|
||||
return self.addChat(server: server, channel: channel, name: channelInfo)
|
||||
guard let chat = self.addChat(server: server, channel: channel, name: channelInfo) else { throw Error.chatCreationFailed }
|
||||
return chat
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
@objc(addChatWithServer:channel:name:)
|
||||
public func addChat(server: String, channel: UInt64, name: String) -> LokiGroupChat {
|
||||
let chat = LokiGroupChat(channel: channel, server: server, displayName: name, isDeletable: true)
|
||||
let model = TSGroupModel(title: chat.displayName, memberIds: [ourHexEncodedPublicKey!, chat.server], image: nil, groupId: chat.idAsData!)
|
||||
public func addChat(server: String, channel: UInt64, name: String) -> LokiGroupChat? {
|
||||
guard let chat = LokiGroupChat(channel: channel, server: server, displayName: name, isDeletable: true) else { return nil }
|
||||
let model = TSGroupModel(title: chat.displayName, memberIds: [ourHexEncodedPublicKey!, chat.server], image: nil, groupId: chat.idAsData)
|
||||
|
||||
// Store the group chat mapping
|
||||
self.storage.dbReadWriteConnection.readWrite { transaction in
|
||||
|
@ -95,7 +101,7 @@ public final class LokiPublicChatManager: NSObject {
|
|||
|
||||
private func refreshChatsAndPollers() {
|
||||
storage.dbReadConnection.read { transaction in
|
||||
let newChats = self.storage.getAllGroupChats(with: transaction)
|
||||
let newChats = self.storage.getAllGroupChats(in: transaction)
|
||||
|
||||
// Remove any chats that don't exist in the database
|
||||
let removedChatThreadIds = self.chats.keys.filter { !newChats.keys.contains($0) }
|
||||
|
|
|
@ -26,8 +26,8 @@ public final class LokiDatabaseUtilities : NSObject {
|
|||
}
|
||||
|
||||
@objc(getAllGroupChats:)
|
||||
public static func objc_getAllGroupChats(in transaction: YapDatabaseReadTransaction) -> [String:LokiGroupChat] {
|
||||
return OWSPrimaryStorage.shared().getAllGroupChats(with: transaction)
|
||||
public static func getAllGroupChats(in transaction: YapDatabaseReadTransaction) -> [String:LokiGroupChat] {
|
||||
return OWSPrimaryStorage.shared().getAllGroupChats(in: transaction)
|
||||
}
|
||||
|
||||
@objc(getGroupChatForThreadID:transaction:)
|
||||
|
@ -36,12 +36,12 @@ public final class LokiDatabaseUtilities : NSObject {
|
|||
}
|
||||
|
||||
@objc(setGroupChat:threadID:transaction:)
|
||||
public static func objc_setGroupChat(_ groupChat: LokiGroupChat, for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
||||
public static func setGroupChat(_ groupChat: LokiGroupChat, for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
||||
return OWSPrimaryStorage.shared().setGroupChat(groupChat, for: threadID, in: transaction)
|
||||
}
|
||||
|
||||
@objc(removeGroupChatForThreadID:transaction:)
|
||||
public static func objc_removeGroupChat(for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
||||
public static func removeGroupChat(for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
||||
return OWSPrimaryStorage.shared().removeGroupChat(for: threadID, in: transaction)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
public extension OWSPrimaryStorage {
|
||||
private var groupChatCollection: String {
|
||||
return "LokiGroupChatCollection"
|
||||
}
|
||||
|
||||
// MARK: Device Links
|
||||
private func getDeviceLinkCollection(for primaryDevice: String) -> String {
|
||||
return "LokiDeviceLinkCollection-\(primaryDevice)"
|
||||
}
|
||||
|
@ -55,14 +53,18 @@ public extension OWSPrimaryStorage {
|
|||
return getDeviceLink(for: slaveHexEncodedPublicKey, in: transaction)?.master.hexEncodedPublicKey
|
||||
}
|
||||
|
||||
public func getAllGroupChats(with transaction: YapDatabaseReadTransaction) -> [String: LokiGroupChat] {
|
||||
var dict = [String: LokiGroupChat]()
|
||||
transaction.enumerateKeysAndObjects(inCollection: groupChatCollection) { (threadID, object, _) in
|
||||
if let groupChat = object as? LokiGroupChat {
|
||||
dict[threadID] = groupChat
|
||||
}
|
||||
// MARK: Group Chats
|
||||
private var groupChatCollection: String {
|
||||
return "LokiGroupChatCollection"
|
||||
}
|
||||
|
||||
public func getAllGroupChats(in transaction: YapDatabaseReadTransaction) -> [String:LokiGroupChat] {
|
||||
var result = [String:LokiGroupChat]()
|
||||
transaction.enumerateKeysAndObjects(inCollection: groupChatCollection) { threadID, object, _ in
|
||||
guard let groupChat = object as? LokiGroupChat else { return }
|
||||
result[threadID] = groupChat
|
||||
}
|
||||
return dict
|
||||
return result
|
||||
}
|
||||
|
||||
public func getGroupChat(for threadID: String, in transaction: YapDatabaseReadTransaction) -> LokiGroupChat? {
|
||||
|
|
|
@ -9,14 +9,14 @@ public final class DisplayNameUtilities : NSObject {
|
|||
}
|
||||
|
||||
private static var userDisplayName: String? {
|
||||
return OWSProfileManager.shared().localProfileName()
|
||||
return SSKEnvironment.shared.profileManager.localProfileName()!
|
||||
}
|
||||
|
||||
@objc public static func getPrivateChatDisplayName(for hexEncodedPublicKey: String) -> String? {
|
||||
if hexEncodedPublicKey == userHexEncodedPublicKey {
|
||||
return userDisplayName
|
||||
} else {
|
||||
return OWSProfileManager.shared().profileName(forRecipientId: hexEncodedPublicKey)
|
||||
return SSKEnvironment.shared.profileManager.profileName(forRecipientId: hexEncodedPublicKey)
|
||||
}
|
||||
}
|
||||
|
|
@ -503,9 +503,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
if ([message isKindOfClass:[OWSOutgoingSyncMessage class]]) {
|
||||
[recipientIds addObject:self.tsAccountManager.localNumber];
|
||||
} else if (thread.isGroupThread) {
|
||||
[_primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) {
|
||||
[self.primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction * _Nonnull transaction) {
|
||||
LKGroupChat *groupChat = [LKDatabaseUtilities getGroupChatForThreadID:thread.uniqueId transaction:transaction];
|
||||
if (groupChat != nil) { [recipientIds addObject:groupChat.server]; }
|
||||
[recipientIds addObject:groupChat.server];
|
||||
}];
|
||||
} else if ([thread isKindOfClass:[TSContactThread class]]) {
|
||||
NSString *recipientContactId = ((TSContactThread *)thread).contactIdentifier;
|
||||
|
@ -1188,12 +1188,10 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
|||
[self messageSendDidFail:messageSend deviceMessages:deviceMessages statusCode:statusCode error:error responseData:responseData];
|
||||
};
|
||||
|
||||
// Get the group chat info if we have it
|
||||
__block LKGroupChat *groupChat;
|
||||
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
groupChat = [LKDatabaseUtilities getGroupChatForThreadID:message.uniqueThreadId transaction: transaction];
|
||||
}];
|
||||
|
||||
if (groupChat != nil) {
|
||||
NSString *userHexEncodedPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
|
||||
NSString *displayName = SSKEnvironment.shared.profileManager.localProfileName;
|
||||
|
|
|
@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (OWSAES256Key *)localProfileKey;
|
||||
|
||||
- (nullable NSString *)localProfileName;
|
||||
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId;
|
||||
|
||||
- (nullable NSData *)profileKeyDataForRecipientId:(NSString *)recipientId;
|
||||
- (void)setProfileKeyData:(NSData *)profileKeyData forRecipientId:(NSString *)recipientId;
|
||||
|
|
Loading…
Reference in New Issue