Skip to content

Commit d974f18

Browse files
Merge pull request #49 from andreasmolnardev/wallpaper-patch
Refactor old wallpaper retrieval logic
2 parents ba71491 + c96c9dc commit d974f18

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/api/v1/wallpapers/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ export async function POST(request: Request) {
7171
uploadForm.append('userId', userId);
7272

7373
// 6) get old wallpaper
74-
let old_wallpaper = await pb.collection('wallpaperStore').getFirstListItem(`userId="${userId}"`);
74+
// 6) get old wallpaper
75+
const userWallpapers = await pb.collection('wallpaperStore').getList(1, 1, {
76+
filter: `userId="${userId}"`,
77+
});
7578

79+
const old_wallpaper = userWallpapers.items?.[0] ?? null;
7680
// 7) create record in PB
7781
const record = await pb.collection('wallpaperStore').create(uploadForm);
7882

0 commit comments

Comments
 (0)