From f3936a79aa0f6b247f50866c3ac88daf21594962 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 19 Aug 2018 04:01:10 +0900 Subject: [PATCH] Fix #2335 --- src/server/api/endpoints/i/update.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index aa801b1b0..922b39679 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -105,17 +105,22 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a } } - if (wallpaperId) { - const wallpaper = await DriveFile.findOne({ - _id: wallpaperId - }); + if (wallpaperId !== undefined) { + if (wallpaperId === null) { + updates.wallpaperUrl = null; + updates.wallpaperColor = null; + } else { + const wallpaper = await DriveFile.findOne({ + _id: wallpaperId + }); - if (wallpaper == null) return rej('wallpaper not found'); + if (wallpaper == null) return rej('wallpaper not found'); - updates.wallpaperUrl = wallpaper.metadata.url || `${config.drive_url}/${wallpaper._id}`; + updates.wallpaperUrl = wallpaper.metadata.url || `${config.drive_url}/${wallpaper._id}`; - if (wallpaper.metadata.properties.avgColor) { - updates.wallpaperColor = wallpaper.metadata.properties.avgColor; + if (wallpaper.metadata.properties.avgColor) { + updates.wallpaperColor = wallpaper.metadata.properties.avgColor; + } } }