1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 00:03:22 +00:00

[EC-844] Improve Apple Watch states (#2246)

* EC-844 improve need login / need setup states on the watch

* EC-844 Fix naming of things and moved constant to the proper place to maintain format. Also removed UpdateLastUserShouldConnectToWatchAsync from the interface of the StateService given that it's not used outside the service and made it private
This commit is contained in:
Federico Maccaroni
2022-12-15 15:21:29 -03:00
committed by GitHub
parent a19b5c4e05
commit 728182de6c
5 changed files with 31 additions and 11 deletions

View File

@@ -84,6 +84,8 @@ namespace Bit.Core.Services
// Update pre-auth settings based on now-active user
await SetRememberedOrgIdentifierAsync(await GetRememberedOrgIdentifierAsync());
await SetPreAuthEnvironmentUrlsAsync(await GetEnvironmentUrlsAsync());
await SetLastUserShouldConnectToWatchAsync();
}
public async Task CheckExtensionActiveUserAndSwitchIfNeededAsync()
@@ -1708,6 +1710,21 @@ namespace Bit.Core.Services
ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync());
var key = Constants.ShouldConnectToWatchKey(reconciledOptions.UserId);
await SetValueAsync(key, shouldConnect, reconciledOptions);
await SetLastUserShouldConnectToWatchAsync(shouldConnect);
}
public async Task<bool> GetLastUserShouldConnectToWatchAsync()
{
var options = await GetDefaultStorageOptionsAsync();
var key = Constants.LastUserShouldConnectToWatchKey;
return await GetValueAsync<bool?>(key, options) ?? false;
}
private async Task SetLastUserShouldConnectToWatchAsync(bool? shouldConnect = null)
{
var options = await GetDefaultStorageOptionsAsync();
var key = Constants.LastUserShouldConnectToWatchKey;
await SetValueAsync(key, shouldConnect ?? await GetShouldConnectToWatchAsync(), options);
}
}
}