fix: since loggedIn is determined by state we control, cache the value to avoid expensive lookups
This commit is contained in:
parent
d3ccb51df4
commit
ac8e2f5443
@ -16,11 +16,13 @@ object SDCredentials {
|
|||||||
.run { this?.userName to this?.getPasswordAsString() }
|
.run { this?.userName to this?.getPasswordAsString() }
|
||||||
set(value) {
|
set(value) {
|
||||||
PasswordSafe.instance[createCredentialAttributes("httpAuth")] = Credentials(value.first, value.second)
|
PasswordSafe.instance[createCredentialAttributes("httpAuth")] = Credentials(value.first, value.second)
|
||||||
|
loggedIn = value.first != null && value.second != null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logOut() {
|
fun logOut() {
|
||||||
PasswordSafe.instance[createCredentialAttributes("httpAuth")] = null
|
PasswordSafe.instance[createCredentialAttributes("httpAuth")] = null
|
||||||
PasswordSafe.instance[createCredentialAttributes("teamId")] = null
|
PasswordSafe.instance[createCredentialAttributes("teamId")] = null
|
||||||
|
loggedIn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
var url: String
|
var url: String
|
||||||
@ -34,4 +36,7 @@ object SDCredentials {
|
|||||||
set(value) {
|
set(value) {
|
||||||
PasswordSafe.instance[createCredentialAttributes("teamId")] = Credentials(value)
|
PasswordSafe.instance[createCredentialAttributes("teamId")] = Credentials(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var loggedIn: Boolean = credentials.first != null && credentials.second != null
|
||||||
|
private set
|
||||||
}
|
}
|
@ -291,8 +291,7 @@ object SDom {
|
|||||||
baos.toByteArray()
|
baos.toByteArray()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
val loggedIn: Boolean
|
val loggedIn: Boolean get() = SDCredentials.loggedIn
|
||||||
get() = SDCredentials.credentials.first != null && SDCredentials.credentials.second != null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user