@ -216,11 +216,13 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
disappearingMessagesConfig : disappearingMessagesConfig
disappearingMessagesConfig : disappearingMessagesConfig
)
)
}
}
. mapWithPrevious { [ weak self , dependencies ] previous , current -> [ SectionModel ] in
. compactMapWithPrevious { [ weak self ] prev , current -> [ SectionModel ] ? in self ? . content ( prev , current ) }
private func content ( _ previous : State ? , _ current : State ) -> [ SectionModel ] {
// I f w e d o n ' t g e t a ` S e s s i o n T h r e a d V i e w M o d e l ` t h e n i t m e a n s t h e t h r e a d w a s p r o b a b l y d e l e t e d
// I f w e d o n ' t g e t a ` S e s s i o n T h r e a d V i e w M o d e l ` t h e n i t m e a n s t h e t h r e a d w a s p r o b a b l y d e l e t e d
// s o d i s m i s s t h e s c r e e n
// s o d i s m i s s t h e s c r e e n
guard let threadViewModel : SessionThreadViewModel = current . threadViewModel else {
guard let threadViewModel : SessionThreadViewModel = current . threadViewModel else {
self ? . dismissScreen ( type : . popToRoot )
self . dismissScreen ( type : . popToRoot )
return [ ]
return [ ]
}
}
@ -262,7 +264,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
customPadding : SessionCell . Padding ( bottom : Values . smallSpacing ) ,
customPadding : SessionCell . Padding ( bottom : Values . smallSpacing ) ,
backgroundStyle : . noBackground
backgroundStyle : . noBackground
) ,
) ,
onTap : { self ? . viewProfilePicture ( threadViewModel : threadViewModel ) }
onTap : { [ weak self ] in self ? . viewProfilePicture ( threadViewModel : threadViewModel ) }
) ,
) ,
SessionCell . Info (
SessionCell . Info (
id : . nickname ,
id : . nickname ,
@ -300,7 +302,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
identifier : " Username " ,
identifier : " Username " ,
label : threadViewModel . displayName
label : threadViewModel . displayName
) ,
) ,
onTap : {
onTap : { [ weak self ] in
self ? . textChanged ( self ? . oldDisplayName , for : . nickname )
self ? . textChanged ( self ? . oldDisplayName , for : . nickname )
self ? . setIsEditing ( true )
self ? . setIsEditing ( true )
}
}
@ -348,7 +350,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
identifier : " \( ThreadSettingsViewModel . self ) .copy_thread_id " ,
identifier : " \( ThreadSettingsViewModel . self ) .copy_thread_id " ,
label : " Copy Session ID "
label : " Copy Session ID "
) ,
) ,
onTap : {
onTap : { [ weak self ] in
switch threadViewModel . threadVariant {
switch threadViewModel . threadVariant {
case . contact , . legacyGroup , . group :
case . contact , . legacyGroup , . group :
UIPasteboard . general . string = threadViewModel . threadId
UIPasteboard . general . string = threadViewModel . threadId
@ -546,7 +548,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
confirmStyle : . danger ,
confirmStyle : . danger ,
cancelStyle : . alert_text
cancelStyle : . alert_text
) ,
) ,
onTap : { [ weak self ] in
onTap : { [ dependencies ] in
dependencies . storage . write { db in
dependencies . storage . write { db in
try SessionThread . deleteOrLeave (
try SessionThread . deleteOrLeave (
db ,
db ,
@ -607,7 +609,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
identifier : " Mentions only notification setting " ,
identifier : " Mentions only notification setting " ,
label : " Mentions only "
label : " Mentions only "
) ,
) ,
onTap : {
onTap : { [ dependencies ] in
let newValue : Bool = ! ( threadViewModel . threadOnlyNotifyForMentions = = true )
let newValue : Bool = ! ( threadViewModel . threadOnlyNotifyForMentions = = true )
dependencies . storage . writeAsync { db in
dependencies . storage . writeAsync { db in
@ -648,7 +650,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
identifier : " \( ThreadSettingsViewModel . self ) .mute " ,
identifier : " \( ThreadSettingsViewModel . self ) .mute " ,
label : " Mute notifications "
label : " Mute notifications "
) ,
) ,
onTap : {
onTap : { [ dependencies ] in
dependencies . storage . writeAsync { db in
dependencies . storage . writeAsync { db in
let currentValue : TimeInterval ? = try SessionThread
let currentValue : TimeInterval ? = try SessionThread
. filter ( id : threadViewModel . threadId )
. filter ( id : threadViewModel . threadId )
@ -715,7 +717,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
confirmStyle : . danger ,
confirmStyle : . danger ,
cancelStyle : . alert_text
cancelStyle : . alert_text
) ,
) ,
onTap : {
onTap : { [ weak self ] in
let isBlocked : Bool = ( threadViewModel . threadIsBlocked = = true )
let isBlocked : Bool = ( threadViewModel . threadIsBlocked = = true )
self ? . updateBlockedState (
self ? . updateBlockedState (