diff --git a/src/App/Services/MobileStorageService.cs b/src/App/Services/MobileStorageService.cs index a80b039ea..5ebe09e1d 100644 --- a/src/App/Services/MobileStorageService.cs +++ b/src/App/Services/MobileStorageService.cs @@ -30,8 +30,15 @@ namespace Bit.App.Services Constants.MigratedFromV1AutofillPromptShown, Constants.TriedV1Resync, Constants.ClearCiphersCacheKey, + Constants.EnvironmentUrlsKey, }; + private readonly HashSet _migrateToPreferences = new HashSet + { + Constants.EnvironmentUrlsKey, + }; + private readonly HashSet _haveMigratedToPreferences = new HashSet(); + public MobileStorageService( IStorageService preferenceStorageService, IStorageService liteDbStorageService) @@ -40,13 +47,28 @@ namespace Bit.App.Services _liteDbStorageService = liteDbStorageService; } - public Task GetAsync(string key) + public async Task GetAsync(string key) { if(_preferenceStorageKeys.Contains(key)) { - return _preferencesStorageService.GetAsync(key); + var prefValue = await _preferencesStorageService.GetAsync(key); + if(prefValue != null || !_migrateToPreferences.Contains(key) || + _haveMigratedToPreferences.Contains(key)) + { + return prefValue; + } } - return _liteDbStorageService.GetAsync(key); + var liteDbValue = await _liteDbStorageService.GetAsync(key); + if(_migrateToPreferences.Contains(key)) + { + if(liteDbValue != null) + { + await _preferencesStorageService.SaveAsync(key, liteDbValue); + await _liteDbStorageService.RemoveAsync(key); + } + _haveMigratedToPreferences.Add(key); + } + return liteDbValue; } public Task SaveAsync(string key, T obj) diff --git a/src/App/Services/PreferencesStorageService.cs b/src/App/Services/PreferencesStorageService.cs index f67b9c621..758325977 100644 --- a/src/App/Services/PreferencesStorageService.cs +++ b/src/App/Services/PreferencesStorageService.cs @@ -13,7 +13,8 @@ namespace Bit.App.Services private readonly string _sharedName; private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { - ContractResolver = new CamelCasePropertyNamesContractResolver() + ContractResolver = new CamelCasePropertyNamesContractResolver(), + NullValueHandling = NullValueHandling.Ignore }; public PreferencesStorageService(string sharedName)