From dc07273476ffa3d43c869243b73739eafaed9624 Mon Sep 17 00:00:00 2001 From: Sahil Date: Thu, 19 Mar 2026 14:27:42 +0530 Subject: [PATCH] fix(ui): added optional chaining to getContentType to prevent undefined crash --- frontend/common/utils/utils.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/common/utils/utils.tsx b/frontend/common/utils/utils.tsx index 88389946f1a4..a4413975a6be 100644 --- a/frontend/common/utils/utils.tsx +++ b/frontend/common/utils/utils.tsx @@ -212,10 +212,10 @@ const Utils = Object.assign({}, require('./base/_utils'), { ) { const findAppended = `${value}`.includes(':') ? (conditions || []).find((v) => { - const split = value.split(':') - const targetKey = `:${split[split.length - 1]}` - return v.value === operator + targetKey - }) + const split = value.split(':') + const targetKey = `:${split[split.length - 1]}` + return v.value === operator + targetKey + }) : false if (findAppended) return findAppended @@ -228,7 +228,7 @@ const Utils = Object.assign({}, require('./base/_utils'), { return Object.prototype.hasOwnProperty.call(flagsmith.getAllFlags(), flag) }, getContentType(contentTypes: ContentType[], model: string, type: string) { - return contentTypes.find((c: ContentType) => c[model] === type) || null + return contentTypes?.find((c: ContentType) => c[model] === type) || null }, getCreateProjectPermission(organisation: Organisation) { if (organisation?.restrict_project_create_to_admin) { @@ -248,9 +248,9 @@ const Utils = Object.assign({}, require('./base/_utils'), { waitFor: string | undefined, ): | { - amountOfTime: number - timeUnit: (typeof TimeUnit)[keyof typeof TimeUnit] - } + amountOfTime: number + timeUnit: (typeof TimeUnit)[keyof typeof TimeUnit] + } | undefined => { if (!waitFor) { return @@ -670,7 +670,7 @@ const Utils = Object.assign({}, require('./base/_utils'), { }, loadScriptPromise(url: string) { return new Promise((resolve) => { - const cb = function () { + const cb = function() { // @ts-ignore this.removeEventListener('load', cb) resolve(null)