mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 23:32:14 +00:00
[UBER-829] Avoiding redundant table model rebuilding (#3668)
Signed-off-by: Oleg Solodkov <oleg.solodkov@xored.com>
This commit is contained in:
parent
466dcdf257
commit
153cbe65cc
@ -14,7 +14,18 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import core, { AnyAttribute, Class, Doc, DocumentQuery, FindOptions, Lookup, Ref } from '@hcengineering/core'
|
import { deepEqual } from 'fast-equals'
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
import core, {
|
||||||
|
AnyAttribute,
|
||||||
|
Class,
|
||||||
|
Doc,
|
||||||
|
DocumentQuery,
|
||||||
|
FindOptions,
|
||||||
|
Lookup,
|
||||||
|
Ref,
|
||||||
|
TxOperations
|
||||||
|
} from '@hcengineering/core'
|
||||||
import { getObjectValue, SortingOrder } from '@hcengineering/core'
|
import { getObjectValue, SortingOrder } from '@hcengineering/core'
|
||||||
import notification from '@hcengineering/notification'
|
import notification from '@hcengineering/notification'
|
||||||
import { createQuery, getClient, updateAttribute } from '@hcengineering/presentation'
|
import { createQuery, getClient, updateAttribute } from '@hcengineering/presentation'
|
||||||
@ -30,8 +41,7 @@
|
|||||||
showPopup,
|
showPopup,
|
||||||
Spinner
|
Spinner
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { AttributeModel, BuildModelKey } from '@hcengineering/view'
|
import { AttributeModel, BuildModelKey, BuildModelOptions } from '@hcengineering/view'
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
import view from '../plugin'
|
import view from '../plugin'
|
||||||
import { buildConfigLookup, buildModel, LoadingProps } from '../utils'
|
import { buildConfigLookup, buildModel, LoadingProps } from '../utils'
|
||||||
import Menu from './Menu.svelte'
|
import Menu from './Menu.svelte'
|
||||||
@ -234,11 +244,35 @@
|
|||||||
total: true
|
total: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let isBuildingModel = true
|
||||||
|
let model: AttributeModel[] | undefined
|
||||||
|
let modelOptions: BuildModelOptions | undefined
|
||||||
|
|
||||||
|
$: updateModelOptions(client, _class, config, lookup)
|
||||||
|
async function updateModelOptions (
|
||||||
|
client: TxOperations,
|
||||||
|
_class: Ref<Class<Doc>>,
|
||||||
|
config: (string | BuildModelKey)[],
|
||||||
|
lookup?: Lookup<Doc>
|
||||||
|
) {
|
||||||
|
const newModelOpts = { client, _class, keys: config, lookup }
|
||||||
|
if (modelOptions == null || !deepEqual(modelOptions, newModelOpts)) {
|
||||||
|
modelOptions = newModelOpts
|
||||||
|
await build(modelOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function build (modelOptions: BuildModelOptions) {
|
||||||
|
isBuildingModel = true
|
||||||
|
model = await buildModel(modelOptions)
|
||||||
|
isBuildingModel = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await buildModel({ client, _class, keys: config, lookup })}
|
{#if !model || isBuildingModel}
|
||||||
<Loading />
|
<Loading />
|
||||||
{:then model}
|
{:else}
|
||||||
<table
|
<table
|
||||||
id={tableId}
|
id={tableId}
|
||||||
use:resizeObserver={(element) => {
|
use:resizeObserver={(element) => {
|
||||||
@ -376,7 +410,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</table>
|
</table>
|
||||||
{#if loading > 0}<Loading />{/if}
|
{#if loading > 0}<Loading />{/if}
|
||||||
{/await}
|
{/if}
|
||||||
{#if showFooter}
|
{#if showFooter}
|
||||||
<div class="space" />
|
<div class="space" />
|
||||||
<div class="footer" style="width: {width}px;">
|
<div class="footer" style="width: {width}px;">
|
||||||
|
Loading…
Reference in New Issue
Block a user