mirror of
https://github.com/bitwarden/mobile.git
synced 2025-02-25 02:41:26 +01:00
Apply Disable Favicon setting globally to match desktop (#1811)
* Apply Disable Favicon setting globally to match desktop * streamline the approach to applying global settings
This commit is contained in:
parent
be993bcd02
commit
f94812719d
@ -206,7 +206,6 @@ namespace Bit.App.Pages
|
||||
await _stateService.SetThemeAsync(theme);
|
||||
ThemeManager.SetTheme(Application.Current.Resources);
|
||||
_messagingService.Send("updatedTheme");
|
||||
_stateService.ApplyThemeGloballyAsync(theme).FireAndForget();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,6 @@ namespace Bit.Core.Abstractions
|
||||
Task SetRememberedOrgIdentifierAsync(string value);
|
||||
Task<string> GetThemeAsync(string userId = null);
|
||||
Task SetThemeAsync(string value, string userId = null);
|
||||
Task ApplyThemeGloballyAsync(string value);
|
||||
Task<bool?> GetAddSitePromptShownAsync(string userId = null);
|
||||
Task SetAddSitePromptShownAsync(bool? value, string userId = null);
|
||||
Task<bool?> GetPushInitialPromptShownAsync();
|
||||
|
@ -579,6 +579,9 @@ namespace Bit.Core.Services
|
||||
await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.DisableFaviconKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
|
||||
// TODO remove this to restore per-account DisableFavicon support
|
||||
SetValueGloballyAsync(Constants.DisableFaviconKey, value, reconciledOptions).FireAndForget();
|
||||
}
|
||||
|
||||
public async Task<bool?> GetDisableAutoTotpCopyAsync(string userId = null)
|
||||
@ -863,26 +866,9 @@ namespace Bit.Core.Services
|
||||
await GetDefaultStorageOptionsAsync());
|
||||
var key = Constants.ThemeKey(reconciledOptions.UserId);
|
||||
await SetValueAsync(key, value, reconciledOptions);
|
||||
}
|
||||
|
||||
public async Task ApplyThemeGloballyAsync(string value)
|
||||
{
|
||||
// TODO remove this method (ApplyThemeGlobally) to restore per-account theme support
|
||||
await CheckStateAsync();
|
||||
if (_state?.Accounts == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var activeUserId = await GetActiveUserIdAsync();
|
||||
foreach (var account in _state.Accounts)
|
||||
{
|
||||
var uid = account.Value?.Profile?.UserId;
|
||||
// skip active user (theme already set)
|
||||
if (uid != null && uid != activeUserId)
|
||||
{
|
||||
await SetThemeAsync(value, uid);
|
||||
}
|
||||
}
|
||||
// TODO remove this to restore per-account Theme support
|
||||
SetValueGloballyAsync(Constants.ThemeKey, value, reconciledOptions).FireAndForget();
|
||||
}
|
||||
|
||||
public async Task<bool?> GetAddSitePromptShownAsync(string userId = null)
|
||||
@ -1185,6 +1171,25 @@ namespace Bit.Core.Services
|
||||
await GetStorageService(options).SaveAsync(key, value);
|
||||
}
|
||||
|
||||
private async Task SetValueGloballyAsync<T>(Func<string, string> keyPrefix, T value, StorageOptions options)
|
||||
{
|
||||
await CheckStateAsync();
|
||||
if (_state?.Accounts == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// userId from options was already applied, skip those
|
||||
var userIdToSkip = options.UserId;
|
||||
foreach (var account in _state.Accounts)
|
||||
{
|
||||
var uid = account.Value?.Profile?.UserId;
|
||||
if (uid != null && uid != userIdToSkip)
|
||||
{
|
||||
await SetValueAsync(keyPrefix(uid), value, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IStorageService GetStorageService(StorageOptions options)
|
||||
{
|
||||
return options.UseSecureStorage.GetValueOrDefault(false) ? _secureStorageService : _storageService;
|
||||
|
Loading…
Reference in New Issue
Block a user