From ab5b80eea4601b6dcc7bde2679ca8ab4b9caff07 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 24 Oct 2024 16:17:30 -0300 Subject: [PATCH 1/2] Ignore current entity id --- consumer-server/src/logic/has-content-changed-task.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consumer-server/src/logic/has-content-changed-task.ts b/consumer-server/src/logic/has-content-changed-task.ts index c185bb6..3189db0 100644 --- a/consumer-server/src/logic/has-content-changed-task.ts +++ b/consumer-server/src/logic/has-content-changed-task.ts @@ -39,7 +39,7 @@ async function getManifestFiles(entityID: string, buildTarget: string): Promise< } } -async function getLastEntityIdByBase(base: string, contentServer: string): Promise { +async function getLastEntityIdByBase(currentEntityId: string, base: string, contentServer: string): Promise { const url = `${contentServer}/pointer-changes?entityType=scene&sortingField=localTimestamp` const res = await fetch(url) @@ -52,7 +52,7 @@ async function getLastEntityIdByBase(base: string, contentServer: string): Promi // Iterate through the deltas array to find the first matching base, since order is DESC in the endpoint for (const delta of response.deltas) { const deltaBase = delta.metadata.scene?.base - if (deltaBase && deltaBase === base) { + if (deltaBase && deltaBase === base && delta.entityId !== currentEntityId) { return delta.entityId } } @@ -153,7 +153,7 @@ export async function hasContentChange( const entity = await getActiveEntity(entityId, contentServerUrl) if (entity.type === 'scene') { logger.info(`HasContentChanged: Entity ${entityId} is a scene`) - const previousHash = await getLastEntityIdByBase(entity.metadata.scene.base, contentServerUrl) + const previousHash = await getLastEntityIdByBase(entityId, entity.metadata.scene.base, contentServerUrl) if (previousHash !== null) { logger.info(`HasContentChanged: Previous hash is ${previousHash}`) const manifest = await getManifestFiles(previousHash, buildTarget) From 4f6d7a587b2491dd97194c688b4657821f350627 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Thu, 24 Oct 2024 16:18:25 -0300 Subject: [PATCH 2/2] lint fix --- consumer-server/src/logic/has-content-changed-task.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/consumer-server/src/logic/has-content-changed-task.ts b/consumer-server/src/logic/has-content-changed-task.ts index 3189db0..5177c11 100644 --- a/consumer-server/src/logic/has-content-changed-task.ts +++ b/consumer-server/src/logic/has-content-changed-task.ts @@ -39,7 +39,11 @@ async function getManifestFiles(entityID: string, buildTarget: string): Promise< } } -async function getLastEntityIdByBase(currentEntityId: string, base: string, contentServer: string): Promise { +async function getLastEntityIdByBase( + currentEntityId: string, + base: string, + contentServer: string +): Promise { const url = `${contentServer}/pointer-changes?entityType=scene&sortingField=localTimestamp` const res = await fetch(url)