mirror of
https://github.com/bitwarden/android.git
synced 2024-12-21 00:31:58 +03:00
Incremental sync only every 30 minutes
This commit is contained in:
parent
bb4b732b76
commit
7b76f2c238
3 changed files with 15 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading.Tasks;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Bit.App.Abstractions
|
namespace Bit.App.Abstractions
|
||||||
{
|
{
|
||||||
|
@ -9,6 +10,7 @@ namespace Bit.App.Abstractions
|
||||||
Task<bool> SyncDeleteFolderAsync(string id);
|
Task<bool> SyncDeleteFolderAsync(string id);
|
||||||
Task<bool> SyncDeleteSiteAsync(string id);
|
Task<bool> SyncDeleteSiteAsync(string id);
|
||||||
Task<bool> FullSyncAsync();
|
Task<bool> FullSyncAsync();
|
||||||
|
Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold);
|
||||||
Task<bool> IncrementalSyncAsync();
|
Task<bool> IncrementalSyncAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace Bit.App
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _syncService.IncrementalSyncAsync();
|
await _syncService.IncrementalSyncAsync(TimeSpan.FromMinutes(30));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch(WebException)
|
catch(WebException)
|
||||||
|
|
|
@ -167,6 +167,17 @@ namespace Bit.App.Services
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold)
|
||||||
|
{
|
||||||
|
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(LastSyncKey);
|
||||||
|
if(lastSync != null && DateTime.UtcNow - lastSync.Value < syncThreshold)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await IncrementalSyncAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> IncrementalSyncAsync()
|
public async Task<bool> IncrementalSyncAsync()
|
||||||
{
|
{
|
||||||
if(!_authService.IsAuthenticated)
|
if(!_authService.IsAuthenticated)
|
||||||
|
|
Loading…
Reference in a new issue