@@ -115,6 +115,8 @@ class GeneratorViewModel @Inject constructor(
115
115
shouldShowAnonAddySelfHostServerUrlField = featureFlagManager.getFeatureFlag(
116
116
FlagKey .AnonAddySelfHostAlias ,
117
117
),
118
+ shouldShowSimpleLoginSelfHostServerField =
119
+ featureFlagManager.getFeatureFlag(FlagKey .SimpleLoginSelfHostAlias ),
118
120
)
119
121
},
120
122
) {
@@ -152,6 +154,15 @@ class GeneratorViewModel @Inject constructor(
152
154
}
153
155
.onEach(::sendAction)
154
156
.launchIn(viewModelScope)
157
+
158
+ featureFlagManager.getFeatureFlagFlow(FlagKey .SimpleLoginSelfHostAlias )
159
+ .map { shouldShowSimpleLoginSelfHostServerField ->
160
+ GeneratorAction .Internal .ShouldShowSimpleLoginSelfHostValueChangeReceive (
161
+ shouldShowSelfHostServerField = shouldShowSimpleLoginSelfHostServerField,
162
+ )
163
+ }
164
+ .onEach(::sendAction)
165
+ .launchIn(viewModelScope)
155
166
}
156
167
157
168
override fun handleAction (action : GeneratorAction ) {
@@ -249,6 +260,10 @@ class GeneratorViewModel @Inject constructor(
249
260
is GeneratorAction .MainType .Username .UsernameType .RandomWord -> {
250
261
handleRandomWordSpecificAction(action)
251
262
}
263
+
264
+ is GeneratorAction .MainType .Username .UsernameType .ForwardedEmailAlias .SimpleLogin .SelfHostServerUrlChange -> {
265
+ handleSimpleLoginSelfHostServerUrlChange(action)
266
+ }
252
267
}
253
268
}
254
269
@@ -289,6 +304,10 @@ class GeneratorViewModel @Inject constructor(
289
304
is GeneratorAction .Internal .ShouldShowAnonAddySelfHostValueChangeReceive -> {
290
305
handleShouldShowAnonAddySelfHostValueChange(action)
291
306
}
307
+
308
+ is GeneratorAction .Internal .ShouldShowSimpleLoginSelfHostValueChangeReceive -> {
309
+ handleShouldShowSimpleLoginSelfHostValueChange(action)
310
+ }
292
311
}
293
312
}
294
313
@@ -594,6 +613,8 @@ class GeneratorViewModel @Inject constructor(
594
613
type = UsernameGenerationOptions .UsernameType .FORWARDED_EMAIL_ALIAS ,
595
614
serviceType = UsernameGenerationOptions .ForwardedEmailServiceType .SIMPLE_LOGIN ,
596
615
simpleLoginApiKey = forwardedEmailAlias.selectedServiceType.apiKey,
616
+ simpleLoginSelfHostServerUrl =
617
+ forwardedEmailAlias.selectedServiceType.selfHostServerUrl,
597
618
)
598
619
599
620
is ForwardEmail -> options.copy(
@@ -643,6 +664,7 @@ class GeneratorViewModel @Inject constructor(
643
664
catchAllEmailDomain = " " ,
644
665
firefoxRelayApiAccessToken = " " ,
645
666
simpleLoginApiKey = " " ,
667
+ simpleLoginSelfHostServerUrl = " " ,
646
668
duckDuckGoApiKey = " " ,
647
669
fastMailApiKey = " " ,
648
670
anonAddyApiAccessToken = " " ,
@@ -813,6 +835,14 @@ class GeneratorViewModel @Inject constructor(
813
835
}
814
836
}
815
837
838
+ private fun handleShouldShowSimpleLoginSelfHostValueChange (
839
+ action : GeneratorAction .Internal .ShouldShowSimpleLoginSelfHostValueChangeReceive ,
840
+ ) {
841
+ mutableStateFlow.update {
842
+ it.copy(shouldShowSimpleLoginSelfHostServerField = action.shouldShowSelfHostServerField)
843
+ }
844
+ }
845
+
816
846
private fun handlePasswordGeneratorPolicyReceive (
817
847
action : GeneratorAction .Internal .PasswordGeneratorPolicyReceive ,
818
848
) {
@@ -1392,6 +1422,21 @@ class GeneratorViewModel @Inject constructor(
1392
1422
}
1393
1423
}
1394
1424
1425
+ private fun handleSimpleLoginSelfHostServerUrlChange (
1426
+ action : GeneratorAction
1427
+ .MainType
1428
+ .Username
1429
+ .UsernameType
1430
+ .ForwardedEmailAlias
1431
+ .SimpleLogin
1432
+ .SelfHostServerUrlChange ,
1433
+ ) {
1434
+ updateSimpleLoginServiceType { simpleLoginServiceType ->
1435
+ val newServerUrl = action.url
1436
+ simpleLoginServiceType.copy(selfHostServerUrl = newServerUrl)
1437
+ }
1438
+ }
1439
+
1395
1440
// endregion SimpleLogin Service Specific Handlers
1396
1441
1397
1442
// region Plus Addressed Email Specific Handlers
@@ -1538,6 +1583,7 @@ class GeneratorViewModel @Inject constructor(
1538
1583
?.toUsernameGeneratorRequest(
1539
1584
website = state.website,
1540
1585
allowAddyIoSelfHostUrl = state.shouldShowAnonAddySelfHostServerUrlField,
1586
+ allowSimpleLoginSelfHostUrl = state.shouldShowSimpleLoginSelfHostServerField,
1541
1587
)
1542
1588
? : run {
1543
1589
mutableStateFlow.update { it.copy(generatedText = NO_GENERATED_TEXT ) }
@@ -1840,6 +1886,7 @@ data class GeneratorState(
1840
1886
var passcodePolicyOverride : PasscodePolicyOverride ? = null ,
1841
1887
private val shouldShowCoachMarkTour : Boolean ,
1842
1888
val shouldShowAnonAddySelfHostServerUrlField : Boolean ,
1889
+ val shouldShowSimpleLoginSelfHostServerField : Boolean ,
1843
1890
) : Parcelable {
1844
1891
1845
1892
/* *
@@ -2243,9 +2290,15 @@ data class GeneratorState(
2243
2290
@Parcelize
2244
2291
data class SimpleLogin (
2245
2292
val apiKey : String = " " ,
2293
+ val selfHostServerUrl : String = " " ,
2246
2294
) : ServiceType(), Parcelable {
2247
2295
override val displayStringResId: Int
2248
2296
get() = ServiceTypeOption .SIMPLE_LOGIN .labelRes
2297
+
2298
+ @Suppress(" UndocumentedPublicClass" )
2299
+ companion object {
2300
+ const val DEFAULT_SIMPLE_LOGIN_URL = " https://app.simplelogin.io"
2301
+ }
2249
2302
}
2250
2303
}
2251
2304
}
@@ -2586,6 +2639,13 @@ sealed class GeneratorAction {
2586
2639
* @property apiKey The new api key text.
2587
2640
*/
2588
2641
data class ApiKeyTextChange (val apiKey : String ) : SimpleLogin()
2642
+
2643
+ /* *
2644
+ * Fired when the self host server url input text is changed.
2645
+ *
2646
+ * @property url The new self host server url text.
2647
+ */
2648
+ data class SelfHostServerUrlChange (val url : String ) : SimpleLogin()
2589
2649
}
2590
2650
}
2591
2651
@@ -2704,6 +2764,13 @@ sealed class GeneratorAction {
2704
2764
data class ShouldShowAnonAddySelfHostValueChangeReceive (
2705
2765
val shouldShowAnonAddySelfHostServerUrlField : Boolean ,
2706
2766
) : Internal()
2767
+
2768
+ /* *
2769
+ * The value for the shouldShowSimpleLoginSelfHostServerField has changed.
2770
+ */
2771
+ data class ShouldShowSimpleLoginSelfHostValueChangeReceive (
2772
+ val shouldShowSelfHostServerField : Boolean ,
2773
+ ) : Internal()
2707
2774
}
2708
2775
}
2709
2776
0 commit comments