Login, Download and visuals update
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user