Login, Download and visuals update

This commit is contained in:
2023-10-28 04:13:01 -05:00
parent 2b72508206
commit b3fd9637eb
16 changed files with 303 additions and 178 deletions

View File

@@ -23,6 +23,14 @@ export type FileDocument = BaseDocument & {
data: string;
};
export type errorEvent = {
error: {
code : number;
message: string;
redirect: string;
}
};
export type Document = FolderDocument | FileDocument;
@@ -44,19 +52,36 @@ export class DocumentHandler {
case !!msg.update:
this.handleUpdateMessage(msg);
break;
case !!msg.error:
this.handleError(msg);
break;
default:
}
}
private handleRootMessage({ root }: { root: FileStructure }) {
if (this.store && this.store.root) this.store.root = root;
if (this.store && this.store.root) {
this.store.user.isLoggedIn = true;
this.store.root = root;
}
}
private handleUpdateMessage(updateData: { update: FileStructure[] }) {
const root = updateData.update[0]
if(root) this.store.root = root
if(root) {
this.store.user.isLoggedIn = true;
this.store.root = root
}
}
private handleError(msg: errorEvent){
if(msg.error.code === 401){
this.store.user.isOpenLoginModal = true;
this.store.user.isLoggedIn = false;
return
}
}
}
export class DocumentUploadHandler {
constructor( private store: DocumentStore = useDocumentStore() ) {
this.handleWebSocketMessage = this.handleWebSocketMessage.bind(this);