Respond to CR.

This commit is contained in:
Matthew Chen 2019-10-10 11:44:54 -03:00
parent 3f2a4109d7
commit 91dab4e9cd
58 changed files with 70 additions and 127 deletions

View File

@ -75,8 +75,8 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
// Note that we enumerate _twice_ (archived & non-archived)
let readCount = 10
startMeasuring()
write { transaction in
self.startMeasuring()
for _ in 0..<readCount {
var observedCount = 0
do {
@ -91,8 +91,8 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
let expectedCount = isArchived ? expectedArchivedCount : expectedUnarchivedCount
XCTAssertEqual(expectedCount, observedCount)
}
self.stopMeasuring()
}
stopMeasuring()
// cleanup for next iteration
write { transaction in
@ -124,7 +124,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
// .empty
let contactThread = ContactThreadFactory().create()
XCTAssertFalse(contactThread.shouldThreadBeVisible)
XCTAssertNil(contactThread.archivedAsOfMessageSortId)
XCTAssertFalse(contactThread.isArchived)
if threadType == .empty {
return contactThread
}
@ -135,7 +135,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
write { transaction in
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertFalse(latestThread.shouldThreadBeVisible)
XCTAssertNil(latestThread.archivedAsOfMessageSortId)
XCTAssertFalse(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}
@ -149,7 +149,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertTrue(latestThread.shouldThreadBeVisible)
XCTAssertNil(latestThread.archivedAsOfMessageSortId)
XCTAssertFalse(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}
@ -162,7 +162,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
write { transaction in
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertTrue(latestThread.shouldThreadBeVisible)
XCTAssertNil(latestThread.archivedAsOfMessageSortId)
XCTAssertFalse(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}
@ -171,7 +171,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertTrue(latestThread.shouldThreadBeVisible)
XCTAssertNotNil(latestThread.archivedAsOfMessageSortId)
XCTAssertTrue(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}
@ -184,7 +184,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
write { transaction in
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertTrue(latestThread.shouldThreadBeVisible)
XCTAssertNotNil(latestThread.archivedAsOfMessageSortId)
XCTAssertTrue(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}
@ -194,7 +194,7 @@ class ThreadFinderPerformanceTest: PerformanceBaseTest {
if let latestThread = TSThread.anyFetch(uniqueId: contactThread.uniqueId, transaction: transaction) {
XCTAssertTrue(latestThread.shouldThreadBeVisible)
// XCTAssertNil(latestThread.archivedAsOfMessageSortId)
XCTAssertFalse(latestThread.isArchived)
} else {
XCTFail("Missing thread.")
}

View File

@ -551,7 +551,6 @@ class OWSContactQuerySerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .contactQuery

View File

@ -550,7 +550,6 @@ class OWSDisappearingMessagesConfigurationSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .disappearingMessagesConfiguration

View File

@ -579,7 +579,6 @@ class SignalAccountSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .signalAccount

View File

@ -565,7 +565,6 @@ class SignalRecipientSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .signalRecipient

View File

@ -29,9 +29,9 @@ public struct ThreadRecord: SDSRecord {
// Base class properties
public let archivalDate: Double?
public let archivedAsOfMessageSortId: UInt64?
public let conversationColorName: String
public let creationDate: Double?
public let isArchived: Bool
public let isArchivedByLegacyTimestampForSorting: Bool
public let lastInteractionSortId: Int64
public let lastMessageDate: Double?
@ -51,9 +51,9 @@ public struct ThreadRecord: SDSRecord {
case recordType
case uniqueId
case archivalDate
case archivedAsOfMessageSortId
case conversationColorName
case creationDate
case isArchived
case isArchivedByLegacyTimestampForSorting
case lastInteractionSortId
case lastMessageDate
@ -92,9 +92,9 @@ public extension ThreadRecord {
recordType = row[1]
uniqueId = row[2]
archivalDate = row[3]
archivedAsOfMessageSortId = row[4]
conversationColorName = row[5]
creationDate = row[6]
conversationColorName = row[4]
creationDate = row[5]
isArchived = row[6]
isArchivedByLegacyTimestampForSorting = row[7]
lastInteractionSortId = row[8]
lastMessageDate = row[9]
@ -139,10 +139,10 @@ extension TSThread {
let uniqueId: String = record.uniqueId
let archivalDateInterval: Double? = record.archivalDate
let archivalDate: Date? = SDSDeserialization.optionalDoubleAsDate(archivalDateInterval, name: "archivalDate")
let archivedAsOfMessageSortId: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.archivedAsOfMessageSortId, name: "archivedAsOfMessageSortId", conversion: { NSNumber(value: $0) })
let conversationColorName: ConversationColorName = ConversationColorName(rawValue: record.conversationColorName)
let creationDateInterval: Double? = record.creationDate
let creationDate: Date? = SDSDeserialization.optionalDoubleAsDate(creationDateInterval, name: "creationDate")
let isArchived: Bool = record.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = record.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = record.lastInteractionSortId
let lastMessageDateInterval: Double? = record.lastMessageDate
@ -160,9 +160,9 @@ extension TSThread {
return TSContactThread(grdbId: recordId,
uniqueId: uniqueId,
archivalDate: archivalDate,
archivedAsOfMessageSortId: archivedAsOfMessageSortId,
conversationColorName: conversationColorName,
creationDate: creationDate,
isArchived: isArchived,
isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting,
lastInteractionSortId: lastInteractionSortId,
lastMessageDate: lastMessageDate,
@ -180,10 +180,10 @@ extension TSThread {
let uniqueId: String = record.uniqueId
let archivalDateInterval: Double? = record.archivalDate
let archivalDate: Date? = SDSDeserialization.optionalDoubleAsDate(archivalDateInterval, name: "archivalDate")
let archivedAsOfMessageSortId: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.archivedAsOfMessageSortId, name: "archivedAsOfMessageSortId", conversion: { NSNumber(value: $0) })
let conversationColorName: ConversationColorName = ConversationColorName(rawValue: record.conversationColorName)
let creationDateInterval: Double? = record.creationDate
let creationDate: Date? = SDSDeserialization.optionalDoubleAsDate(creationDateInterval, name: "creationDate")
let isArchived: Bool = record.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = record.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = record.lastInteractionSortId
let lastMessageDateInterval: Double? = record.lastMessageDate
@ -199,9 +199,9 @@ extension TSThread {
return TSGroupThread(grdbId: recordId,
uniqueId: uniqueId,
archivalDate: archivalDate,
archivedAsOfMessageSortId: archivedAsOfMessageSortId,
conversationColorName: conversationColorName,
creationDate: creationDate,
isArchived: isArchived,
isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting,
lastInteractionSortId: lastInteractionSortId,
lastMessageDate: lastMessageDate,
@ -216,10 +216,10 @@ extension TSThread {
let uniqueId: String = record.uniqueId
let archivalDateInterval: Double? = record.archivalDate
let archivalDate: Date? = SDSDeserialization.optionalDoubleAsDate(archivalDateInterval, name: "archivalDate")
let archivedAsOfMessageSortId: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.archivedAsOfMessageSortId, name: "archivedAsOfMessageSortId", conversion: { NSNumber(value: $0) })
let conversationColorName: ConversationColorName = ConversationColorName(rawValue: record.conversationColorName)
let creationDateInterval: Double? = record.creationDate
let creationDate: Date? = SDSDeserialization.optionalDoubleAsDate(creationDateInterval, name: "creationDate")
let isArchived: Bool = record.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = record.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = record.lastInteractionSortId
let lastMessageDateInterval: Double? = record.lastMessageDate
@ -233,9 +233,9 @@ extension TSThread {
return TSThread(grdbId: recordId,
uniqueId: uniqueId,
archivalDate: archivalDate,
archivedAsOfMessageSortId: archivedAsOfMessageSortId,
conversationColorName: conversationColorName,
creationDate: creationDate,
isArchived: isArchived,
isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting,
lastInteractionSortId: lastInteractionSortId,
lastMessageDate: lastMessageDate,
@ -294,9 +294,9 @@ extension TSThreadSerializer {
static let uniqueIdColumn = SDSColumnMetadata(columnName: "uniqueId", columnType: .unicodeString, isUnique: true, columnIndex: 2)
// Base class properties
static let archivalDateColumn = SDSColumnMetadata(columnName: "archivalDate", columnType: .double, isOptional: true, columnIndex: 3)
static let archivedAsOfMessageSortIdColumn = SDSColumnMetadata(columnName: "archivedAsOfMessageSortId", columnType: .int64, isOptional: true, columnIndex: 4)
static let conversationColorNameColumn = SDSColumnMetadata(columnName: "conversationColorName", columnType: .unicodeString, columnIndex: 5)
static let creationDateColumn = SDSColumnMetadata(columnName: "creationDate", columnType: .double, isOptional: true, columnIndex: 6)
static let conversationColorNameColumn = SDSColumnMetadata(columnName: "conversationColorName", columnType: .unicodeString, columnIndex: 4)
static let creationDateColumn = SDSColumnMetadata(columnName: "creationDate", columnType: .double, isOptional: true, columnIndex: 5)
static let isArchivedColumn = SDSColumnMetadata(columnName: "isArchived", columnType: .int, columnIndex: 6)
static let isArchivedByLegacyTimestampForSortingColumn = SDSColumnMetadata(columnName: "isArchivedByLegacyTimestampForSorting", columnType: .int, columnIndex: 7)
static let lastInteractionSortIdColumn = SDSColumnMetadata(columnName: "lastInteractionSortId", columnType: .int64, columnIndex: 8)
static let lastMessageDateColumn = SDSColumnMetadata(columnName: "lastMessageDate", columnType: .double, isOptional: true, columnIndex: 9)
@ -319,9 +319,9 @@ extension TSThreadSerializer {
recordTypeColumn,
uniqueIdColumn,
archivalDateColumn,
archivedAsOfMessageSortIdColumn,
conversationColorNameColumn,
creationDateColumn,
isArchivedColumn,
isArchivedByLegacyTimestampForSortingColumn,
lastInteractionSortIdColumn,
lastMessageDateColumn,
@ -723,7 +723,6 @@ class TSThreadSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .thread
@ -731,9 +730,9 @@ class TSThreadSerializer: SDSSerializer {
// Base class properties
let archivalDate: Double? = archiveOptionalDate(model.archivalDate)
let archivedAsOfMessageSortId: UInt64? = archiveOptionalNSNumber(model.archivedAsOfMessageSortId, conversion: { $0.uint64Value })
let conversationColorName: String = model.conversationColorName.rawValue
let creationDate: Double? = archiveOptionalDate(model.creationDate)
let isArchived: Bool = model.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = model.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = model.lastInteractionSortId
let lastMessageDate: Double? = archiveOptionalDate(model.lastMessageDate)
@ -748,6 +747,6 @@ class TSThreadSerializer: SDSSerializer {
let groupModel: Data? = nil
let hasDismissedOffers: Bool? = nil
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, archivedAsOfMessageSortId: archivedAsOfMessageSortId, conversationColorName: conversationColorName, creationDate: creationDate, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, conversationColorName: conversationColorName, creationDate: creationDate, isArchived: isArchived, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
}
}

View File

@ -41,6 +41,7 @@ extern ConversationColorName const kConversationColorName_Default;
@property (nonatomic, readonly, nullable) NSDate *creationDate;
@property (nonatomic, readonly) BOOL isArchivedByLegacyTimestampForSorting;
@property (nonatomic, readonly) int64_t rowId;
@property (nonatomic, readonly) BOOL isArchived;
// zero if thread has never had an interaction.
// The corresponding interaction may have been deleted.
@ -55,9 +56,9 @@ extern ConversationColorName const kConversationColorName_Default;
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -65,7 +66,7 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
mutedUntilDate:(nullable NSDate *)mutedUntilDate
rowId:(int64_t)rowId
shouldThreadBeVisible:(BOOL)shouldThreadBeVisible
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:archivedAsOfMessageSortId:conversationColorName:creationDate:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:));
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:conversationColorName:creationDate:isArchived:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:));
// clang-format on
@ -128,15 +129,12 @@ NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:archivedAsOfMessageSortId:conver
* @param lastMessage Latest Interaction to take into consideration.
* @param transaction Database transaction.
*/
- (void)updateWithLastMessage:(TSInteraction *)lastMessage transaction:(SDSAnyWriteTransaction *)transaction;
- (void)updateWithLastMessage:(TSInteraction *)lastMessage
wasMessageInserted:(BOOL)wasMessageInserted
transaction:(SDSAnyWriteTransaction *)transaction;
#pragma mark Archival
/**
* @return YES if no new messages have been sent or received since the thread was last archived.
*/
- (BOOL)isArchivedWithTransaction:(SDSAnyReadTransaction *)transaction;
/**
* Archives a thread
*

View File

@ -43,7 +43,7 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
@property (nonatomic, nullable) NSDate *creationDate;
@property (nonatomic) NSString *conversationColorName;
@property (nonatomic, nullable) NSNumber *archivedAsOfMessageSortId;
@property (nonatomic) BOOL isArchived;
@property (nonatomic, copy, nullable) NSString *messageDraft;
@property (atomic, nullable) NSDate *mutedUntilDate;
@ -107,9 +107,9 @@ ConversationColorName const kConversationColorName_Default = ConversationColorNa
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -126,9 +126,9 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
}
_archivalDate = archivalDate;
_archivedAsOfMessageSortId = archivedAsOfMessageSortId;
_conversationColorName = conversationColorName;
_creationDate = creationDate;
_isArchived = isArchived;
_isArchivedByLegacyTimestampForSorting = isArchivedByLegacyTimestampForSorting;
_lastInteractionSortId = lastInteractionSortId;
_lastMessageDate = lastMessageDate;
@ -188,6 +188,11 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
_isArchivedByLegacyTimestampForSorting =
[self.class legacyIsArchivedWithLastMessageDate:lastMessageDate archivalDate:archivalDate];
if ([coder decodeObjectForKey:@"archivedAsOfMessageSortId"] != nil) {
OWSAssertDebug(!_isArchived);
_isArchived = YES;
}
return self;
}
@ -428,7 +433,9 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
return YES;
}
- (void)updateWithLastMessage:(TSInteraction *)lastMessage transaction:(SDSAnyWriteTransaction *)transaction
- (void)updateWithLastMessage:(TSInteraction *)lastMessage
wasMessageInserted:(BOOL)wasMessageInserted
transaction:(SDSAnyWriteTransaction *)transaction
{
OWSAssertDebug(lastMessage);
OWSAssertDebug(transaction);
@ -450,18 +457,16 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
}
}
BOOL needsToMarkAsVisible = !self.shouldThreadBeVisible;
BOOL needsToClearArchived = (self.archivedAsOfMessageSortId != nil
&& self.archivedAsOfMessageSortId.unsignedLongLongValue < messageSortId);
BOOL needsToClearArchived = self.isArchived && wasMessageInserted;
BOOL needsToUpdateLastInteractionSortId = messageSortId > self.lastInteractionSortId;
if (needsToMarkAsVisible || needsToClearArchived || needsToUpdateLastInteractionSortId) {
[self anyUpdateWithTransaction:transaction
block:^(TSThread *thread) {
thread.shouldThreadBeVisible = YES;
thread.lastInteractionSortId = MAX(thread.lastInteractionSortId, messageSortId);
if (thread.archivedAsOfMessageSortId != nil
&& thread.archivedAsOfMessageSortId.unsignedLongLongValue < messageSortId) {
if (thread.isArchived && wasMessageInserted) {
// No longer archived.
thread.archivedAsOfMessageSortId = nil;
thread.isArchived = NO;
}
}];
} else {
@ -501,17 +506,6 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
#pragma mark - Archival
- (BOOL)isArchivedWithTransaction:(SDSAnyReadTransaction *)transaction
{
if (!self.archivedAsOfMessageSortId) {
return NO;
}
TSInteraction *_Nullable latestInteraction = [self lastInteractionForInboxWithTransaction:transaction];
uint64_t latestSortIdForInbox = latestInteraction ? latestInteraction.sortId : 0;
return self.archivedAsOfMessageSortId.unsignedLongLongValue >= latestSortIdForInbox;
}
+ (BOOL)legacyIsArchivedWithLastMessageDate:(nullable NSDate *)lastMessageDate
archivalDate:(nullable NSDate *)archivalDate
{
@ -530,8 +524,7 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
{
[self anyUpdateWithTransaction:transaction
block:^(TSThread *thread) {
uint64_t latestId = [InteractionFinder mostRecentSortIdWithTransaction:transaction];
thread.archivedAsOfMessageSortId = @(latestId);
thread.isArchived = YES;
}];
[self markAllAsReadWithTransaction:transaction];
@ -541,7 +534,7 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
{
[self anyUpdateWithTransaction:transaction
block:^(TSThread *thread) {
thread.archivedAsOfMessageSortId = nil;
thread.isArchived = NO;
}];
}

View File

@ -55,7 +55,6 @@ class TSContactThreadSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .contactThread
@ -63,9 +62,9 @@ class TSContactThreadSerializer: SDSSerializer {
// Base class properties
let archivalDate: Double? = archiveOptionalDate(model.archivalDate)
let archivedAsOfMessageSortId: UInt64? = archiveOptionalNSNumber(model.archivedAsOfMessageSortId, conversion: { $0.uint64Value })
let conversationColorName: String = model.conversationColorName.rawValue
let creationDate: Double? = archiveOptionalDate(model.creationDate)
let isArchived: Bool = model.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = model.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = model.lastInteractionSortId
let lastMessageDate: Double? = archiveOptionalDate(model.lastMessageDate)
@ -80,6 +79,6 @@ class TSContactThreadSerializer: SDSSerializer {
let groupModel: Data? = nil
let hasDismissedOffers: Bool? = model.hasDismissedOffers
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, archivedAsOfMessageSortId: archivedAsOfMessageSortId, conversationColorName: conversationColorName, creationDate: creationDate, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, conversationColorName: conversationColorName, creationDate: creationDate, isArchived: isArchived, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
}
}

View File

@ -19,9 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -33,7 +33,7 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
contactThreadSchemaVersion:(NSUInteger)contactThreadSchemaVersion
contactUUID:(nullable NSString *)contactUUID
hasDismissedOffers:(BOOL)hasDismissedOffers
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:archivedAsOfMessageSortId:conversationColorName:creationDate:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:contactPhoneNumber:contactThreadSchemaVersion:contactUUID:hasDismissedOffers:));
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:conversationColorName:creationDate:isArchived:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:contactPhoneNumber:contactThreadSchemaVersion:contactUUID:hasDismissedOffers:));
// clang-format on

View File

@ -52,9 +52,9 @@ NSUInteger const TSContactThreadSchemaVersion = 1;
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -70,9 +70,9 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
self = [super initWithGrdbId:grdbId
uniqueId:uniqueId
archivalDate:archivalDate
archivedAsOfMessageSortId:archivedAsOfMessageSortId
conversationColorName:conversationColorName
creationDate:creationDate
isArchived:isArchived
isArchivedByLegacyTimestampForSorting:isArchivedByLegacyTimestampForSorting
lastInteractionSortId:lastInteractionSortId
lastMessageDate:lastMessageDate

View File

@ -55,7 +55,6 @@ class TSGroupThreadSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .groupThread
@ -63,9 +62,9 @@ class TSGroupThreadSerializer: SDSSerializer {
// Base class properties
let archivalDate: Double? = archiveOptionalDate(model.archivalDate)
let archivedAsOfMessageSortId: UInt64? = archiveOptionalNSNumber(model.archivedAsOfMessageSortId, conversion: { $0.uint64Value })
let conversationColorName: String = model.conversationColorName.rawValue
let creationDate: Double? = archiveOptionalDate(model.creationDate)
let isArchived: Bool = model.isArchived
let isArchivedByLegacyTimestampForSorting: Bool = model.isArchivedByLegacyTimestampForSorting
let lastInteractionSortId: Int64 = model.lastInteractionSortId
let lastMessageDate: Double? = archiveOptionalDate(model.lastMessageDate)
@ -80,6 +79,6 @@ class TSGroupThreadSerializer: SDSSerializer {
let groupModel: Data? = optionalArchive(model.groupModel)
let hasDismissedOffers: Bool? = nil
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, archivedAsOfMessageSortId: archivedAsOfMessageSortId, conversationColorName: conversationColorName, creationDate: creationDate, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
return ThreadRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, archivalDate: archivalDate, conversationColorName: conversationColorName, creationDate: creationDate, isArchived: isArchived, isArchivedByLegacyTimestampForSorting: isArchivedByLegacyTimestampForSorting, lastInteractionSortId: lastInteractionSortId, lastMessageDate: lastMessageDate, messageDraft: messageDraft, mutedUntilDate: mutedUntilDate, shouldThreadBeVisible: shouldThreadBeVisible, contactPhoneNumber: contactPhoneNumber, contactThreadSchemaVersion: contactThreadSchemaVersion, contactUUID: contactUUID, groupModel: groupModel, hasDismissedOffers: hasDismissedOffers)
}
}

View File

@ -25,9 +25,9 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -36,7 +36,7 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
rowId:(int64_t)rowId
shouldThreadBeVisible:(BOOL)shouldThreadBeVisible
groupModel:(TSGroupModel *)groupModel
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:archivedAsOfMessageSortId:conversationColorName:creationDate:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:groupModel:));
NS_SWIFT_NAME(init(grdbId:uniqueId:archivalDate:conversationColorName:creationDate:isArchived:isArchivedByLegacyTimestampForSorting:lastInteractionSortId:lastMessageDate:messageDraft:mutedUntilDate:rowId:shouldThreadBeVisible:groupModel:));
// clang-format on

View File

@ -26,9 +26,9 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
- (instancetype)initWithGrdbId:(int64_t)grdbId
uniqueId:(NSString *)uniqueId
archivalDate:(nullable NSDate *)archivalDate
archivedAsOfMessageSortId:(nullable NSNumber *)archivedAsOfMessageSortId
conversationColorName:(ConversationColorName)conversationColorName
creationDate:(nullable NSDate *)creationDate
isArchived:(BOOL)isArchived
isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSorting
lastInteractionSortId:(int64_t)lastInteractionSortId
lastMessageDate:(nullable NSDate *)lastMessageDate
@ -41,9 +41,9 @@ isArchivedByLegacyTimestampForSorting:(BOOL)isArchivedByLegacyTimestampForSortin
self = [super initWithGrdbId:grdbId
uniqueId:uniqueId
archivalDate:archivalDate
archivedAsOfMessageSortId:archivedAsOfMessageSortId
conversationColorName:conversationColorName
creationDate:creationDate
isArchived:isArchived
isArchivedByLegacyTimestampForSorting:isArchivedByLegacyTimestampForSorting
lastInteractionSortId:lastInteractionSortId
lastMessageDate:lastMessageDate

View File

@ -566,7 +566,6 @@ class OWSDeviceSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .device

View File

@ -571,7 +571,6 @@ class OWSLinkedDeviceReadReceiptSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .linkedDeviceReadReceipt

View File

@ -795,7 +795,6 @@ class TSAttachmentSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .attachment

View File

@ -55,7 +55,6 @@ class TSAttachmentPointerSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .attachmentPointer

View File

@ -55,7 +55,6 @@ class TSAttachmentStreamSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .attachmentStream

View File

@ -55,7 +55,6 @@ class OWSContactOffersInteractionSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .contactOffersInteraction

View File

@ -55,7 +55,6 @@ class OWSDisappearingConfigurationUpdateInfoMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .disappearingConfigurationUpdateInfoMessage

View File

@ -55,7 +55,6 @@ class OWSVerificationStateChangeMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .verificationStateChangeMessage

View File

@ -55,7 +55,6 @@ class TSErrorMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .errorMessage

View File

@ -55,7 +55,6 @@ class TSIncomingMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .incomingMessage

View File

@ -55,7 +55,6 @@ class TSInfoMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .infoMessage

View File

@ -1825,7 +1825,6 @@ class TSInteractionSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .interaction

View File

@ -294,21 +294,22 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
{
[super anyDidInsertWithTransaction:transaction];
[self updateLastMessageWithTransaction:transaction];
[self updateLastMessageWithTransaction:transaction wasMessageInserted:YES];
}
- (void)anyDidUpdateWithTransaction:(SDSAnyWriteTransaction *)transaction
{
[super anyDidUpdateWithTransaction:transaction];
[self updateLastMessageWithTransaction:transaction];
[self updateLastMessageWithTransaction:transaction wasMessageInserted:NO];
}
- (void)updateLastMessageWithTransaction:(SDSAnyWriteTransaction *)transaction
wasMessageInserted:(BOOL)wasMessageInserted
{
TSThread *fetchedThread = [self threadWithTransaction:transaction];
[fetchedThread updateWithLastMessage:self transaction:transaction];
[fetchedThread updateWithLastMessage:self wasMessageInserted:wasMessageInserted transaction:transaction];
}
- (void)anyDidRemoveWithTransaction:(SDSAnyWriteTransaction *)transaction

View File

@ -55,7 +55,6 @@ class TSMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .message

View File

@ -55,7 +55,6 @@ class TSOutgoingMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .outgoingMessage

View File

@ -55,7 +55,6 @@ class TSUnreadIndicatorInteractionSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .unreadIndicatorInteraction

View File

@ -55,7 +55,6 @@ class TSInvalidIdentityKeyErrorMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .invalidIdentityKeyErrorMessage

View File

@ -55,7 +55,6 @@ class TSInvalidIdentityKeyReceivingErrorMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .invalidIdentityKeyReceivingErrorMessage

View File

@ -55,7 +55,6 @@ class TSInvalidIdentityKeySendingErrorMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .invalidIdentityKeySendingErrorMessage

View File

@ -55,7 +55,6 @@ class OWSAddToContactsOfferMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .addToContactsOfferMessage

View File

@ -55,7 +55,6 @@ class OWSAddToProfileWhitelistOfferMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .addToProfileWhitelistOfferMessage

View File

@ -565,7 +565,6 @@ class OWSMessageContentJobSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .messageContentJob

View File

@ -551,7 +551,6 @@ class OWSMessageDecryptJobSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .messageDecryptJob

View File

@ -558,7 +558,6 @@ class TSRecipientReadReceiptSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .recipientReadReceipt

View File

@ -55,7 +55,6 @@ class OWSUnknownContactBlockOfferMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .unknownContactBlockOfferMessage

View File

@ -55,7 +55,6 @@ class OWSUnknownProtocolVersionMessageSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .unknownProtocolVersionMessage

View File

@ -551,7 +551,6 @@ class InstalledStickerSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .installedSticker

View File

@ -559,7 +559,6 @@ class KnownStickerPackSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .knownStickerPack

View File

@ -589,7 +589,6 @@ class StickerPackSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .stickerPack

View File

@ -55,7 +55,6 @@ class TSCallSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .call

View File

@ -55,7 +55,6 @@ class SSKMessageDecryptJobRecordSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .messageDecryptJobRecord

View File

@ -579,7 +579,6 @@ class OWSRecipientIdentitySerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .recipientIdentity

View File

@ -213,7 +213,7 @@ public class GRDBDatabaseStorageAdapter: NSObject {
on: ThreadRecord.databaseTableName,
columns: [
ThreadRecord.columnName(.shouldThreadBeVisible),
ThreadRecord.columnName(.archivedAsOfMessageSortId),
ThreadRecord.columnName(.isArchived),
ThreadRecord.columnName(.lastInteractionSortId)
]
)

View File

@ -83,14 +83,13 @@ struct GRDBThreadFinder: ThreadFinder {
static let cn = ThreadRecord.columnName
func visibleThreadCount(isArchived: Bool, transaction: Database) throws -> UInt {
let archivedClause = isArchived ? "IS NOT NULL" : "IS NULL"
let sql = """
SELECT COUNT(*)
FROM \(ThreadRecord.databaseTableName)
WHERE \(threadColumn: .shouldThreadBeVisible) = 1
AND \(threadColumn: .archivedAsOfMessageSortId) \(archivedClause)
AND \(threadColumn: .isArchived) = ?
"""
let arguments: StatementArguments = []
let arguments: StatementArguments = [isArchived]
guard let count = try UInt.fetchOne(transaction, sql: sql, arguments: arguments) else {
owsFailDebug("count was unexpectedly nil")
@ -101,15 +100,14 @@ struct GRDBThreadFinder: ThreadFinder {
}
func enumerateVisibleThreads(isArchived: Bool, transaction: Database, block: @escaping (TSThread) -> Void) throws {
let archivedClause = isArchived ? "IS NOT NULL" : "IS NULL"
let sql = """
SELECT *
FROM \(ThreadRecord.databaseTableName)
WHERE \(threadColumn: .shouldThreadBeVisible) = 1
AND \(threadColumn: .archivedAsOfMessageSortId) \(archivedClause)
AND \(threadColumn: .isArchived) = ?
ORDER BY \(threadColumn: .lastInteractionSortId) DESC
"""
let arguments: StatementArguments = []
let arguments: StatementArguments = [isArchived]
try ThreadRecord.fetchCursor(transaction, sql: sql, arguments: arguments).forEach { threadRecord in
block(try TSThread.fromRecord(threadRecord))

View File

@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSThread (SDS)
@property (nonatomic, nullable, readonly) NSNumber *archivedAsOfMessageSortId;
@property (nonatomic, copy, nullable, readonly) NSString *messageDraft;
@property (nonatomic, nullable, readonly) NSDate *lastMessageDate DEPRECATED_ATTRIBUTE;

View File

@ -55,7 +55,6 @@ class OWSBroadcastMediaMessageJobRecordSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .broadcastMediaMessageJobRecord

View File

@ -55,7 +55,6 @@ class OWSSessionResetJobRecordSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .sessionResetJobRecord

View File

@ -685,7 +685,6 @@ class SSKJobRecordSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .jobRecord

View File

@ -55,7 +55,6 @@ class SSKMessageSenderJobRecordSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = model.sortId > 0 ? Int64(model.sortId) : nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .messageSenderJobRecord

View File

@ -315,7 +315,7 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
}
}
return [thread isArchivedWithTransaction:transaction.asAnyRead] ? TSArchiveGroup : TSInboxGroup;
return thread.isArchived ? TSArchiveGroup : TSInboxGroup;
}];
YapDatabaseViewSorting *viewSorting = [self threadSorting];

View File

@ -533,7 +533,6 @@ class ExperienceUpgradeSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .experienceUpgrade

View File

@ -578,7 +578,6 @@ class OWSBackupFragmentSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .backupFragment

View File

@ -593,7 +593,6 @@ class OWSUserProfileSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .userProfile

View File

@ -600,7 +600,6 @@ class TestModelSerializer: SDSSerializer {
// MARK: - Record
func asRecord() throws -> SDSRecord {
// let id: Int64? = nil
let id: Int64? = model.grdbId?.int64Value
let recordType: SDSRecordType = .testModel