Rewrite document store to keep all docs: filter and path selection without recreation. Much faster sorting and filtering.

This commit is contained in:
Leo Vasanko
2023-11-06 21:50:29 +00:00
parent 6938740b0f
commit e3af21af91
8 changed files with 84 additions and 131 deletions

View File

@@ -4,21 +4,19 @@ import createWebSocket from './WS'
export type FUID = string
type BaseDocument = {
export type Document = {
loc: string[]
name: string
key: FUID
}
export type FolderDocument = BaseDocument & {
type: 'folder' | 'file'
size: number
sizedisp: string
mtime: number
modified: string
haystack: string
dir?: DirList
}
export type Document = FolderDocument
export type errorEvent = {
error: {
code: number
@@ -110,9 +108,9 @@ export class DocumentHandler {
private handleRootMessage({ root }: { root: DirEntry }) {
console.log('Watch root', root)
if (this.store && this.store.root) {
if (this.store) {
this.store.user.isLoggedIn = true
this.store.root = root
this.store.updateRoot(root)
}
}
private handleUpdateMessage(updateData: { update: UpdateEntry[] }) {
@@ -132,6 +130,7 @@ export class DocumentHandler {
if (elem.mtime !== undefined) node.mtime = elem.mtime
if (elem.dir !== undefined) node.dir = elem.dir
}
this.store.updateRoot()
}
private handleError(msg: errorEvent) {
if (msg.error.code === 401) {