mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Respond to CR.
// FREEBIE
This commit is contained in:
parent
ffe44e68be
commit
ee13084d5c
9 changed files with 50 additions and 48 deletions
|
@ -85,7 +85,7 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
|
|||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleMessageRead:)
|
||||
name:kMessageMarkedAsReadNotification
|
||||
name:kIncomingMessageMarkedAsReadNotification
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
|
|
|
@ -13,8 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initWithSenderId:(NSString *)senderId timestamp:(uint64_t)timestamp;
|
||||
|
||||
+ (nullable OWSLinkedDeviceReadReceipt *)linkedDeviceReadReceiptWithSenderId:(NSString *)senderId
|
||||
timestamp:(uint64_t)timestamp;
|
||||
+ (nullable OWSLinkedDeviceReadReceipt *)findLinkedDeviceReadReceiptWithSenderId:(NSString *)senderId
|
||||
timestamp:(uint64_t)timestamp
|
||||
transaction:
|
||||
(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -27,13 +27,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
OWSAssert(senderId.length > 0 && timestamp > 0);
|
||||
|
||||
return [NSString stringWithFormat:@"%@ %llu", senderId, timestamp];
|
||||
return [NSString stringWithFormat:@"%@-%llu", senderId, timestamp];
|
||||
}
|
||||
|
||||
+ (nullable OWSLinkedDeviceReadReceipt *)linkedDeviceReadReceiptWithSenderId:(NSString *)senderId
|
||||
timestamp:(uint64_t)timestamp
|
||||
+ (nullable OWSLinkedDeviceReadReceipt *)findLinkedDeviceReadReceiptWithSenderId:(NSString *)senderId
|
||||
timestamp:(uint64_t)timestamp
|
||||
transaction:
|
||||
(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
return [OWSLinkedDeviceReadReceipt fetchObjectWithUniqueID:[self uniqueIdForSenderId:senderId timestamp:timestamp]];
|
||||
OWSAssert(transaction);
|
||||
|
||||
return [OWSLinkedDeviceReadReceipt fetchObjectWithUniqueID:[self uniqueIdForSenderId:senderId timestamp:timestamp]
|
||||
transaction:transaction];
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
|
|
@ -113,7 +113,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
sentAt:transcript.expirationStartedAt
|
||||
transaction:transaction];
|
||||
|
||||
[self.readReceiptManager updateOutgoingMessageFromLinkedDevice:outgoingMessage transaction:transaction];
|
||||
[self.readReceiptManager applyEarlyReadReceiptsForOutgoingMessageFromLinkedDevice:outgoingMessage
|
||||
transaction:transaction];
|
||||
|
||||
[attachmentsProcessor
|
||||
fetchAttachmentsForMessage:outgoingMessage
|
||||
|
|
|
@ -898,8 +898,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
if (thread && incomingMessage) {
|
||||
// In case we already have a read receipt for this new message (this happens sometimes).
|
||||
[OWSReadReceiptManager.sharedManager updateIncomingMessage:incomingMessage
|
||||
transaction:transaction];
|
||||
[OWSReadReceiptManager.sharedManager applyEarlyReadReceiptsForIncomingMessage:incomingMessage
|
||||
transaction:transaction];
|
||||
|
||||
// TODO: Do this synchronously.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
|
|
@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@class TSThread;
|
||||
@class YapDatabaseReadWriteTransaction;
|
||||
|
||||
extern NSString *const kMessageMarkedAsReadNotification;
|
||||
extern NSString *const kIncomingMessageMarkedAsReadNotification;
|
||||
|
||||
// There are four kinds of read receipts:
|
||||
//
|
||||
|
@ -44,16 +44,16 @@ extern NSString *const kMessageMarkedAsReadNotification;
|
|||
- (void)processReadReceiptsFromRecipient:(OWSSignalServiceProtosReceiptMessage *)receiptMessage
|
||||
envelope:(OWSSignalServiceProtosEnvelope *)envelope;
|
||||
|
||||
- (void)updateOutgoingMessageFromLinkedDevice:(TSOutgoingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)applyEarlyReadReceiptsForOutgoingMessageFromLinkedDevice:(TSOutgoingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
#pragma mark - Linked Device Read Receipts
|
||||
|
||||
- (void)processReadReceiptsFromLinkedDevice:(NSArray<OWSSignalServiceProtosSyncMessageRead *> *)readReceiptProtos
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
- (void)updateIncomingMessage:(TSIncomingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
- (void)applyEarlyReadReceiptsForIncomingMessage:(TSIncomingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
#pragma mark - Locally Read
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSString *const kMessageMarkedAsReadNotification = @"kMessageMarkedAsReadNotification";
|
||||
NSString *const kIncomingMessageMarkedAsReadNotification = @"kIncomingMessageMarkedAsReadNotification";
|
||||
|
||||
@interface TSRecipientReadReceipt : TSYapDatabaseObject
|
||||
|
||||
|
@ -315,8 +315,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
|
||||
OWSLinkedDeviceReadReceipt *_Nullable oldReadReceipt = self.toLinkedDevicesReadReceiptMap[threadUniqueId];
|
||||
if (oldReadReceipt && oldReadReceipt.timestamp > newReadReceipt.timestamp) {
|
||||
// If there's an existing read receipt for the same thread with
|
||||
// a newer timestamp, discard the new read receipt.
|
||||
// If there's an existing "linked device" read receipt for the same thread with
|
||||
// a newer timestamp, discard this "linked device" read receipt.
|
||||
DDLogVerbose(@"%@ Ignoring redundant read receipt for linked devices.", self.tag);
|
||||
} else {
|
||||
DDLogVerbose(@"%@ Enqueuing read receipt for linked devices.", self.tag);
|
||||
|
@ -389,8 +389,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
});
|
||||
}
|
||||
|
||||
- (void)updateOutgoingMessageFromLinkedDevice:(TSOutgoingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
- (void)applyEarlyReadReceiptsForOutgoingMessageFromLinkedDevice:(TSOutgoingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssert(message);
|
||||
OWSAssert(transaction);
|
||||
|
@ -414,8 +414,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
|
||||
#pragma mark - Linked Device Read Receipts
|
||||
|
||||
- (void)updateIncomingMessage:(TSIncomingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
- (void)applyEarlyReadReceiptsForIncomingMessage:(TSIncomingMessage *)message
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssert(message);
|
||||
OWSAssert(transaction);
|
||||
|
@ -427,19 +427,18 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
return;
|
||||
}
|
||||
|
||||
OWSLinkedDeviceReadReceipt *_Nullable readReceipt = [OWSLinkedDeviceReadReceipt linkedDeviceReadReceiptWithSenderId:senderId
|
||||
timestamp:timestamp];
|
||||
OWSLinkedDeviceReadReceipt *_Nullable readReceipt =
|
||||
[OWSLinkedDeviceReadReceipt findLinkedDeviceReadReceiptWithSenderId:senderId
|
||||
timestamp:timestamp
|
||||
transaction:transaction];
|
||||
if (!readReceipt) {
|
||||
return;
|
||||
}
|
||||
[message markAsReadWithTransaction:transaction sendReadReceipt:NO updateExpiration:YES];
|
||||
[readReceipt removeWithTransaction:transaction];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kMessageMarkedAsReadNotification
|
||||
object:message];
|
||||
});
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:kIncomingMessageMarkedAsReadNotification
|
||||
object:message];
|
||||
}
|
||||
|
||||
- (void)processReadReceiptsFromLinkedDevice:(NSArray<OWSSignalServiceProtosSyncMessageRead *> *)readReceiptProtos
|
||||
|
@ -545,11 +544,8 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|||
|
||||
if ([possiblyRead isKindOfClass:[TSIncomingMessage class]]) {
|
||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)possiblyRead;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kMessageMarkedAsReadNotification
|
||||
object:incomingMessage];
|
||||
});
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:kIncomingMessageMarkedAsReadNotification
|
||||
object:incomingMessage];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,13 +168,13 @@ static const CGFloat kAttachmentUploadProgressTheta = 0.001f;
|
|||
|
||||
- (void)fireProgressNotification:(CGFloat)progress attachmentId:(NSString *)attachmentId
|
||||
{
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter postNotificationNameAsync:kAttachmentUploadProgressNotification
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kAttachmentUploadProgressKey : @(progress),
|
||||
kAttachmentUploadAttachmentIDKey : attachmentId
|
||||
}];
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter postNotificationNameAsync:kAttachmentUploadProgressNotification
|
||||
object:nil
|
||||
userInfo:@{
|
||||
kAttachmentUploadProgressKey : @(progress),
|
||||
kAttachmentUploadAttachmentIDKey : attachmentId
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
|
|
@ -442,12 +442,10 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
|
||||
[TSDatabaseView.sharedInstance setAreAllAsyncRegistrationsComplete];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_DatabaseViewRegistrationComplete
|
||||
object:nil
|
||||
userInfo:nil];
|
||||
});
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationNameAsync:kNSNotificationName_DatabaseViewRegistrationComplete
|
||||
object:nil
|
||||
userInfo:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue