1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +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) public override void OnReceive(Context context, Intent intent)
{ {
Debug.WriteLine("App updated!"); Debug.WriteLine("App updated!");
Helpers.PerformUpdateTasks(Resolver.Resolve<ISettings>(), Resolver.Resolve<IAppInfoService>(), Helpers.PerformUpdateTasks(Resolver.Resolve<ISettings>(),
Resolver.Resolve<IDatabaseService>()); Resolver.Resolve<IAppInfoService>(),Resolver.Resolve<IDatabaseService>(),
Resolver.Resolve<ISyncService>());
} }
} }
} }

View File

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

View File

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