fix retrieve disappearing message config from database with session thread data model

pull/941/head
Ryan Zhao 2 years ago
parent 54914d69c6
commit f5e41907d4

@ -64,6 +64,7 @@ public struct SessionThreadViewModel: FetchableRecordWithRowId, Decodable, Equat
public static let threadUnreadMentionCountString: String = CodingKeys.threadUnreadMentionCount.stringValue public static let threadUnreadMentionCountString: String = CodingKeys.threadUnreadMentionCount.stringValue
public static let closedGroupUserCountString: String = CodingKeys.closedGroupUserCount.stringValue public static let closedGroupUserCountString: String = CodingKeys.closedGroupUserCount.stringValue
public static let openGroupUserCountString: String = CodingKeys.openGroupUserCount.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 contactProfileString: String = CodingKeys.contactProfile.stringValue
public static let closedGroupProfileFrontString: String = CodingKeys.closedGroupProfileFront.stringValue public static let closedGroupProfileFrontString: String = CodingKeys.closedGroupProfileFront.stringValue
public static let closedGroupProfileBackString: String = CodingKeys.closedGroupProfileBack.stringValue public static let closedGroupProfileBackString: String = CodingKeys.closedGroupProfileBack.stringValue
@ -812,18 +813,19 @@ public extension SessionThreadViewModel {
return request.adapted { db in return request.adapted { db in
let adapters = try splittingRowAdapters(columnCounts: [ let adapters = try splittingRowAdapters(columnCounts: [
numColumnsBeforeProfiles, numColumnsBeforeProfiles,
DisappearingMessagesConfiguration.numberOfSelectedColumns(db),
Profile.numberOfSelectedColumns(db) Profile.numberOfSelectedColumns(db)
]) ])
return ScopeAdapter([ return ScopeAdapter([
ViewModel.contactProfileString: adapters[1] ViewModel.disappearingMessagesConfigurationString: adapters[1],
ViewModel.contactProfileString: adapters[2]
]) ])
} }
} }
static func conversationSettingsQuery(threadId: String, userPublicKey: String) -> AdaptedFetchRequest<SQLRequest<SessionThreadViewModel>> { static func conversationSettingsQuery(threadId: String, userPublicKey: String) -> AdaptedFetchRequest<SQLRequest<SessionThreadViewModel>> {
let thread: TypedTableAlias<SessionThread> = TypedTableAlias() let thread: TypedTableAlias<SessionThread> = TypedTableAlias()
let disappearingMessagesConfiguration: TypedTableAlias<DisappearingMessagesConfiguration> = TypedTableAlias()
let contact: TypedTableAlias<Contact> = TypedTableAlias() let contact: TypedTableAlias<Contact> = TypedTableAlias()
let closedGroup: TypedTableAlias<ClosedGroup> = TypedTableAlias() let closedGroup: TypedTableAlias<ClosedGroup> = TypedTableAlias()
let groupMember: TypedTableAlias<GroupMember> = TypedTableAlias() let groupMember: TypedTableAlias<GroupMember> = TypedTableAlias()
@ -852,8 +854,6 @@ public extension SessionThreadViewModel {
\(thread[.mutedUntilTimestamp]) AS \(ViewModel.threadMutedUntilTimestampKey), \(thread[.mutedUntilTimestamp]) AS \(ViewModel.threadMutedUntilTimestampKey),
\(thread[.onlyNotifyForMentions]) AS \(ViewModel.threadOnlyNotifyForMentionsKey), \(thread[.onlyNotifyForMentions]) AS \(ViewModel.threadOnlyNotifyForMentionsKey),
\(ViewModel.disappearingMessagesConfigurationKey).*,
\(ViewModel.contactProfileKey).*, \(ViewModel.contactProfileKey).*,
\(ViewModel.closedGroupProfileFrontKey).*, \(ViewModel.closedGroupProfileFrontKey).*,
\(ViewModel.closedGroupProfileBackKey).*, \(ViewModel.closedGroupProfileBackKey).*,
@ -867,7 +867,6 @@ public extension SessionThreadViewModel {
\(SQL("\(userPublicKey)")) AS \(ViewModel.currentUserPublicKeyKey) \(SQL("\(userPublicKey)")) AS \(ViewModel.currentUserPublicKeyKey)
FROM \(SessionThread.self) FROM \(SessionThread.self)
LEFT JOIN \(DisappearingMessagesConfiguration.self) ON \(disappearingMessagesConfiguration[.threadId]) = \(thread[.id])
LEFT JOIN \(Contact.self) ON \(contact[.id]) = \(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 \(Profile.self) AS \(ViewModel.contactProfileKey) ON \(ViewModel.contactProfileKey).\(profileIdColumnLiteral) = \(thread[.id])
LEFT JOIN \(OpenGroup.self) ON \(openGroup[.threadId]) = \(thread[.id]) LEFT JOIN \(OpenGroup.self) ON \(openGroup[.threadId]) = \(thread[.id])

Loading…
Cancel
Save