@ -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 , _ ) :
// W e n e e d t o c u s t o m h a n d l e t h e ' N o t e t o S e l f ' c o n v e r s a t i o n ( i t s h o u l d j u s t b e
// h i d d e n r a t h e r t h a n d e l e t e d
if threadIds . contains ( currentUserPublicKey ) {
case ( . contact , . standard ) , ( . contact , . silent ) :
// C l e a r a n y i n t e r a c t i o n s f o r t h e d e l e t e d t h r e a d
_ = try Interaction
. filter ( Interaction. Columns . threadId = = currentUserPublicKey )
. filter ( threadIds . contains ( Interaction . Columns . threadId ) )
. deleteAll ( db )
// W e n e e d t o c u s t o m h a n d l e t h e ' N o t e t o S e l f ' c o n v e r s a t i o n ( i t s h o u l d j u s t b e
// h i d d e n l o c a l l y r a t h e r t h a n d e l e t e d )
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
}
// U p d a t e a n y o t h e r t h r e a d s t o b e h i d d e n ( d o n ' t w a n t t o a c t u a l l y d e l e t e t h e t h r e a d
// r e c o r d i n c a s e i t ' s s e t t i n g s g e t c h a n g e d w h i l e i t ' s n o t v i s i b l e )
_ = 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 ) :
// I f t h i s w a s n ' t c a l l e d f r o m c o n f i g h a n d l i n g t h e n w e n e e d t o h i d e t h e c o n v e r s a t i o n
if ! calledFromConfigHandling {
try SessionUtil
. hide ( db , contactIds : threadIds )
. remove( db , contactIds : remainingT hreadIds)
}
_ = try SessionThread
. filter ( ids : remainingThreadIds )
. filter ( id : remainingThreadIds )
. deleteAll ( db )
case ( . legacyGroup , . standard ) , ( . group , . standard ) :