sync: update LastAccessTime on push, pull & register

This commit is contained in:
Abdullah Atta
2025-08-01 11:39:18 +05:00
parent a96b0e1e42
commit c1f0e24d21
2 changed files with 17 additions and 7 deletions

View File

@@ -158,7 +158,7 @@ namespace Notesnook.API.Hubs
private static async IAsyncEnumerable<SyncTransferItemV2> PrepareChunks(Func<string, string[], bool, int, Task<IAsyncCursor<SyncItem>>>[] collections, string[] types, string userId, string[] ids, int size, bool resetSync, long maxBytes)
{
var chunksProcessed = 0;
var itemsProcessed = 0;
for (int i = 0; i < collections.Length; i++)
{
var type = types[i];
@@ -180,11 +180,12 @@ namespace Notesnook.API.Hubs
totalBytes += item.Length + METADATA_BYTES;
if (totalBytes >= maxBytes)
{
itemsProcessed += chunk.Count;
yield return new SyncTransferItemV2
{
Items = chunk,
Type = type,
Count = chunksProcessed
Count = itemsProcessed
};
totalBytes = 0;
@@ -194,11 +195,12 @@ namespace Notesnook.API.Hubs
}
if (chunk.Count > 0)
{
itemsProcessed += chunk.Count;
yield return new SyncTransferItemV2
{
Items = chunk,
Type = type,
Count = chunksProcessed
Count = itemsProcessed
};
}
}
@@ -211,9 +213,12 @@ namespace Notesnook.API.Hubs
SyncEventCounterSource.Log.FetchV2();
var deviceService = new SyncDeviceService(new SyncDevice(userId, deviceId));
var device = new SyncDevice(userId, deviceId);
var deviceService = new SyncDeviceService(device);
if (!deviceService.IsDeviceRegistered()) deviceService.RegisterDevice();
device.LastAccessTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var isResetSync = deviceService.IsSyncReset();
if (!deviceService.IsUnsynced() &&
!deviceService.IsSyncPending() &&