From 53db52bb406bae2492b6695c5d64a3702a4f26fa Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Dec 2017 19:38:49 +0900 Subject: [PATCH] Refactor --- src/api/serializers/drive-file.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/api/serializers/drive-file.ts b/src/api/serializers/drive-file.ts index dcdaa01fa..92a9492d8 100644 --- a/src/api/serializers/drive-file.ts +++ b/src/api/serializers/drive-file.ts @@ -56,18 +56,20 @@ export default ( _target.url = `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`; - if (opts.detail && _target.folder_id) { - // Populate folder - _target.folder = await serializeDriveFolder(_target.folder_id, { - detail: true - }); - } + if (opts.detail) { + if (_target.folder_id) { + // Populate folder + _target.folder = await serializeDriveFolder(_target.folder_id, { + detail: true + }); + } - if (opts.detail && _target.tags) { - // Populate tags - _target.tags = await _target.tags.map(async (tag: any) => - await serializeDriveTag(tag) - ); + if (_target.tags) { + // Populate tags + _target.tags = await _target.tags.map(async (tag: any) => + await serializeDriveTag(tag) + ); + } } resolve(_target);