migrated messaging

This commit is contained in:
Kyle Spearrin 2019-06-01 23:33:36 -04:00
parent 1d95c73173
commit 0fc013eb8a
3 changed files with 24 additions and 2 deletions

View file

@ -31,7 +31,11 @@ namespace Bit.Droid
{ {
RegisterLocalServices(); RegisterLocalServices();
ServiceContainer.Init(); ServiceContainer.Init();
var task = App.Migration.MigrationHelpers.PerformMigrationAsync(); if(App.Migration.MigrationHelpers.NeedsMigration())
{
var task = App.Migration.MigrationHelpers.PerformMigrationAsync();
Task.Delay(2000).Wait();
}
} }
} }

View file

@ -99,6 +99,10 @@ namespace Bit.App
} }
else if(message.Command == "logout") else if(message.Command == "logout")
{ {
if(Migration.MigrationHelpers.Migrating)
{
return;
}
await LogOutAsync(false); await LogOutAsync(false);
} }
else if(message.Command == "loggedOut") else if(message.Command == "loggedOut")
@ -117,6 +121,11 @@ namespace Bit.App
SyncIfNeeded(); SyncIfNeeded();
} }
} }
else if(message.Command == "migrated")
{
await Task.Delay(1000);
await SetMainPageAsync();
}
}); });
} }
@ -295,6 +304,10 @@ namespace Bit.App
private void SyncIfNeeded() private void SyncIfNeeded()
{ {
if(Migration.MigrationHelpers.Migrating)
{
return;
}
Task.Run(async () => Task.Run(async () =>
{ {
var lastSync = await _syncService.GetLastSyncAsync(); var lastSync = await _syncService.GetLastSyncAsync();

View file

@ -5,12 +5,13 @@ using Bit.Core.Utilities;
using System; using System;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms;
namespace Bit.App.Migration namespace Bit.App.Migration
{ {
public static class MigrationHelpers public static class MigrationHelpers
{ {
public static bool Migrating = false;
public static bool NeedsMigration() public static bool NeedsMigration()
{ {
return ServiceContainer.Resolve<SettingsShim>("settingsShim") return ServiceContainer.Resolve<SettingsShim>("settingsShim")
@ -24,10 +25,12 @@ namespace Bit.App.Migration
return false; return false;
} }
Migrating = true;
var settingsShim = ServiceContainer.Resolve<SettingsShim>("settingsShim"); var settingsShim = ServiceContainer.Resolve<SettingsShim>("settingsShim");
var oldSecureStorageService = ServiceContainer.Resolve<Abstractions.IOldSecureStorageService>( var oldSecureStorageService = ServiceContainer.Resolve<Abstractions.IOldSecureStorageService>(
"oldSecureStorageService"); "oldSecureStorageService");
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
var storageService = ServiceContainer.Resolve<IStorageService>("storageService"); var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
var secureStorageService = ServiceContainer.Resolve<IStorageService>("secureStorageService"); var secureStorageService = ServiceContainer.Resolve<IStorageService>("secureStorageService");
var cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService"); var cryptoService = ServiceContainer.Resolve<ICryptoService>("cryptoService");
@ -159,6 +162,8 @@ namespace Bit.App.Migration
// Remove "needs migration" flag // Remove "needs migration" flag
settingsShim.Remove(Constants.OldUserIdKey); settingsShim.Remove(Constants.OldUserIdKey);
Migrating = false;
messagingService.Send("migrated");
return true; return true;
} }
} }