Update to update self endpoint to make remove distinct flow for appFavourites
This commit is contained in:
parent
e3fba2aa05
commit
8c90d422c2
|
@ -164,23 +164,21 @@ export async function updateSelf(
|
||||||
const update = ctx.request.body
|
const update = ctx.request.body
|
||||||
|
|
||||||
let user = await userSdk.db.getUser(ctx.user._id!)
|
let user = await userSdk.db.getUser(ctx.user._id!)
|
||||||
|
let requestAppFavourites: string[] = [...(update.appFavourites || [])]
|
||||||
|
let updatedAppFavourites: string[] | undefined
|
||||||
|
|
||||||
if ("appFavourites" in update) {
|
if ("appFavourites" in update) {
|
||||||
const appIds: string[] = processUserAppFavourites(
|
const appIds: string[] = processUserAppFavourites(
|
||||||
user,
|
user,
|
||||||
update.appFavourites
|
requestAppFavourites
|
||||||
)
|
)
|
||||||
const validAppIds: string[] = await syncAppFavourites(appIds)
|
updatedAppFavourites = await syncAppFavourites(appIds)
|
||||||
|
}
|
||||||
|
|
||||||
user = {
|
user = {
|
||||||
...user,
|
...user,
|
||||||
appFavourites: validAppIds,
|
...update,
|
||||||
}
|
...(updatedAppFavourites ? { appFavourites: updatedAppFavourites } : {}),
|
||||||
} else {
|
|
||||||
user = {
|
|
||||||
...user,
|
|
||||||
...update,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user = await userSdk.db.save(user, { requirePassword: false })
|
user = await userSdk.db.save(user, { requirePassword: false })
|
||||||
|
|
Loading…
Reference in New Issue