1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 08:13:20 +00:00

update tasks and sync on app start

This commit is contained in:
Kyle Spearrin
2019-05-30 14:13:02 -04:00
parent dc7b37c8f2
commit 6d51864873
7 changed files with 98 additions and 4 deletions

View File

@@ -106,6 +106,13 @@ namespace Bit.App
{
// TODO
}
else if(message.Command == "resumed")
{
if(Device.RuntimePlatform == Device.iOS)
{
SyncIfNeeded();
}
}
});
}
@@ -114,6 +121,15 @@ namespace Bit.App
System.Diagnostics.Debug.WriteLine("XF App: OnStart");
await ClearCacheIfNeededAsync();
Prime();
if(string.IsNullOrWhiteSpace(_appOptions.Uri))
{
var updated = await AppHelpers.PerformUpdateTasksAsync(_syncService, _deviceActionService,
_storageService);
if(!updated)
{
SyncIfNeeded();
}
}
}
protected async override void OnSleep()
@@ -129,6 +145,10 @@ namespace Bit.App
_messagingService.Send("cancelLockTimer");
await ClearCacheIfNeededAsync();
Prime();
if(Device.RuntimePlatform == Device.Android)
{
SyncIfNeeded();
}
}
private void SetCulture()
@@ -264,5 +284,17 @@ namespace Bit.App
var mainPageTask = SetMainPageAsync();
ServiceContainer.Resolve<MobilePlatformUtilsService>("platformUtilsService").Init();
}
private void SyncIfNeeded()
{
Task.Run(async () =>
{
var lastSync = await _syncService.GetLastSyncAsync();
if(DateTime.UtcNow - lastSync > TimeSpan.FromMinutes(30))
{
await _syncService.FullSyncAsync(false);
}
});
}
}
}