From 3882bd16924b71e2df60551a914b732cc0004b97 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 25 Nov 2022 19:40:15 +0530 Subject: [PATCH] fix: parse attachment column value if string Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Gallery.vue | 7 ++++++- packages/nc-gui/components/smartsheet/Kanban.vue | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index f5ff3056f0..3b3f5ac263 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -80,7 +80,12 @@ const isRowEmpty = (record: any, col: any) => { const attachments = (record: any): Attachment[] => { try { - return coverImageColumn?.title && record.row[coverImageColumn.title] ? JSON.parse(record.row[coverImageColumn.title]) : [] + if (coverImageColumn?.title && record.row[coverImageColumn.title]) { + return typeof record.row[coverImageColumn.title] === 'string' + ? JSON.parse(record.row[coverImageColumn.title]) + : record.row[coverImageColumn.title] + } + return [] } catch (e) { return [] } diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vue index 4d14c576e5..973d0ed10e 100644 --- a/packages/nc-gui/components/smartsheet/Kanban.vue +++ b/packages/nc-gui/components/smartsheet/Kanban.vue @@ -116,7 +116,12 @@ reloadViewDataHook?.on(async () => { const attachments = (record: any): Attachment[] => { try { - return coverImageColumn?.title && record.row[coverImageColumn.title] ? JSON.parse(record.row[coverImageColumn.title]) : [] + if (coverImageColumn?.title && record.row[coverImageColumn.title]) { + return typeof record.row[coverImageColumn.title] === 'string' + ? JSON.parse(record.row[coverImageColumn.title]) + : record.row[coverImageColumn.title] + } + return [] } catch (e) { return [] }