1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-26 16:57:59 +01:00

clear cache in main app if change made in extension

This commit is contained in:
Kyle Spearrin 2019-07-06 22:49:17 -04:00
parent cf35d20adb
commit 62d8824450
5 changed files with 37 additions and 10 deletions

View File

@ -162,6 +162,7 @@ namespace Bit.App
{
System.Diagnostics.Debug.WriteLine("XF App: OnStart");
await ClearCacheIfNeededAsync();
await TryClearCiphersCacheAsync();
Prime();
if(string.IsNullOrWhiteSpace(_appOptions.Uri))
{
@ -185,7 +186,7 @@ namespace Bit.App
await HandleLockingAsync();
}
protected async override void OnResume()
protected override void OnResume()
{
System.Diagnostics.Debug.WriteLine("XF App: OnResume");
if(Device.RuntimePlatform == Device.Android)
@ -198,6 +199,7 @@ namespace Bit.App
{
_messagingService.Send("cancelLockTimer");
await ClearCacheIfNeededAsync();
await TryClearCiphersCacheAsync();
Prime();
SyncIfNeeded();
if(Current.MainPage is NavigationPage navPage && navPage.CurrentPage is LockPage lockPage)
@ -356,5 +358,19 @@ namespace Bit.App
}
});
}
private async Task TryClearCiphersCacheAsync()
{
if(Device.RuntimePlatform != Device.iOS)
{
return;
}
var clearCache = await _storageService.GetAsync<bool?>(Constants.ClearCiphersCacheKey);
if(clearCache.GetValueOrDefault())
{
_cipherService.ClearCache();
await _storageService.RemoveAsync(Constants.ClearCiphersCacheKey);
}
}
}
}

View File

@ -8,6 +8,8 @@ using Bit.Core.Utilities;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
namespace Bit.App.Pages
{
@ -59,6 +61,9 @@ namespace Bit.App.Pages
ToolbarItems.Add(_moreItem);
}
_vm.ShowNotesSeparator = true;
_typePicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
_ownershipPicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
}
_typePicker.ItemDisplayBinding = new Binding("Key");
@ -156,7 +161,7 @@ namespace Bit.App.Pages
{
if(FromAutofillFramework)
{
Application.Current.MainPage = new TabsPage();
Xamarin.Forms.Application.Current.MainPage = new TabsPage();
return true;
}
return base.OnBackButtonPressed();
@ -166,7 +171,8 @@ namespace Bit.App.Pages
{
if(DoOnce())
{
await Navigation.PushModalAsync(new NavigationPage(new PasswordHistoryPage(_vm.CipherId)));
await Navigation.PushModalAsync(
new Xamarin.Forms.NavigationPage(new PasswordHistoryPage(_vm.CipherId)));
}
}
@ -193,7 +199,7 @@ namespace Bit.App.Pages
if(DoOnce())
{
var page = new AttachmentsPage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}
@ -202,7 +208,7 @@ namespace Bit.App.Pages
if(DoOnce())
{
var page = new SharePage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}
@ -222,7 +228,7 @@ namespace Bit.App.Pages
if(DoOnce())
{
var page = new CollectionsPage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}
@ -238,7 +244,7 @@ namespace Bit.App.Pages
await _vm.UpdateTotpKeyAsync(key);
});
});
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}
@ -265,17 +271,17 @@ namespace Bit.App.Pages
else if(selection == AppResources.Attachments)
{
var page = new AttachmentsPage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
else if(selection == AppResources.Collections)
{
var page = new CollectionsPage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
else if(selection == AppResources.Share)
{
var page = new SharePage(_vm.CipherId);
await Navigation.PushModalAsync(new NavigationPage(page));
await Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(page));
}
}

View File

@ -31,6 +31,7 @@ namespace Bit.App.Services
Constants.MigratedFromV1,
Constants.MigratedFromV1AutofillPromptShown,
Constants.TriedV1Resync,
Constants.ClearCiphersCacheKey,
};
public MobileStorageService(

View File

@ -28,6 +28,7 @@
public static string LastBuildKey = "lastBuild";
public static string OldUserIdKey = "userId";
public static string AddSitePromptShownKey = "addSitePromptShown";
public static string ClearCiphersCacheKey = "clearCiphersCache";
public static string MigratedFromV1 = "migratedFromV1";
public static string MigratedFromV1AutofillPromptShown = "migratedV1AutofillPromptShown";
public static string TriedV1Resync = "triedV1Resync";

View File

@ -20,6 +20,7 @@ namespace Bit.iOS.Core.Controllers
{
private ICipherService _cipherService;
private IFolderService _folderService;
private IStorageService _storageService;
private IEnumerable<FolderView> _folders;
public LoginAddViewController(IntPtr handle)
@ -47,6 +48,7 @@ namespace Bit.iOS.Core.Controllers
{
_cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
_folderService = ServiceContainer.Resolve<IFolderService>("folderService");
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
BaseNavItem.Title = AppResources.AddItem;
BaseCancelButton.Title = AppResources.Cancel;
@ -168,6 +170,7 @@ namespace Bit.iOS.Core.Controllers
var cipherDomain = await _cipherService.EncryptAsync(cipher);
await _cipherService.SaveWithServerAsync(cipherDomain);
await loadingAlert.DismissViewControllerAsync(true);
await _storageService.SaveAsync(Bit.Core.Constants.ClearCiphersCacheKey, true);
if(await ASHelpers.IdentitiesCanIncremental())
{
var identity = await ASHelpers.GetCipherIdentityAsync(cipherDomain.Id);