mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
Refactor account retrieval logic in LocalPreferences
- Add a check to verify if an account exists using `containsAccount` before attempting to retrieve it. - Move `DataStoreAccess.getEncryptedKey` outside the `sharedPrefs` apply block for better structure. - Ensure the method returns null early if the account is not found.
This commit is contained in:
@@ -442,12 +442,15 @@ object LocalPreferences {
|
||||
if (accountCache.get(npub) != null) {
|
||||
return accountCache.get(npub)
|
||||
}
|
||||
if (!containsAccount(context, npub)) {
|
||||
return null
|
||||
}
|
||||
val privKey = DataStoreAccess.getEncryptedKey(
|
||||
context,
|
||||
npub,
|
||||
DataStoreAccess.NOSTR_PRIVKEY,
|
||||
)
|
||||
sharedPrefs(context, npub).apply {
|
||||
val privKey = DataStoreAccess.getEncryptedKey(
|
||||
context,
|
||||
npub,
|
||||
DataStoreAccess.NOSTR_PRIVKEY,
|
||||
)
|
||||
val pubKey = getString(PrefKeys.NOSTR_PUBKEY.key, null) ?: return null
|
||||
val name = getString(PrefKeys.ACCOUNT_NAME.key, "") ?: ""
|
||||
val picture = getString(PrefKeys.PROFILE_URL.key, "") ?: ""
|
||||
|
||||
Reference in New Issue
Block a user