@ -13,8 +13,6 @@ import SessionUtilitiesKit
import SignalCoreKit
import SignalCoreKit
class DeveloperSettingsViewModel : SessionTableViewModel , NavigatableStateHolder , ObservableTableSource {
class DeveloperSettingsViewModel : SessionTableViewModel , NavigatableStateHolder , ObservableTableSource {
typealias TableItem = Section
public let dependencies : Dependencies
public let dependencies : Dependencies
public let navigatableState : NavigatableState = NavigatableState ( )
public let navigatableState : NavigatableState = NavigatableState ( )
public let state : TableDataState < Section , TableItem > = TableDataState ( )
public let state : TableDataState < Section , TableItem > = TableDataState ( )
@ -30,29 +28,61 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
// MARK: - S e c t i o n
// MARK: - S e c t i o n
public enum Section : SessionTableSection , CaseIterable {
public enum Section : SessionTableSection {
case developerMode
case network
case disappearingMessages
case groups
case database
var title : String ? {
switch self {
case . developerMode : return nil
case . network : return " Network "
case . disappearingMessages : return " Disappearing Messages "
case . groups : return " Groups "
case . database : return " Database "
}
}
// d e f a u l t : r e t u r n . t i t l e R o u n d e d C o n t e n t / / . p a d d i n g
var style : SessionTableSectionStyle {
switch self {
case . developerMode : return . padding
default : return . titleRoundedContent
}
}
}
public enum TableItem : Differentiable , CaseIterable {
case developerMode
case developerMode
case serviceNetwork
case serviceNetwork
case networkLayer
case networkLayer
case updatedDisappearingMessages
case updatedDisappearingMessages
case debugDisappearingMessageDurations
case updatedGroups
case updatedGroups
case updatedGroupsRemoveMessagesOnKick
case updatedGroupsRemoveMessagesOnKick
case updatedGroupsAllowHistoricAccessOnInvite
case updatedGroupsAllowHistoricAccessOnInvite
case updatedGroupsAllowDisplayPicture
case updatedGroupsAllowDisplayPicture
case updatedGroupsAllowDescriptionEditing
case updatedGroupsAllowDescriptionEditing
case updatedGroupsAllowPromotions
case updatedGroupsAllowPromotions
case exportDatabase
var style : SessionTableSectionStyle { . padding }
case exportDatabase
}
}
// MARK: - C o n t e n t
// MARK: - C o n t e n t
private struct State : Equatable {
private struct State : Equatable {
let developerMode : Bool
let developerMode : Bool
let serviceNetwork : ServiceNetwork
let serviceNetwork : ServiceNetwork
let networkLayer : Network . Layers
let networkLayer : Network . Layers
let debugDisappearingMessageDurations : Bool
let updatedDisappearingMessages : Bool
let updatedDisappearingMessages : Bool
let updatedGroups : Bool
let updatedGroups : Bool
let updatedGroupsRemoveMessagesOnKick : Bool
let updatedGroupsRemoveMessagesOnKick : Bool
let updatedGroupsAllowHistoricAccessOnInvite : Bool
let updatedGroupsAllowHistoricAccessOnInvite : Bool
@ -69,6 +99,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
developerMode : dependencies [ singleton : . storage , key : . developerModeEnabled ] ,
developerMode : dependencies [ singleton : . storage , key : . developerModeEnabled ] ,
serviceNetwork : dependencies [ feature : . serviceNetwork ] ,
serviceNetwork : dependencies [ feature : . serviceNetwork ] ,
networkLayer : dependencies [ feature : . networkLayers ] ,
networkLayer : dependencies [ feature : . networkLayers ] ,
debugDisappearingMessageDurations : dependencies [ feature : . debugDisappearingMessageDurations ] ,
updatedDisappearingMessages : dependencies [ feature : . updatedDisappearingMessages ] ,
updatedDisappearingMessages : dependencies [ feature : . updatedDisappearingMessages ] ,
updatedGroups : dependencies [ feature : . updatedGroups ] ,
updatedGroups : dependencies [ feature : . updatedGroups ] ,
updatedGroupsRemoveMessagesOnKick : dependencies [ feature : . updatedGroupsRemoveMessagesOnKick ] ,
updatedGroupsRemoveMessagesOnKick : dependencies [ feature : . updatedGroupsRemoveMessagesOnKick ] ,
@ -87,9 +118,11 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
id : . developerMode ,
id : . developerMode ,
title : " Developer Mode " ,
title : " Developer Mode " ,
subtitle : " " "
subtitle : " " "
Developer Mode grants the device access to the settings on this screen .
Grants access to this screen .
Disabling this setting will reset all of the below settings back to default ( removing data as described below ) and revoke access to this screen unless Developer Mode is re - enabled .
Disabling this setting will :
• Reset all the below settings to default ( removing data as described below )
• Revoke access to this screen unless Developer Mode is re - enabled
" " " ,
" " " ,
trailingAccessory : . toggle (
trailingAccessory : . toggle (
. boolValue ( current . developerMode , oldValue : ( previous ? ? current ) . developerMode )
. boolValue ( current . developerMode , oldValue : ( previous ? ? current ) . developerMode )
@ -103,15 +136,16 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
]
]
) ,
) ,
SectionModel (
SectionModel (
model : . serviceN etwork,
model : . n etwork,
elements : [
elements : [
SessionCell . Info (
SessionCell . Info (
id : . serviceNetwork ,
id : . serviceNetwork ,
title : " Network " ,
title : " Environment " ,
subtitle : " " "
subtitle : " " "
The service network which should be used for sending requests and storing messages .
The environment used for sending requests and storing messages .
< b > Warning : </ b > These networks cannot communicate with each other so changing this network will result in all conversation and snode data being cleared and any pending network requests being cancelled .
< b > Warning : </ b >
Changing this setting will result in all conversation and snode data being cleared and any pending network requests being cancelled .
" " " ,
" " " ,
trailingAccessory : . dropDown (
trailingAccessory : . dropDown (
. dynamicString { current . serviceNetwork . title }
. dynamicString { current . serviceNetwork . title }
@ -120,7 +154,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
self ? . transitionToScreen (
self ? . transitionToScreen (
SessionTableViewController (
SessionTableViewController (
viewModel : SessionListViewModel < ServiceNetwork > (
viewModel : SessionListViewModel < ServiceNetwork > (
title : " Network " ,
title : " Environment " ,
options : ServiceNetwork . allCases ,
options : ServiceNetwork . allCases ,
behaviour : . autoDismiss (
behaviour : . autoDismiss (
initialSelection : current . serviceNetwork ,
initialSelection : current . serviceNetwork ,
@ -131,19 +165,17 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
)
)
)
)
}
}
)
) ,
]
) ,
SectionModel (
model : . networkLayer ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . networkLayer ,
id : . networkLayer ,
title : " Network Layer " ,
title : " Routing " ,
subtitle : " " "
subtitle : " " "
The network layer which all network traffic should be routed through . We do support sending network traffic through multiple network layers , if multiple layers are selected then requests will wait for a response from all layers before completing with the first successful response .
The network layer which all network traffic should be routed through .
We do support sending network traffic through multiple network layers , if multiple layers are selected then requests will wait for a response from all layers before completing with the first successful response .
< b > Warning : </ b > Different network layers offer different levels of privacy , make sure to read the description of the network layers before making a selection .
< b > Warning : </ b >
Different network layers offer different levels of privacy , make sure to read the description of the network layers before making a selection .
" " " ,
" " " ,
trailingAccessory : . dropDown (
trailingAccessory : . dropDown (
. dynamicString { current . networkLayer . title }
. dynamicString { current . networkLayer . title }
@ -152,7 +184,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
self ? . transitionToScreen (
self ? . transitionToScreen (
SessionTableViewController (
SessionTableViewController (
viewModel : SessionListViewModel < Network . Layers > (
viewModel : SessionListViewModel < Network . Layers > (
title : " Network Layer " ,
title : " Routing " ,
options : Network . Layers . allCases ,
options : Network . Layers . allCases ,
behaviour : . singleSelect (
behaviour : . singleSelect (
initialSelection : current . networkLayer ,
initialSelection : current . networkLayer ,
@ -167,13 +199,34 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
]
]
) ,
) ,
SectionModel (
SectionModel (
model : . up datedD isappearingMessages,
model : . disappearingMessages,
elements : [
elements : [
SessionCell . Info (
id : . debugDisappearingMessageDurations ,
title : " Debug Durations " ,
subtitle : " " "
Adds 10 and 60 second durations for Disappearing Message settings .
These should only be used for debugging purposes and can result in odd behaviours .
" " " ,
trailingAccessory : . toggle (
. boolValue (
current . debugDisappearingMessageDurations ,
oldValue : ( previous ? ? current ) . debugDisappearingMessageDurations
)
) ,
onTap : {
self ? . updateFlag (
for : . debugDisappearingMessageDurations ,
to : ! current . debugDisappearingMessageDurations
)
}
) ,
SessionCell . Info (
SessionCell . Info (
id : . updatedDisappearingMessages ,
id : . updatedDisappearingMessages ,
title : " Updated Disappearing Messages " ,
title : " U se U pdated Disappearing Messages" ,
subtitle : " " "
subtitle : " " "
This setting controls whether legacy or updated disappearing messages should be used .
C ontrols whether legacy or updated disappearing messages should be used .
" " " ,
" " " ,
trailingAccessory : . toggle (
trailingAccessory : . toggle (
. boolValue (
. boolValue (
@ -191,29 +244,24 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
]
]
) ,
) ,
SectionModel (
SectionModel (
model : . updatedG roups,
model : . g roups,
elements : [
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroups ,
id : . updatedGroups ,
title : " U pdated Groups" ,
title : " U se U pdated Groups" ,
subtitle : " " "
subtitle : " " "
This settings controls whether newly created groups should use the updated groups or legacy groups .
Controls whether newly created groups are updated or legacy groups .
" " " ,
" " " ,
trailingAccessory : . toggle (
trailingAccessory : . toggle (
. boolValue ( current . updatedGroups , oldValue : ( previous ? ? current ) . updatedGroups )
. boolValue ( current . updatedGroups , oldValue : ( previous ? ? current ) . updatedGroups )
) ,
) ,
onTap : { self ? . updateFlag ( for : . updatedGroups , to : ! current . updatedGroups ) }
onTap : { self ? . updateFlag ( for : . updatedGroups , to : ! current . updatedGroups ) }
)
) ,
]
) ,
SectionModel (
model : . updatedGroupsRemoveMessagesOnKick ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroupsRemoveMessagesOnKick ,
id : . updatedGroupsRemoveMessagesOnKick ,
title : " Remove Messages when Kicking from Updated Groups " ,
title : " Remove Messages on Kick " ,
subtitle : " " "
subtitle : " " "
This settings c ontrols whether a group members messages should be removed when they are kicked from an updated group .
Controls whether a group members messages should be removed when they are kicked from an updated group .
< b > Note : </ b > In a future release we will offer this as an option when removing members but for the initial release it can be controlled via this flag for testing purposes .
< b > Note : </ b > In a future release we will offer this as an option when removing members but for the initial release it can be controlled via this flag for testing purposes .
" " " ,
" " " ,
@ -229,17 +277,12 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
to : ! current . updatedGroupsRemoveMessagesOnKick
to : ! current . updatedGroupsRemoveMessagesOnKick
)
)
}
}
)
) ,
]
) ,
SectionModel (
model : . updatedGroupsAllowHistoricAccessOnInvite ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroupsAllowHistoricAccessOnInvite ,
id : . updatedGroupsAllowHistoricAccessOnInvite ,
title : " Allow access to historic messages when inviting to an updated group " ,
title : " Allow Historic Message Access " ,
subtitle : " " "
subtitle : " " "
This settings controls whether a group members should be granted access to h s itoric messages when invited to an updated group .
Controls whether members should be granted access to historic messages when invited to an updated group .
< b > Note : </ b > In a future release we will offer this as an option when inviting members but for the initial release it can be controlled via this flag for testing purposes .
< b > Note : </ b > In a future release we will offer this as an option when inviting members but for the initial release it can be controlled via this flag for testing purposes .
" " " ,
" " " ,
@ -255,17 +298,12 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
to : ! current . updatedGroupsAllowHistoricAccessOnInvite
to : ! current . updatedGroupsAllowHistoricAccessOnInvite
)
)
}
}
)
) ,
]
) ,
SectionModel (
model : . updatedGroupsAllowDisplayPicture ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroupsAllowDisplayPicture ,
id : . updatedGroupsAllowDisplayPicture ,
title : " Shows UI for setting updated group custom display p ictures" ,
title : " Custom Display Pictures " ,
subtitle : " " "
subtitle : " " "
This settings c ontrols whether the UI allows group admins to set a custom display picture for a group .
Controls whether the UI allows group admins to set a custom display picture for a group .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
" " " ,
" " " ,
@ -281,17 +319,12 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
to : ! current . updatedGroupsAllowDisplayPicture
to : ! current . updatedGroupsAllowDisplayPicture
)
)
}
}
)
) ,
]
) ,
SectionModel (
model : . updatedGroupsAllowDescriptionEditing ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroupsAllowDescriptionEditing ,
id : . updatedGroupsAllowDescriptionEditing ,
title : " Show UI for editing updated group d escriptions" ,
title : " Edit Group Descriptions " ,
subtitle : " " "
subtitle : " " "
This settings c ontrols whether the UI allows group admins to modify the descriptions of updated groups .
Controls whether the UI allows group admins to modify the descriptions of updated groups .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
" " " ,
" " " ,
@ -307,17 +340,12 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
to : ! current . updatedGroupsAllowDescriptionEditing
to : ! current . updatedGroupsAllowDescriptionEditing
)
)
}
}
)
) ,
]
) ,
SectionModel (
model : . updatedGroupsAllowPromotions ,
elements : [
SessionCell . Info (
SessionCell . Info (
id : . updatedGroupsAllowPromotions ,
id : . updatedGroupsAllowPromotions ,
title : " Show UI for updated group p romotions" ,
title : " Allow Group Promotions " ,
subtitle : " " "
subtitle : " " "
This settings c ontrols whether the UI allows group admins promote other group members to admin within an updated group .
Controls whether the UI allows group admins promote other group members to admin within an updated group .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
< b > Note : </ b > In a future release we will offer this functionality but for the initial release it may not be fully supported across platforms so can be controlled via this flag for testing purposes .
" " " ,
" " " ,
@ -337,7 +365,7 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
]
]
) ,
) ,
SectionModel (
SectionModel (
model : . exportD atabase,
model : . d atabase,
elements : [
elements : [
SessionCell . Info (
SessionCell . Info (
id : . exportDatabase ,
id : . exportDatabase ,
@ -362,14 +390,18 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder,
private func disableDeveloperMode ( ) {
private func disableDeveloperMode ( ) {
// / L o o p t h r o u g h a l l o f t h e s e c t i o n s a n d r e s e t t h e f e a t u r e s b a c k t o d e f a u l t f o r e a c h o n e a s n e e d e d ( t h i s w a y i f a n e w s e c t i o n i s a d d e d
// / L o o p t h r o u g h a l l o f t h e s e c t i o n s a n d r e s e t t h e f e a t u r e s b a c k t o d e f a u l t f o r e a c h o n e a s n e e d e d ( t h i s w a y i f a n e w s e c t i o n i s a d d e d
// / t h e n w e w i l l g e t a c o m p i l e e r r o r i f i t d o e s n ' t g e t r e s e t t i n g i n s t r u c t i o n s a d d e d )
// / t h e n w e w i l l g e t a c o m p i l e e r r o r i f i t d o e s n ' t g e t r e s e t t i n g i n s t r u c t i o n s a d d e d )
Section. allCases . forEach { section in
TableItem. allCases . forEach { item in
switch section {
switch item {
case . developerMode : break // N o t a f e a t u r e
case . developerMode : break // N o t a f e a t u r e
case . exportDatabase : break // N o t a f e a t u r e
case . exportDatabase : break // N o t a f e a t u r e
case . serviceNetwork : updateServiceNetwork ( to : nil )
case . serviceNetwork : updateServiceNetwork ( to : nil )
case . networkLayer : updateNetworkLayers ( to : nil )
case . networkLayer : updateNetworkLayers ( to : nil )
case . debugDisappearingMessageDurations :
updateFlag ( for : . debugDisappearingMessageDurations , to : nil )
case . updatedDisappearingMessages : updateFlag ( for : . updatedDisappearingMessages , to : nil )
case . updatedDisappearingMessages : updateFlag ( for : . updatedDisappearingMessages , to : nil )
case . updatedGroups : updateFlag ( for : . updatedGroups , to : nil )
case . updatedGroups : updateFlag ( for : . updatedGroups , to : nil )
case . updatedGroupsRemoveMessagesOnKick : updateFlag ( for : . updatedGroupsRemoveMessagesOnKick , to : nil )
case . updatedGroupsRemoveMessagesOnKick : updateFlag ( for : . updatedGroupsRemoveMessagesOnKick , to : nil )
case . updatedGroupsAllowHistoricAccessOnInvite :
case . updatedGroupsAllowHistoricAccessOnInvite :