1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-17 15:27:43 +01:00

perform sync on update

This commit is contained in:
Kyle Spearrin 2017-10-28 21:36:27 -04:00
parent fea94f956d
commit d4cd2b8be8
3 changed files with 8 additions and 5 deletions

View File

@ -15,8 +15,9 @@ namespace Bit.Android
public override void OnReceive(Context context, Intent intent)
{
Debug.WriteLine("App updated!");
Helpers.PerformUpdateTasks(Resolver.Resolve<ISettings>(), Resolver.Resolve<IAppInfoService>(),
Resolver.Resolve<IDatabaseService>());
Helpers.PerformUpdateTasks(Resolver.Resolve<ISettings>(),
Resolver.Resolve<IAppInfoService>(),Resolver.Resolve<IDatabaseService>(),
Resolver.Resolve<ISyncService>());
}
}
}

View File

@ -103,7 +103,7 @@ namespace Bit.App
if(string.IsNullOrWhiteSpace(_uri))
{
Helpers.PerformUpdateTasks(_settings, _appInfoService, _databaseService);
Helpers.PerformUpdateTasks(_settings, _appInfoService, _databaseService, _syncService);
await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
}

View File

@ -1,6 +1,7 @@
using Bit.App.Abstractions;
using Plugin.Settings.Abstractions;
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Bit.App.Utilities
@ -41,14 +42,15 @@ namespace Bit.App.Utilities
#endif
}
public static bool PerformUpdateTasks(ISettings settings, IAppInfoService appInfoService,
IDatabaseService databaseService)
public static bool PerformUpdateTasks(ISettings settings,
IAppInfoService appInfoService, IDatabaseService databaseService, ISyncService syncService)
{
var lastBuild = settings.GetValueOrDefault(Constants.LastBuildKey, null);
if(InDebugMode() || lastBuild == null || lastBuild != appInfoService.Build)
{
settings.AddOrUpdateValue(Constants.LastBuildKey, appInfoService.Build);
databaseService.CreateTables();
var task = Task.Run(async () => await syncService.FullSyncAsync(true));
return true;
}