1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

Simplify shouldUpdate logic in SyncUpsertSendAsync

This commit is contained in:
Bernd Schoolmann
2023-08-03 17:21:42 +02:00
parent 73f3ffceb2
commit 743bf06b24

View File

@@ -281,27 +281,15 @@ namespace Bit.Core.Services
try
{
var shouldUpdate = true;
var localSend = await _sendService.GetAsync(notification.Id);
if (localSend != null && localSend.RevisionDate >= notification.RevisionDate)
{
shouldUpdate = false;
}
if (shouldUpdate)
if ((isEdit && localSend == null) || (!isEdit && localSend != null))
{
if (isEdit)
{
shouldUpdate = localSend != null;
}
else
{
shouldUpdate = localSend == null;
return SyncCompleted(false);
}
}
if (shouldUpdate)
{
var remoteSend = await _apiService.GetSendAsync(notification.Id);
if (remoteSend != null)
{
@@ -314,7 +302,6 @@ namespace Bit.Core.Services
return SyncCompleted(true);
}
}
}
catch (ApiException e)
{
if (e.Error != null && e.Error.StatusCode == System.Net.HttpStatusCode.NotFound && isEdit)