|
|
|
@ -296,17 +296,18 @@ public extension SessionThread {
|
|
|
|
|
calledFromConfigHandling: Bool
|
|
|
|
|
) throws {
|
|
|
|
|
let currentUserPublicKey: String = getUserHexEncodedPublicKey(db)
|
|
|
|
|
let remainingThreadIds: [String] = threadIds.filter { $0 != currentUserPublicKey }
|
|
|
|
|
let remainingThreadIds: Set<String> = threadIds.asSet().removing(currentUserPublicKey)
|
|
|
|
|
|
|
|
|
|
switch (threadVariant, groupLeaveType) {
|
|
|
|
|
case (.contact, _):
|
|
|
|
|
// We need to custom handle the 'Note to Self' conversation (it should just be
|
|
|
|
|
// hidden rather than deleted
|
|
|
|
|
if threadIds.contains(currentUserPublicKey) {
|
|
|
|
|
case (.contact, .standard), (.contact, .silent):
|
|
|
|
|
// Clear any interactions for the deleted thread
|
|
|
|
|
_ = try Interaction
|
|
|
|
|
.filter(Interaction.Columns.threadId == currentUserPublicKey)
|
|
|
|
|
.filter(threadIds.contains(Interaction.Columns.threadId))
|
|
|
|
|
.deleteAll(db)
|
|
|
|
|
|
|
|
|
|
// We need to custom handle the 'Note to Self' conversation (it should just be
|
|
|
|
|
// hidden locally rather than deleted)
|
|
|
|
|
if threadIds.contains(currentUserPublicKey) {
|
|
|
|
|
_ = try SessionThread
|
|
|
|
|
.filter(id: currentUserPublicKey)
|
|
|
|
|
.updateAllAndConfig(
|
|
|
|
@ -314,17 +315,28 @@ public extension SessionThread {
|
|
|
|
|
SessionThread.Columns.pinnedPriority.set(to: 0),
|
|
|
|
|
SessionThread.Columns.shouldBeVisible.set(to: false)
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update any other threads to be hidden (don't want to actually delete the thread
|
|
|
|
|
// record in case it's settings get changed while it's not visible)
|
|
|
|
|
_ = try SessionThread
|
|
|
|
|
.filter(id: remainingThreadIds)
|
|
|
|
|
.updateAllAndConfig(
|
|
|
|
|
db,
|
|
|
|
|
calledFromConfig: calledFromConfig,
|
|
|
|
|
SessionThread.Columns.pinnedPriority.set(to: SessionUtil.hiddenPriority),
|
|
|
|
|
SessionThread.Columns.shouldBeVisible.set(to: false)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
case (.contact, .forced):
|
|
|
|
|
// If this wasn't called from config handling then we need to hide the conversation
|
|
|
|
|
if !calledFromConfigHandling {
|
|
|
|
|
try SessionUtil
|
|
|
|
|
.hide(db, contactIds: threadIds)
|
|
|
|
|
.remove(db, contactIds: remainingThreadIds)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ = try SessionThread
|
|
|
|
|
.filter(ids: remainingThreadIds)
|
|
|
|
|
.filter(id: remainingThreadIds)
|
|
|
|
|
.deleteAll(db)
|
|
|
|
|
|
|
|
|
|
case (.legacyGroup, .standard), (.group, .standard):
|
|
|
|
|