diff --git a/src/api/manager/job/syncInventory.ts b/src/api/manager/job/syncInventory.ts index 8c435846..444324cb 100644 --- a/src/api/manager/job/syncInventory.ts +++ b/src/api/manager/job/syncInventory.ts @@ -68,22 +68,15 @@ export async function runSyncInventory() { // If source was not found in response from API, always mark it as gone return { ...inventorySource, status: 'gone' } satisfies WithId; } - const statusUpdateCheck = () => { - const databaseStatus = inventorySource.status; - const apiStatus = apiSource.status; - if (apiStatus === 'new') { - return apiStatus; - } else if (databaseStatus === 'purge' && apiStatus === 'gone') { - return databaseStatus; - } else { - return apiStatus; - } - }; + + const databaseStatus = inventorySource.status; + const apiStatus = apiSource.status; + const isStatusGoneAndSetToPurge = databaseStatus === 'purge' && apiStatus === 'gone'; // Keep all old fields from the inventory source (name, tags, id, audio_stream etc), but update the status return { ...inventorySource, - status: statusUpdateCheck() + status: isStatusGoneAndSetToPurge ? databaseStatus : apiStatus } satisfies WithId; });