From 2b7f3936267acdb731a1176e21fdbd57420a2310 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 21 Oct 2021 10:24:41 +0100 Subject: [PATCH] Remove optional chaining from server --- .../server/src/api/controllers/table/utils.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.js b/packages/server/src/api/controllers/table/utils.js index 9b5f11d865..65c081f90e 100644 --- a/packages/server/src/api/controllers/table/utils.js +++ b/packages/server/src/api/controllers/table/utils.js @@ -266,13 +266,15 @@ exports.checkForViewUpdates = async (db, table, rename, deletedColumns) => { } // Update filters if required - view.meta.filters?.forEach(filter => { - if (filter.key === rename.old) { - filter.key = rename.updated - needsUpdated = true - } - }) - } else if (deletedColumns?.length) { + if (view.meta.filters) { + view.meta.filters.forEach(filter => { + if (filter.key === rename.old) { + filter.key = rename.updated + needsUpdated = true + } + }) + } + } else if (deletedColumns) { deletedColumns.forEach(column => { // Remove calculation statement if required if (view.meta.field === column) { @@ -289,7 +291,7 @@ exports.checkForViewUpdates = async (db, table, rename, deletedColumns) => { } // Remove filters referencing deleted field if required - if (view.meta.filters?.length) { + if (view.meta.filters && view.meta.filters.length) { const initialLength = view.meta.filters.length view.meta.filters = view.meta.filters.filter(filter => { return filter.key !== column