Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ignore current entity id in HasSameContent #164

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions consumer-server/src/logic/has-content-changed-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ async function getManifestFiles(entityID: string, buildTarget: string): Promise<
}
}

async function getLastEntityIdByBase(base: string, contentServer: string): Promise<string | null> {
async function getLastEntityIdByBase(
currentEntityId: string,
base: string,
contentServer: string
): Promise<string | null> {
const url = `${contentServer}/pointer-changes?entityType=scene&sortingField=localTimestamp`

const res = await fetch(url)
Expand All @@ -52,7 +56,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
}
}
Expand Down Expand Up @@ -153,7 +157,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)
Expand Down
Loading