fix(fe/state_mgr): auto refresh is not applied

This commit is contained in:
hexxa 2022-02-15 17:16:02 +08:00 committed by Hexxa
parent 1314171a09
commit ecb35e2de1

View file

@ -14,6 +14,7 @@ import { UsersClient } from "../client/users";
import { SettingsClient } from "../client/settings"; import { SettingsClient } from "../client/settings";
import { IUsersClient, IFilesClient, ISettingsClient } from "../client"; import { IUsersClient, IFilesClient, ISettingsClient } from "../client";
import { loadingCtrl, ctrlOn, ctrlOff } from "../common/controls"; import { loadingCtrl, ctrlOn, ctrlOff } from "../common/controls";
import { CronTable } from "../common/cron";
export interface Props {} export interface Props {}
export interface State extends ICoreState {} export interface State extends ICoreState {}
@ -33,6 +34,18 @@ export class StateMgr extends React.Component<Props, State, {}> {
this.initUpdater(this.state, query); // don't await this.initUpdater(this.state, query); // don't await
} }
componentDidMount(): void {
CronTable().setInterval("refreshState", {
func: this.update,
args: [updater().updateAll],
delay: 1000,
});
}
componentWillUnmount() {
CronTable().clearInterval("refreshState");
}
setUsersClient = (client: IUsersClient) => { setUsersClient = (client: IUsersClient) => {
this.usersClient = client; this.usersClient = client;
}; };