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
|
||||
|
||||
let user = await userSdk.db.getUser(ctx.user._id!)
|
||||
let requestAppFavourites: string[] = [...(update.appFavourites || [])]
|
||||
let updatedAppFavourites: string[] | undefined
|
||||
|
||||
if ("appFavourites" in update) {
|
||||
const appIds: string[] = processUserAppFavourites(
|
||||
user,
|
||||
update.appFavourites
|
||||
requestAppFavourites
|
||||
)
|
||||
const validAppIds: string[] = await syncAppFavourites(appIds)
|
||||
updatedAppFavourites = await syncAppFavourites(appIds)
|
||||
}
|
||||
|
||||
user = {
|
||||
...user,
|
||||
appFavourites: validAppIds,
|
||||
}
|
||||
} else {
|
||||
user = {
|
||||
...user,
|
||||
...update,
|
||||
}
|
||||
user = {
|
||||
...user,
|
||||
...update,
|
||||
...(updatedAppFavourites ? { appFavourites: updatedAppFavourites } : {}),
|
||||
}
|
||||
|
||||
user = await userSdk.db.save(user, { requirePassword: false })
|
||||
|
|
Loading…
Reference in New Issue