From 6bab6a459c4d9c179fecaffce4f99a9f92562211 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 10 Oct 2022 11:13:14 +0200 Subject: [PATCH] refactor(nc-gui): remove watcher from virtual cell icon --- .../smartsheet/header/VirtualCellIcon.ts | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/header/VirtualCellIcon.ts b/packages/nc-gui/components/smartsheet/header/VirtualCellIcon.ts index 850dadee6d..029543fb48 100644 --- a/packages/nc-gui/components/smartsheet/header/VirtualCellIcon.ts +++ b/packages/nc-gui/components/smartsheet/header/VirtualCellIcon.ts @@ -2,7 +2,7 @@ import type { PropType } from '@vue/runtime-core' import type { ColumnType, LinkToAnotherRecordType, LookupType } from 'nocodb-sdk' import type { Ref } from 'vue' import { RelationTypes, UITypes } from 'nocodb-sdk' -import { ColumnInj, MetaInj, defineComponent, h, inject, isBt, isHm, isLookup, isMm, isRollup, ref, toRef, watch } from '#imports' +import { ColumnInj, MetaInj, defineComponent, h, inject, isBt, isHm, isLookup, isMm, isRollup, ref, toRef } from '#imports' import GenericIcon from '~icons/mdi/square-rounded' import HMIcon from '~icons/mdi/table-arrow-right' import BTIcon from '~icons/mdi/table-arrow-left' @@ -67,36 +67,24 @@ export default defineComponent({ setup(props) { const columnMeta = toRef(props, 'columnMeta') - const column = inject(ColumnInj, ref(columnMeta)) as Ref + const column = inject(ColumnInj, columnMeta) as Ref let relationColumn: ColumnType & { colOptions: LookupType } - watch( - column, - () => { - if (column && column.value) { - if ( - isMm(column.value) || - isHm(column.value) || - isBt(column.value) || - isLookup(column.value) || - isRollup(column.value) - ) { - const meta = inject(MetaInj, ref()) + return () => { + if (!column.value) return null - relationColumn = meta.value?.columns?.find( - (c) => c.id === column.value?.colOptions?.fk_relation_column_id, - ) as ColumnType & { - colOptions: LinkToAnotherRecordType - } + if (column && column.value) { + if (isMm(column.value) || isHm(column.value) || isBt(column.value) || isLookup(column.value) || isRollup(column.value)) { + const meta = inject(MetaInj, ref()) + + relationColumn = meta.value?.columns?.find( + (c) => c.id === column.value?.colOptions?.fk_relation_column_id, + ) as ColumnType & { + colOptions: LinkToAnotherRecordType } } - }, - { immediate: true }, - ) - - return () => { - if (!column.value) return null + } const { icon: Icon, color } = renderIcon(column.value, relationColumn)