diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-21 15:41:28 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-21 15:49:54 +0200 |
commit | cae00d2e965931efeb6ca5386d4dd2cff9f7dc62 (patch) | |
tree | baff1fa6a15644d06a1a9906a5d031a80bc8217c /apps | |
parent | 1de3666e16af8362789d7a000c93b9aea1229c12 (diff) | |
download | nextcloud-server-cae00d2e965931efeb6ca5386d4dd2cff9f7dc62.tar.gz nextcloud-server-cae00d2e965931efeb6ca5386d4dd2cff9f7dc62.zip |
fix(files): paths store reactivity
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/src/store/files.ts | 4 | ||||
-rw-r--r-- | apps/files/src/store/paths.ts | 16 | ||||
-rw-r--r-- | apps/files/src/types.ts | 10 |
3 files changed, 18 insertions, 12 deletions
diff --git a/apps/files/src/store/files.ts b/apps/files/src/store/files.ts index ea516a886d9..bd7d3202dd9 100644 --- a/apps/files/src/store/files.ts +++ b/apps/files/src/store/files.ts @@ -59,11 +59,11 @@ export const useFilesStore = function() { updateNodes(nodes: Node[]) { // Update the store all at once const files = nodes.reduce((acc, node) => { - if (!node.attributes.fileid) { + if (!node.fileid) { logger.warn('Trying to update/set a node without fileid', node) return acc } - acc[node.attributes.fileid] = node + acc[node.fileid] = node return acc }, {} as FilesStore) diff --git a/apps/files/src/store/paths.ts b/apps/files/src/store/paths.ts index c9335304bce..ecff97bf00c 100644 --- a/apps/files/src/store/paths.ts +++ b/apps/files/src/store/paths.ts @@ -24,20 +24,22 @@ import type { PathOptions, ServicesState } from '../types.ts' import { defineStore } from 'pinia' import { subscribe } from '@nextcloud/event-bus' -import type { FileId } from '../types' +import type { FileId, PathsStore } from '../types' import Vue from 'vue' export const usePathsStore = function() { const store = defineStore('paths', { - state: (): ServicesState => ({}), + state: () => ({ + paths: {} as ServicesState + } as PathsStore), getters: { getPath: (state) => { return (service: string, path: string): FileId|undefined => { - if (!state[service]) { + if (!state.paths[service]) { return undefined } - return state[service][path] + return state.paths[service][path] } }, }, @@ -45,12 +47,12 @@ export const usePathsStore = function() { actions: { addPath(payload: PathOptions) { // If it doesn't exists, init the service state - if (!this[payload.service]) { - Vue.set(this, payload.service, {}) + if (!this.paths[payload.service]) { + Vue.set(this.paths, payload.service, {}) } // Now we can set the provided path - Vue.set(this[payload.service], payload.path, payload.fileid) + Vue.set(this.paths[payload.service], payload.path, payload.fileid) }, } }) diff --git a/apps/files/src/types.ts b/apps/files/src/types.ts index cca6fb9111f..c04a9538827 100644 --- a/apps/files/src/types.ts +++ b/apps/files/src/types.ts @@ -49,13 +49,17 @@ export interface RootOptions { // Paths store export type ServicesState = { - [service: Service]: PathsStore + [service: Service]: PathConfig } -export type PathsStore = { +export type PathConfig = { [path: string]: number } +export type PathsStore = { + paths: ServicesState +} + export interface PathOptions { service: Service path: string @@ -91,4 +95,4 @@ export interface ViewConfigs { } export interface ViewConfigStore { viewConfig: ViewConfigs -}
\ No newline at end of file +} |