mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
cd5e5b96da
* feat: init mobx and issue filter * feat: Implemented list and kanban views in plane space and integrated mobx. * feat: updated store type check
44 lines
936 B
TypeScript
44 lines
936 B
TypeScript
// mobx
|
|
import { observable, action, computed, makeObservable, runInAction } from "mobx";
|
|
// service
|
|
import UserService from "services/user.service";
|
|
// types
|
|
import { IUserStore } from "./types";
|
|
|
|
class UserStore implements IUserStore {
|
|
currentUser: any | null = null;
|
|
// root store
|
|
rootStore;
|
|
// service
|
|
userService;
|
|
|
|
constructor(_rootStore: any) {
|
|
makeObservable(this, {
|
|
// observable
|
|
currentUser: observable,
|
|
// actions
|
|
// computed
|
|
});
|
|
this.rootStore = _rootStore;
|
|
this.userService = new UserService();
|
|
}
|
|
|
|
getUserAsync = async () => {
|
|
try {
|
|
const response = this.userService.currentUser();
|
|
if (response) {
|
|
runInAction(() => {
|
|
this.currentUser = response;
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.error("error", error);
|
|
runInAction(() => {
|
|
// render error actions
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
export default UserStore;
|