mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 10:49:24 +02:00
39 lines
868 B
TypeScript
39 lines
868 B
TypeScript
import { Adb } from "@yume-chan/adb";
|
|
import { action, makeAutoObservable } from 'mobx';
|
|
|
|
export class GlobalState {
|
|
device: Adb | undefined;
|
|
errorDialogVisible = false;
|
|
errorDialogMessage = '';
|
|
|
|
logVisible = false;
|
|
|
|
constructor() {
|
|
makeAutoObservable(this, {
|
|
hideErrorDialog: action.bound,
|
|
toggleLog: action.bound,
|
|
});
|
|
}
|
|
|
|
setDevice(device: Adb | undefined) {
|
|
this.device = device;
|
|
device?.onDisconnected(() => {
|
|
this.setDevice(undefined);
|
|
});
|
|
}
|
|
|
|
showErrorDialog(message: string) {
|
|
this.errorDialogVisible = true;
|
|
this.errorDialogMessage = message;
|
|
}
|
|
|
|
hideErrorDialog() {
|
|
this.errorDialogVisible = false;
|
|
}
|
|
|
|
toggleLog() {
|
|
this.logVisible = !this.logVisible;
|
|
}
|
|
}
|
|
|
|
export const global = new GlobalState();
|