Debug
This commit is contained in:
parent
4d5ca1ce66
commit
ea3da42faf
|
@ -717,7 +717,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *userID = [[text substringWithRange:match1.range] stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@""];
|
||||
NSUInteger matchEnd;
|
||||
if ([knownUserIDs containsObject:userID]) {
|
||||
NSString *userDisplayName = [Environment.shared.contactsManager attributedContactOrProfileNameForPhoneIdentifier:userID primaryFont:font secondaryFont:font].string;
|
||||
__block NSString *userDisplayName = [Environment.shared.contactsManager attributedContactOrProfileNameForPhoneIdentifier:userID primaryFont:font secondaryFont:font].string;
|
||||
if ([userDisplayName isEqual:userID]) {
|
||||
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
NSString *collection = [NSString stringWithFormat:@"%@.%llu", LKGroupChatAPI.publicChatServer, LKGroupChatAPI.publicChatServerID];
|
||||
NSString *userDisplayNameCandidate = [transaction objectForKey:userID inCollection:collection];
|
||||
if (userDisplayNameCandidate != nil) {
|
||||
userDisplayName = userDisplayNameCandidate;
|
||||
}
|
||||
}];
|
||||
}
|
||||
text = [text stringByReplacingCharactersInRange:match1.range withString:[NSString stringWithFormat:@"@%@", userDisplayName]];
|
||||
[mentions addObject:[NSValue valueWithRange:NSMakeRange(match1.range.location, userDisplayName.length + 1)]];
|
||||
matchEnd = match1.range.location + userDisplayName.length;
|
||||
|
|
|
@ -524,7 +524,7 @@ typedef enum : NSUInteger {
|
|||
userInfo:nil
|
||||
repeats:YES];
|
||||
|
||||
[LKAPI populateUserIDCacheIfNeededFor:thread.uniqueId];
|
||||
[LKAPI populateUserIDCacheIfNeededFor:thread.uniqueId in:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
|
|
@ -306,10 +306,10 @@ public final class LokiAPI : NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
@objc public static func populateUserIDCacheIfNeeded(for threadID: String) {
|
||||
@objc public static func populateUserIDCacheIfNeeded(for threadID: String, in transaction: YapDatabaseReadWriteTransaction? = nil) {
|
||||
guard userIDCache[threadID] == nil else { return }
|
||||
var result: Set<String> = []
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
func populate(in transaction: YapDatabaseReadWriteTransaction) {
|
||||
guard let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) else { return }
|
||||
let interactions = transaction.ext(TSMessageDatabaseViewExtensionName) as! YapDatabaseViewTransaction
|
||||
interactions.enumerateKeysAndObjects(inGroup: threadID) { _, _, object, index, _ in
|
||||
|
@ -317,6 +317,13 @@ public final class LokiAPI : NSObject {
|
|||
result.insert(message.authorId)
|
||||
}
|
||||
}
|
||||
if let transaction = transaction {
|
||||
populate(in: transaction)
|
||||
} else {
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
populate(in: transaction)
|
||||
}
|
||||
}
|
||||
result.insert(userHexEncodedPublicKey)
|
||||
userIDCache[threadID] = result
|
||||
}
|
||||
|
|
|
@ -1412,9 +1412,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
(unsigned long)timestamp);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
// Loki: Cache the user hex encoded public key (for mentions)
|
||||
[LKAPI populateUserIDCacheIfNeededFor:oldGroupThread.uniqueId];
|
||||
[LKAPI populateUserIDCacheIfNeededFor:oldGroupThread.uniqueId in:transaction];
|
||||
[LKAPI cache:incomingMessage.authorId for:oldGroupThread.uniqueId];
|
||||
|
||||
[self finalizeIncomingMessage:incomingMessage
|
||||
|
|
Loading…
Reference in New Issue