forked from github/plane
3d09a69d58
* fix: eslint fixes --------- Co-authored-by: gurusainath <gurusainath007@gmail.com>
41 lines
944 B
TypeScript
41 lines
944 B
TypeScript
import { observable, action, makeObservable, runInAction } from "mobx";
|
|
// types
|
|
import { AppConfigService } from "services/app_config.service";
|
|
import { IAppConfig } from "@plane/types";
|
|
// services
|
|
|
|
export interface IAppConfigStore {
|
|
// observables
|
|
envConfig: IAppConfig | null;
|
|
// actions
|
|
fetchAppConfig: () => Promise<any>;
|
|
}
|
|
|
|
export class AppConfigStore implements IAppConfigStore {
|
|
// observables
|
|
envConfig: IAppConfig | null = null;
|
|
// service
|
|
appConfigService;
|
|
|
|
constructor() {
|
|
makeObservable(this, {
|
|
// observables
|
|
envConfig: observable.ref,
|
|
// actions
|
|
fetchAppConfig: action,
|
|
});
|
|
this.appConfigService = new AppConfigService();
|
|
}
|
|
|
|
/**
|
|
* Fetches the app config from the API
|
|
*/
|
|
fetchAppConfig = async () =>
|
|
await this.appConfigService.envConfig().then((config) => {
|
|
runInAction(() => {
|
|
this.envConfig = config;
|
|
});
|
|
return config;
|
|
});
|
|
}
|