From 59e796985615770e29a7142906c68cb69f4e99b3 Mon Sep 17 00:00:00 2001 From: Matt Portune Date: Tue, 18 Jan 2022 19:31:32 -0500 Subject: [PATCH] cleanup --- src/Android/Push/FirebaseMessagingService.cs | 4 ++-- src/App/App.xaml.cs | 3 ++- src/Core/Abstractions/IStateService.cs | 4 ++-- src/Core/Services/StateService.cs | 14 ++++++-------- src/iOS.Extension/LoginListViewController.cs | 7 +------ 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/Android/Push/FirebaseMessagingService.cs b/src/Android/Push/FirebaseMessagingService.cs index 5351436c2..676390aef 100644 --- a/src/Android/Push/FirebaseMessagingService.cs +++ b/src/Android/Push/FirebaseMessagingService.cs @@ -16,10 +16,10 @@ namespace Bit.Droid.Push { public async override void OnNewToken(string token) { - var storageService = ServiceContainer.Resolve("storageService"); + var stateService = ServiceContainer.Resolve("stateService"); var pushNotificationService = ServiceContainer.Resolve("pushNotificationService"); - await storageService.SaveAsync(Core.Constants.PushRegisteredTokenKey, token); + await stateService.SetPushRegisteredTokenAsync(token); await pushNotificationService.RegisterAsync(); } diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index ccd40109c..9b67a71f3 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -273,8 +273,9 @@ namespace Bit.App Device.BeginInvokeOnMainThread(async () => { await SetMainPageAsync(); + UpdateTheme(); + await _vaultTimeoutService.CheckVaultTimeoutAsync(); }); - UpdateTheme(); } private async Task SetMainPageAsync() diff --git a/src/Core/Abstractions/IStateService.cs b/src/Core/Abstractions/IStateService.cs index 8ddce9325..68171dea3 100644 --- a/src/Core/Abstractions/IStateService.cs +++ b/src/Core/Abstractions/IStateService.cs @@ -133,8 +133,8 @@ namespace Bit.Core.Abstractions Task SetEncryptedFoldersAsync(Dictionary value, string userId = null); Task> GetEncryptedPoliciesAsync(string userId = null); Task SetEncryptedPoliciesAsync(Dictionary value, string userId = null); - Task GetPushRegisteredTokenAsync(string userId = null); - Task SetPushRegisteredTokenAsync(string value, string userId = null); + Task GetPushRegisteredTokenAsync(); + Task SetPushRegisteredTokenAsync(string value); Task GetAppExtensionStartedAsync(string userId = null); Task SetAppExtensionStartedAsync(bool? value, string userId = null); Task GetAppExtensionActivatedAsync(string userId = null); diff --git a/src/Core/Services/StateService.cs b/src/Core/Services/StateService.cs index f743d3f45..855c1fdeb 100644 --- a/src/Core/Services/StateService.cs +++ b/src/Core/Services/StateService.cs @@ -1051,20 +1051,18 @@ namespace Bit.Core.Services await SetValueAsync(key, value, reconciledOptions); } - public async Task GetPushRegisteredTokenAsync(string userId = null) + public async Task GetPushRegisteredTokenAsync() { - var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, - await GetDefaultStorageOptionsAsync()); + var options = await GetDefaultStorageOptionsAsync(); var key = Constants.PushRegisteredTokenKey; - return await GetValueAsync(key, reconciledOptions); + return await GetValueAsync(key, options); } - public async Task SetPushRegisteredTokenAsync(string value, string userId = null) + public async Task SetPushRegisteredTokenAsync(string value) { - var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, - await GetDefaultStorageOptionsAsync()); + var options = await GetDefaultStorageOptionsAsync(); var key = Constants.PushRegisteredTokenKey; - await SetValueAsync(key, value, reconciledOptions); + await SetValueAsync(key, value, options); } public async Task GetAppExtensionStartedAsync(string userId = null) diff --git a/src/iOS.Extension/LoginListViewController.cs b/src/iOS.Extension/LoginListViewController.cs index b42e2a7b3..ea7917c76 100644 --- a/src/iOS.Extension/LoginListViewController.cs +++ b/src/iOS.Extension/LoginListViewController.cs @@ -9,8 +9,6 @@ using MobileCoreServices; using Bit.iOS.Core.Controllers; using Bit.App.Resources; using Bit.iOS.Core.Views; -using Bit.Core.Utilities; -using Bit.Core.Abstractions; namespace Bit.iOS.Extension { @@ -127,10 +125,7 @@ namespace Bit.iOS.Extension if (_controller.CanAutoFill() && !string.IsNullOrWhiteSpace(item.Password)) { string totp = null; - var storageService = ServiceContainer.Resolve("storageService"); - var userId = _stateService.GetActiveUserIdAsync().GetAwaiter().GetResult(); - var disableTotpCopy = storageService.GetAsync( - Bit.Core.Constants.DisableAutoTotpCopyKey(userId)).GetAwaiter().GetResult(); + var disableTotpCopy = _stateService.GetDisableAutoTotpCopyAsync().GetAwaiter().GetResult(); if (!disableTotpCopy.GetValueOrDefault(false)) { totp = GetTotpAsync(item).GetAwaiter().GetResult();