From 638b3dffa3de2c948b966e0575b9af85a3ed54d0 Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Sat, 4 Feb 2023 21:23:30 +0100 Subject: perf(files): update files store by chunks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/store/files.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/files/src/store/files.ts b/apps/files/src/store/files.ts index c0ec1f7814b..96752653735 100644 --- a/apps/files/src/store/files.ts +++ b/apps/files/src/store/files.ts @@ -54,13 +54,17 @@ export const useFilesStore = defineStore('files', { actions: { updateNodes(nodes: Node[]) { - nodes.forEach(node => { + // Update the store all at once + const files = nodes.reduce((acc, node) => { if (!node.attributes.fileid) { logger.warn('Trying to update/set a node without fileid', node) - return + return acc } - Vue.set(this.files, node.attributes.fileid, node) - }) + acc[node.attributes.fileid] = node + return acc + }, {} as FilesStore) + + Vue.set(this, 'files', {...this.files, ...files}) }, setRoot({ service, root }: RootOptions) { -- cgit v1.2.3