mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
cascade null to sites on folder delete
This commit is contained in:
parent
cf8ee2273a
commit
d0fa6841c3
5 changed files with 23 additions and 4 deletions
|
@ -8,5 +8,6 @@ namespace Bit.App.Abstractions
|
||||||
public interface IFolderRepository : IRepository<FolderData, string>
|
public interface IFolderRepository : IRepository<FolderData, string>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<FolderData>> GetAllByUserIdAsync(string userId);
|
Task<IEnumerable<FolderData>> GetAllByUserIdAsync(string userId);
|
||||||
|
Task DeleteWithSiteUpdateAsync(string id, DateTime revisionDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Bit.App.Abstractions
|
||||||
{
|
{
|
||||||
bool SyncInProgress { get; }
|
bool SyncInProgress { get; }
|
||||||
Task<bool> SyncAsync(string id);
|
Task<bool> SyncAsync(string id);
|
||||||
Task<bool> SyncDeleteFolderAsync(string id);
|
Task<bool> SyncDeleteFolderAsync(string id, DateTime revisionDate);
|
||||||
Task<bool> SyncDeleteSiteAsync(string id);
|
Task<bool> SyncDeleteSiteAsync(string id);
|
||||||
Task<bool> FullSyncAsync();
|
Task<bool> FullSyncAsync();
|
||||||
Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold);
|
Task<bool> IncrementalSyncAsync(TimeSpan syncThreshold);
|
||||||
|
|
|
@ -18,5 +18,23 @@ namespace Bit.App.Repositories
|
||||||
var folders = Connection.Table<FolderData>().Where(f => f.UserId == userId).Cast<FolderData>();
|
var folders = Connection.Table<FolderData>().Where(f => f.UserId == userId).Cast<FolderData>();
|
||||||
return Task.FromResult(folders);
|
return Task.FromResult(folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task DeleteAsync(string id)
|
||||||
|
{
|
||||||
|
var now = DateTime.UtcNow;
|
||||||
|
DeleteWithSiteUpdateAsync(id, now);
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task DeleteWithSiteUpdateAsync(string id, DateTime revisionDate)
|
||||||
|
{
|
||||||
|
Connection.RunInTransaction(() =>
|
||||||
|
{
|
||||||
|
Connection.Execute("UPDATE Site SET FolderId = ?, RevisionDateTime = ? WHERE FolderId = ?", null, revisionDate, id);
|
||||||
|
Connection.Delete<FolderData>(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Bit.App.Services
|
||||||
break;
|
break;
|
||||||
case Enums.PushType.SyncFolderDelete:
|
case Enums.PushType.SyncFolderDelete:
|
||||||
var folderDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
var folderDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
||||||
_syncService.SyncDeleteFolderAsync(folderDeleteMessage.Id);
|
_syncService.SyncDeleteFolderAsync(folderDeleteMessage.Id, folderDeleteMessage.RevisionDate);
|
||||||
break;
|
break;
|
||||||
case Enums.PushType.SyncSiteDelete:
|
case Enums.PushType.SyncSiteDelete:
|
||||||
var siteDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
var siteDeleteMessage = values.ToObject<SyncCipherPushNotification>();
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace Bit.App.Services
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SyncDeleteFolderAsync(string id)
|
public async Task<bool> SyncDeleteFolderAsync(string id, DateTime revisionDate)
|
||||||
{
|
{
|
||||||
if(!_authService.IsAuthenticated)
|
if(!_authService.IsAuthenticated)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ namespace Bit.App.Services
|
||||||
|
|
||||||
SyncStarted();
|
SyncStarted();
|
||||||
|
|
||||||
await _folderRepository.DeleteAsync(id);
|
await _folderRepository.DeleteWithSiteUpdateAsync(id, revisionDate);
|
||||||
SyncCompleted(true);
|
SyncCompleted(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue