Fix to for tenant favourite prefix

This commit is contained in:
Dean 2024-03-15 16:52:38 +00:00
parent 9245784bc8
commit 5696fe0030
1 changed files with 16 additions and 4 deletions

View File

@ -114,9 +114,16 @@ export const syncAppFavourites = async (processedAppIds: string[]) => {
if (processedAppIds.length === 0) { if (processedAppIds.length === 0) {
return [] return []
} }
const apps = await fetchAppsByIds(processedAppIds)
const tenantId = tenancy.getTenantId()
const appPrefix =
tenantId === tenancy.DEFAULT_TENANT_ID
? dbCore.APP_DEV_PREFIX
: `${dbCore.APP_DEV_PREFIX}${tenantId}_`
const apps = await fetchAppsByIds(processedAppIds, appPrefix)
return apps?.reduce((acc: string[], app) => { return apps?.reduce((acc: string[], app) => {
const id = app.appId.replace(dbCore.APP_DEV_PREFIX, "") const id = app.appId.replace(appPrefix, "")
if (processedAppIds.includes(id)) { if (processedAppIds.includes(id)) {
acc.push(id) acc.push(id)
} }
@ -124,9 +131,14 @@ export const syncAppFavourites = async (processedAppIds: string[]) => {
}, []) }, [])
} }
export const fetchAppsByIds = async (processedAppIds: string[]) => { export const fetchAppsByIds = async (
processedAppIds: string[],
appPrefix: string
) => {
return await dbCore.getAppsByIDs( return await dbCore.getAppsByIDs(
processedAppIds.map(appId => `${dbCore.APP_DEV_PREFIX}${appId}`) processedAppIds.map(appId => {
return `${appPrefix}${appId}`
})
) )
} }