Cleanup: simplify migration, remove unused code

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent b039fdd276
commit a9e7c5e879

@ -6,13 +6,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface OWSLinkedDeviceReadReceipt ()
// FIXME remove this `timestamp` property and migrate in initWithCoder.
@property (nonatomic, readonly) uint64_t timestamp;
@end
@implementation OWSLinkedDeviceReadReceipt
- (instancetype)initWithSenderId:(NSString *)senderId
@ -42,18 +35,20 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
// renamed timestamp -> messageIdTimestamp
if (!_messageIdTimestamp) {
// FIXME to remove this legacy `timestamp` property, we need to figure out exactly how MTL encodes uint64_t.
// e.g. can we just do something like: `((NSNumber *)[coder decodeObjectForKey:@"timestamp"]).unsignedLongLong`
_messageIdTimestamp = _timestamp;
NSNumber *_Nullable legacyTimestamp = (NSNumber *)[coder decodeObjectForKey:@"timestamp"];
OWSAssert(legacyTimestamp.unsignedLongLongValue > 0);
_messageIdTimestamp = legacyTimestamp.unsignedLongLongValue;
}
// For legacy early LinkedDeviceReadReceipts, before we were tracking read time, we assume the message was read as
// soon as it was sent. This is always going to be at least a little earlier than it was actually read, but we have
// nothing better to choose, and by the very fact that we're receiving a read receipt, we have good reason to
// believe they read the message on the other device.
// For legacy objects, before we were tracking read time, use the original messages "sent" timestamp
// as the local read time. This will always be at least a little bit earlier than the message was
// actually read, but it's the safer assumption. At worst we'll delete the message from this device
// earlier than the user expects, but this shouldn't be terrible because we know they've read the
// message on the other device. Keep in mind this *only* affects "early" read receipts.
if (_readTimestamp == 0) {
_readTimestamp = _timestamp;
_readTimestamp = _messageIdTimestamp;
}
return self;

@ -17,7 +17,6 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
//+ (void)setExpirationsForThread:(TSThread *)thread;
- (void)startAnyExpirationForMessage:(TSMessage *)message
expirationStartedAt:(uint64_t)expirationStartedAt
transaction:(YapDatabaseReadWriteTransaction *_Nonnull)transaction;

@ -210,28 +210,6 @@ void AssertIsOnDisappearingMessagesQueue()
}];
}
//- (void)setExpirationsForThread:(TSThread *)thread transaction:(YapDatabaseReadWriteTransaction *)transaction
//{
// OWSBackgroundTask *_Nullable backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
//
// uint64_t now = [NSDate ows_millisecondTimeStamp];
// [self.disappearingMessagesFinder
// enumerateUnstartedExpiringMessagesInThread:thread
// block:^(TSMessage *_Nonnull message) {
// DDLogWarn(@"%@ Starting expiring message which should have already "
// @"been started.",
// self.logTag);
// // specify "now" in case D.M. have since been disabled, but we have
// // existing unstarted expiring messages that still need to expire.
// [self setExpirationForMessage:message
// expirationStartedAt:now
// transaction:transaction];
// }
// transaction:transaction];
//
// backgroundTask = nil;
//}
- (void)becomeConsistentWithConfigurationForMessage:(TSMessage *)message
contactsManager:(id<ContactsManagerProtocol>)contactsManager
transaction:(YapDatabaseReadWriteTransaction *)transaction

Loading…
Cancel
Save