Skip to content

Commit

Permalink
Fix slow operations are prohibited on EDT
Browse files Browse the repository at this point in the history
Fix: #5251
  • Loading branch information
YiiGuxing committed Mar 12, 2024
1 parent fd94eff commit ae2c8fe
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import com.intellij.credentialStore.generateServiceName
import com.intellij.ide.passwordSafe.PasswordSafe
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import org.jetbrains.concurrency.runAsync
import java.util.*

@Service
@@ -41,15 +42,17 @@ internal class ReportCredentials private constructor() {
get() = PasswordSafe.instance.get(CredentialAttributes(SERVICE_NAME)) ?: anonymousCredentials

fun clear() {
PasswordSafe.instance.set(CredentialAttributes(SERVICE_NAME), null)
runAsync { PasswordSafe.instance.set(CredentialAttributes(SERVICE_NAME), null) }
lastUserName = ""
}

fun save(userName: String, token: String) {
check(userName.isNotBlank()) { "User name must not be blank" }
val credentials = Credentials(userName, token)
val attributes = CredentialAttributes(SERVICE_NAME, userName)
PasswordSafe.instance.set(attributes, credentials)
runAsync {
val credentials = Credentials(userName, token)
val attributes = CredentialAttributes(SERVICE_NAME, userName)
PasswordSafe.instance.set(attributes, credentials)
}
lastUserName = userName
}

0 comments on commit ae2c8fe

Please sign in to comment.