fix minor store renames

This commit is contained in:
rahulramesha 2024-03-04 20:32:36 +05:30
parent a2ba369114
commit 86e952eb1f
5 changed files with 13 additions and 13 deletions

View File

@ -1,10 +1,10 @@
import { IWorkspaceData, WorkspaceData } from "./workspace.data.store";
export class DataStore {
workspaceData: IWorkspaceData;
workspace: IWorkspaceData;
constructor() {
this.workspaceData = new WorkspaceData(this);
this.workspace = new WorkspaceData(this);
}
resetOnSignout() {}

View File

@ -1,5 +1,5 @@
import { makeObservable, observable } from "mobx";
import { WorkspaceModel } from "store/workspace.model";
import { WorkspaceModel } from "store/workspace.store";
import { DataStore } from ".";
import { IWorkspace } from "@plane/types";
import { set } from "lodash";

View File

@ -1,5 +1,5 @@
import { DataStore } from "./dataMaps";
import { IUserModel, UserModel } from "./user.model";
import { IUserModel, UserModel } from "./user.store";
export class RootStore {
data: DataStore;

View File

@ -3,7 +3,7 @@ import { WorkspaceService } from "services/workspace.service";
import set from "lodash/set";
import { IWorkspace } from "@plane/types";
import { DataStore } from "./dataMaps";
import { IWorkspaceModel } from "./workspace.model";
import { IWorkspaceModel } from "./workspace.store";
export interface IUserModel {
workspaces: Record<string, IWorkspaceModel>;
@ -13,15 +13,15 @@ export class UserModel implements IUserModel {
workspaces: Record<string, IWorkspaceModel> = {};
// data store
dataStore;
data;
// services
workspaceService;
constructor(_dataStore: DataStore) {
constructor(_data: DataStore) {
makeObservable(this, {
workspaces: observable,
});
this.dataStore = _dataStore;
this.data = _data;
this.workspaceService = new WorkspaceService();
}
@ -38,10 +38,10 @@ export class UserModel implements IUserModel {
fetchWorkspaces = async () => {
const workspaceResponse = await this.workspaceService.userWorkspaces();
this.dataStore.workspaceData.addWorkspaces(workspaceResponse);
this.data.workspace.addWorkspaces(workspaceResponse);
runInAction(() => {
workspaceResponse.forEach((workspace) => {
set(this.workspaces, [workspace.id], this.dataStore.workspaceData.workspaceMap[workspace.id]);
set(this.workspaces, [workspace.id], this.data.workspace.workspaceMap[workspace.id]);
});
});
return workspaceResponse;
@ -53,9 +53,9 @@ export class UserModel implements IUserModel {
*/
createWorkspace = async (data: Partial<IWorkspace>) =>
await this.workspaceService.createWorkspace(data).then((response) => {
this.dataStore.workspaceData.addWorkspaces([response]);
this.data.workspace.addWorkspaces([response]);
runInAction(() => {
set(this.workspaces, [response.id], this.dataStore.workspaceData.workspaceMap[response.id]);
set(this.workspaces, [response.id], this.data.workspace.workspaceMap[response.id]);
});
return response;
});
@ -68,7 +68,7 @@ export class UserModel implements IUserModel {
await this.workspaceService.deleteWorkspace(workspaceSlug).then(() => {
const updatedWorkspacesList = this.workspaces;
const workspaceId = this.getWorkspaceBySlug(workspaceSlug)?.id;
this.dataStore.workspaceData.deleteWorkspace(`${workspaceId}`);
this.data.workspace.deleteWorkspace(`${workspaceId}`);
runInAction(() => {
delete updatedWorkspacesList[`${workspaceId}`];
});