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