Rewrite document store to keep all docs: filter and path selection without recreation. Much faster sorting and filtering.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user