From f5e41907d497f8dd4991950d9d7e148c0e1b58b4 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 27 Oct 2022 10:03:47 +1100 Subject: [PATCH] fix retrieve disappearing message config from database with session thread data model --- .../Shared Models/SessionThreadViewModel.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SessionMessagingKit/Shared Models/SessionThreadViewModel.swift b/SessionMessagingKit/Shared Models/SessionThreadViewModel.swift index 7a2e111a1..8c4079e2f 100644 --- a/SessionMessagingKit/Shared Models/SessionThreadViewModel.swift +++ b/SessionMessagingKit/Shared Models/SessionThreadViewModel.swift @@ -64,6 +64,7 @@ public struct SessionThreadViewModel: FetchableRecordWithRowId, Decodable, Equat public static let threadUnreadMentionCountString: String = CodingKeys.threadUnreadMentionCount.stringValue public static let closedGroupUserCountString: String = CodingKeys.closedGroupUserCount.stringValue public static let openGroupUserCountString: String = CodingKeys.openGroupUserCount.stringValue + public static let disappearingMessagesConfigurationString: String = CodingKeys.disappearingMessagesConfiguration.stringValue public static let contactProfileString: String = CodingKeys.contactProfile.stringValue public static let closedGroupProfileFrontString: String = CodingKeys.closedGroupProfileFront.stringValue public static let closedGroupProfileBackString: String = CodingKeys.closedGroupProfileBack.stringValue @@ -812,18 +813,19 @@ public extension SessionThreadViewModel { return request.adapted { db in let adapters = try splittingRowAdapters(columnCounts: [ numColumnsBeforeProfiles, + DisappearingMessagesConfiguration.numberOfSelectedColumns(db), Profile.numberOfSelectedColumns(db) ]) return ScopeAdapter([ - ViewModel.contactProfileString: adapters[1] + ViewModel.disappearingMessagesConfigurationString: adapters[1], + ViewModel.contactProfileString: adapters[2] ]) } } static func conversationSettingsQuery(threadId: String, userPublicKey: String) -> AdaptedFetchRequest> { let thread: TypedTableAlias = TypedTableAlias() - let disappearingMessagesConfiguration: TypedTableAlias = TypedTableAlias() let contact: TypedTableAlias = TypedTableAlias() let closedGroup: TypedTableAlias = TypedTableAlias() let groupMember: TypedTableAlias = TypedTableAlias() @@ -852,8 +854,6 @@ public extension SessionThreadViewModel { \(thread[.mutedUntilTimestamp]) AS \(ViewModel.threadMutedUntilTimestampKey), \(thread[.onlyNotifyForMentions]) AS \(ViewModel.threadOnlyNotifyForMentionsKey), - \(ViewModel.disappearingMessagesConfigurationKey).*, - \(ViewModel.contactProfileKey).*, \(ViewModel.closedGroupProfileFrontKey).*, \(ViewModel.closedGroupProfileBackKey).*, @@ -867,7 +867,6 @@ public extension SessionThreadViewModel { \(SQL("\(userPublicKey)")) AS \(ViewModel.currentUserPublicKeyKey) FROM \(SessionThread.self) - LEFT JOIN \(DisappearingMessagesConfiguration.self) ON \(disappearingMessagesConfiguration[.threadId]) = \(thread[.id]) LEFT JOIN \(Contact.self) ON \(contact[.id]) = \(thread[.id]) LEFT JOIN \(Profile.self) AS \(ViewModel.contactProfileKey) ON \(ViewModel.contactProfileKey).\(profileIdColumnLiteral) = \(thread[.id]) LEFT JOIN \(OpenGroup.self) ON \(openGroup[.threadId]) = \(thread[.id])