mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 19:20:35 -04:00
fix(files): paths store reactivity
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
1de3666e16
commit
cae00d2e96
3 changed files with 18 additions and 12 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
},
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -49,11 +49,15 @@ export interface RootOptions {
|
|||
|
||||
// Paths store
|
||||
export type ServicesState = {
|
||||
[service: Service]: PathsStore
|
||||
[service: Service]: PathConfig
|
||||
}
|
||||
|
||||
export type PathConfig = {
|
||||
[path: string]: number
|
||||
}
|
||||
|
||||
export type PathsStore = {
|
||||
[path: string]: number
|
||||
paths: ServicesState
|
||||
}
|
||||
|
||||
export interface PathOptions {
|
||||
|
|
@ -91,4 +95,4 @@ export interface ViewConfigs {
|
|||
}
|
||||
export interface ViewConfigStore {
|
||||
viewConfig: ViewConfigs
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue