[WEB-5128] refactor: remove local database dependencies and unused code (#8109)

This commit is contained in:
Prateek Shourya 2025-11-13 18:32:15 +05:30 committed by GitHub
parent 64f90b828b
commit 80670b2b3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 36 additions and 6242 deletions

View file

@ -15,7 +15,6 @@ import type { DistributionUpdates } from "@plane/utils";
import { orderCycles, shouldFilterCycle, getDate, updateDistribution } from "@plane/utils";
// helpers
// services
import { syncIssuesWithDeletedCycles } from "@/local-db/utils/load-workspace";
import { CycleService } from "@/services/cycle.service";
import { CycleArchiveService } from "@/services/cycle_archive.service";
import { IssueService } from "@/services/issue";
@ -618,7 +617,6 @@ export class CycleStore implements ICycleStore {
delete this.cycleMap[cycleId];
delete this.activeCycleIdMap[cycleId];
if (this.rootStore.favorite.entityMap[cycleId]) this.rootStore.favorite.removeFavoriteFromStore(cycleId);
syncIssuesWithDeletedCycles([cycleId]);
});
});

View file

@ -9,8 +9,6 @@ import type {
} from "@plane/types";
import { EInboxIssueStatus } from "@plane/types";
// helpers
// local db
import { addIssueToPersistanceLayer } from "@/local-db/utils/utils";
// services
import { InboxIssueService } from "@/services/inbox";
import { IssueService } from "@/services/issue";
@ -109,7 +107,6 @@ export class InboxIssueStore implements IInboxIssueStore {
if (status === EInboxIssueStatus.ACCEPTED) {
const updatedIssue = { ...this.issue, ...inboxIssue.issue };
this.store.issue.issues.addIssue([updatedIssue]);
await addIssueToPersistanceLayer(updatedIssue);
}
} catch {
runInAction(() => set(this, "status", previousData.status));

View file

@ -243,7 +243,7 @@ export class CycleIssuesFilter extends IssueFilterHelperStore implements ICycleI
});
if (this.getShouldClearIssues(updatedDisplayFilters)) {
this.rootIssueStore.cycleIssues.clear(true, true); // clear issues for local store when some filters like layout changes
this.rootIssueStore.cycleIssues.clear(true); // clear issues for local store when some filters like layout changes
}
if (this.getShouldReFetchIssues(updatedDisplayFilters)) {

View file

@ -15,7 +15,6 @@ import type {
import { getDistributionPathsPostUpdate } from "@plane/utils";
//local
import { storage } from "@/lib/local-storage";
import { persistence } from "@/local-db/storage.sqlite";
import type { IBaseIssuesStore } from "../helpers/base-issues.store";
import { BaseIssuesStore } from "../helpers/base-issues.store";
//
@ -190,8 +189,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues {
// set loader and clear store
runInAction(() => {
this.setLoader(loadType);
this.clear(!isExistingPaginationOptions, false); // clear while fetching from server.
if (!this.groupBy) this.clear(!isExistingPaginationOptions, true); // clear while using local to have the no load effect.
this.clear(!isExistingPaginationOptions); // clear while fetching from server.
});
// get params from pagination options
@ -315,7 +313,6 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues {
);
// call fetch issues
if (this.paginationOptions) {
await persistence.syncIssues(projectId.toString());
await this.fetchIssues(workspaceSlug, projectId, "mutation", this.paginationOptions, cycleId);
}

View file

@ -23,9 +23,7 @@ import type {
import { EIssueServiceType, EIssueLayoutTypes } from "@plane/types";
// helpers
import { convertToISODateString } from "@plane/utils";
// local-db
import { SPECIAL_ORDER_BY } from "@/local-db/utils/query-constructor";
import { updatePersistentLayer } from "@/local-db/utils/utils";
// plane web imports
import { workItemSortWithOrderByExtended } from "@/plane-web/store/issue/helpers/base-issue.store";
// services
import { CycleService } from "@/services/cycle.service";
@ -60,7 +58,7 @@ export interface IBaseIssuesStore {
//actions
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
clear(shouldClearPaginationOptions?: boolean, clearForLocal?: boolean): void;
clear(shouldClearPaginationOptions?: boolean): void;
// helper methods
getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined;
issuesSortWithOrderBy(issueIds: string[], key: Partial<TIssueOrderByOptions>): string[];
@ -281,13 +279,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
const orderBy = displayFilters.order_by;
// Temporary code to fix no load order by
if (
this.rootIssueStore.rootStore.user.localDBEnabled &&
this.rootIssueStore.rootStore.router.projectId &&
layout !== EIssueLayoutTypes.SPREADSHEET &&
orderBy &&
Object.keys(SPECIAL_ORDER_BY).includes(orderBy)
) {
if (this.rootIssueStore.rootStore.router.projectId && layout !== EIssueLayoutTypes.SPREADSHEET && orderBy) {
return "sort_order";
}
@ -483,7 +475,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
// Update all the GroupIds to this Store's groupedIssueIds and update Individual group issue counts
runInAction(() => {
this.clear(shouldClearPaginationOptions, true);
this.clear(shouldClearPaginationOptions);
this.updateGroupedIssueIds(groupedIssues, groupedIssueCount);
this.loader[getGroupKey()] = undefined;
});
@ -549,8 +541,6 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
// If shouldUpdateList is true, call fetchParentStats
shouldUpdateList && (await this.fetchParentStats(workspaceSlug, projectId));
updatePersistentLayer(response.id);
return response;
}
@ -1162,22 +1152,17 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
/**
* Method called to clear out the current store
*/
clear(shouldClearPaginationOptions = true, clearForLocal = false) {
if (
(this.rootIssueStore.rootStore.user?.localDBEnabled && clearForLocal) ||
(!this.rootIssueStore.rootStore.user?.localDBEnabled && !clearForLocal)
) {
runInAction(() => {
this.groupedIssueIds = undefined;
this.issuePaginationData = {};
this.groupedIssueCount = {};
if (shouldClearPaginationOptions) {
this.paginationOptions = undefined;
}
});
this.controller.abort();
this.controller = new AbortController();
}
clear(shouldClearPaginationOptions = true) {
runInAction(() => {
this.groupedIssueIds = undefined;
this.issuePaginationData = {};
this.groupedIssueCount = {};
if (shouldClearPaginationOptions) {
this.paginationOptions = undefined;
}
});
this.controller.abort();
this.controller = new AbortController();
}
/**

View file

@ -3,8 +3,6 @@ import { computedFn } from "mobx-utils";
// types
import type { TIssue, TIssueServiceType } from "@plane/types";
import { EIssueServiceType } from "@plane/types";
// local
import { persistence } from "@/local-db/storage.sqlite";
// services
import { IssueArchiveService, WorkspaceDraftService, IssueService } from "@/services/issue";
// types
@ -32,7 +30,6 @@ export interface IIssueStoreActions {
export interface IIssueStore extends IIssueStoreActions {
getIsFetchingIssueDetails: (issueId: string | undefined) => boolean;
getIsLocalDBIssueDescription: (issueId: string | undefined) => boolean;
// helper methods
getIssueById: (issueId: string) => TIssue | undefined;
getIssueIdByIdentifier: (issueIdentifier: string) => string | undefined;
@ -40,7 +37,6 @@ export interface IIssueStore extends IIssueStoreActions {
export class IssueStore implements IIssueStore {
fetchingIssueDetails: string | undefined = undefined;
localDBIssueDescription: string | undefined = undefined;
// root store
rootIssueDetailStore: IIssueDetail;
// services
@ -53,7 +49,6 @@ export class IssueStore implements IIssueStore {
constructor(rootStore: IIssueDetail, serviceType: TIssueServiceType) {
makeObservable(this, {
fetchingIssueDetails: observable.ref,
localDBIssueDescription: observable.ref,
});
// root store
this.rootIssueDetailStore = rootStore;
@ -71,12 +66,6 @@ export class IssueStore implements IIssueStore {
return this.fetchingIssueDetails === issueId;
});
getIsLocalDBIssueDescription = computedFn((issueId: string | undefined) => {
if (!issueId) return false;
return this.localDBIssueDescription === issueId;
});
// helper methods
getIssueById = computedFn((issueId: string) => {
if (!issueId) return undefined;
@ -94,26 +83,12 @@ export class IssueStore implements IIssueStore {
expand: "issue_reactions,issue_attachments,issue_link,parent",
};
let issue: TIssue | undefined;
// fetch issue from local db
if (this.serviceType === EIssueServiceType.ISSUES) {
issue = await persistence.getIssue(issueId);
}
this.fetchingIssueDetails = issueId;
if (issue) {
this.addIssueToStore(issue);
this.localDBIssueDescription = issueId;
}
issue = await this.issueService.retrieve(workspaceSlug, projectId, issueId, query);
const issue = await this.issueService.retrieve(workspaceSlug, projectId, issueId, query);
if (!issue) throw new Error("Work item not found");
const issuePayload = this.addIssueToStore(issue);
this.localDBIssueDescription = undefined;
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]);

View file

@ -11,9 +11,7 @@ import type {
TIssueServiceType,
TLoader,
} from "@plane/types";
import { EIssueServiceType } from "@plane/types";
// services
import { updatePersistentLayer } from "@/local-db/utils/utils";
import { IssueService } from "@/services/issue";
// store
import type { IIssueDetail } from "./root.store";
@ -198,10 +196,6 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
this.subIssues[parentIssueId].length
);
if (this.serviceType === EIssueServiceType.ISSUES) {
updatePersistentLayer([parentIssueId, ...issueIds]);
}
return;
};
@ -298,10 +292,6 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
);
});
if (this.serviceType === EIssueServiceType.ISSUES) {
updatePersistentLayer([parentIssueId]);
}
return;
};
@ -335,10 +325,6 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
);
});
if (this.serviceType === EIssueServiceType.ISSUES) {
updatePersistentLayer([parentIssueId]);
}
return;
};

View file

@ -1,4 +1,4 @@
import { clone, set, update } from "lodash-es";
import { set, update } from "lodash-es";
import { action, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
// types
@ -7,8 +7,6 @@ import type { TIssue } from "@plane/types";
import { getCurrentDateTimeInISO } from "@plane/utils";
import { rootStore } from "@/lib/store-context";
// services
import { deleteIssueFromLocal } from "@/local-db/utils/load-issues";
import { updatePersistentLayer } from "@/local-db/utils/utils";
import { IssueService } from "@/services/issue";
export type IIssueStore = {
@ -103,17 +101,12 @@ export class IssueStore implements IIssueStore {
*/
updateIssue = (issueId: string, issue: Partial<TIssue>) => {
if (!issue || !issueId || !this.issuesMap[issueId]) return;
const issueBeforeUpdate = clone(this.issuesMap[issueId]);
runInAction(() => {
set(this.issuesMap, [issueId, "updated_at"], getCurrentDateTimeInISO());
Object.keys(issue).forEach((key) => {
set(this.issuesMap, [issueId, key], issue[key as keyof TIssue]);
});
});
if (!issueBeforeUpdate.is_epic) {
updatePersistentLayer(issueId);
}
};
/**
@ -126,7 +119,6 @@ export class IssueStore implements IIssueStore {
runInAction(() => {
delete this.issuesMap[issueId];
});
deleteIssueFromLocal(issueId);
};
// helper methods

View file

@ -248,7 +248,7 @@ export class ModuleIssuesFilter extends IssueFilterHelperStore implements IModul
});
if (this.getShouldClearIssues(updatedDisplayFilters)) {
this.rootIssueStore.moduleIssues.clear(true, true); // clear issues for local store when some filters like layout changes
this.rootIssueStore.moduleIssues.clear(true); // clear issues for local store when some filters like layout changes
}
if (this.getShouldReFetchIssues(updatedDisplayFilters)) {

View file

@ -137,8 +137,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues {
// set loader and clear store
runInAction(() => {
this.setLoader(loadType);
this.clear(!isExistingPaginationOptions, false); // clear while fetching from server.
if (!this.groupBy) this.clear(!isExistingPaginationOptions, true); // clear while using local to have the no load effect.
this.clear(!isExistingPaginationOptions); // clear while fetching from server.
});
// get params from pagination options

View file

@ -257,7 +257,7 @@ export class ProjectViewIssuesFilter extends IssueFilterHelperStore implements I
});
if (this.getShouldClearIssues(updatedDisplayFilters)) {
this.rootIssueStore.projectIssues.clear(true, true); // clear issues for local store when some filters like layout changes
this.rootIssueStore.projectIssues.clear(true); // clear issues for local store when some filters like layout changes
}
if (this.getShouldReFetchIssues(updatedDisplayFilters)) {

View file

@ -94,8 +94,7 @@ export class ProjectViewIssues extends BaseIssuesStore implements IProjectViewIs
// set loader and clear store
runInAction(() => {
this.setLoader(loadType);
this.clear(!isExistingPaginationOptions, false); // clear while fetching from server.
if (!this.groupBy) this.clear(!isExistingPaginationOptions, true); // clear while using local to have the no load effect.
this.clear(!isExistingPaginationOptions); // clear while fetching from server.
});
// get params from pagination options

View file

@ -231,7 +231,7 @@ export class ProjectIssuesFilter extends IssueFilterHelperStore implements IProj
});
if (this.getShouldClearIssues(updatedDisplayFilters)) {
this.rootIssueStore.projectIssues.clear(true, true); // clear issues for local store when some filters like layout changes
this.rootIssueStore.projectIssues.clear(true); // clear issues for local store when some filters like layout changes
}
if (this.getShouldReFetchIssues(updatedDisplayFilters)) {

View file

@ -102,8 +102,7 @@ export class ProjectIssues extends BaseIssuesStore implements IProjectIssues {
// set loader and clear store
runInAction(() => {
this.setLoader(loadType);
this.clear(!isExistingPaginationOptions, false); // clear while fetching from server.
if (!this.groupBy) this.clear(!isExistingPaginationOptions, true); // clear while using local to have the no load effect.
this.clear(!isExistingPaginationOptions); // clear while fetching from server.
});
// get params from pagination options

View file

@ -17,8 +17,6 @@ import type {
TBulkOperationsPayload,
} from "@plane/types";
import { getCurrentDateTimeInISO, convertToISODateString } from "@plane/utils";
// local-db
import { addIssueToPersistanceLayer } from "@/local-db/utils/utils";
// services
import workspaceDraftService from "@/services/issue/workspace_draft.service";
// types
@ -350,9 +348,6 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
});
}
// sync issue to local db
addIssueToPersistanceLayer({ ...payload, ...response });
// Update draft issue count in workspaceUserInfo
this.updateWorkspaceUserDraftIssueCount(workspaceSlug, -1);
});

View file

@ -6,7 +6,6 @@ import type { IIssueLabel, IIssueLabelTree } from "@plane/types";
// helpers
import { buildTree } from "@plane/utils";
// services
import { syncIssuesWithDeletedLabels } from "@/local-db/utils/load-workspace";
import { IssueLabelService } from "@/services/issue";
// store
import type { CoreRootStore } from "./root.store";
@ -299,7 +298,6 @@ export class LabelStore implements ILabelStore {
runInAction(() => {
delete this.labelMap[labelId];
});
syncIssuesWithDeletedLabels([labelId]);
});
};
}

View file

@ -7,7 +7,6 @@ import type { DistributionUpdates } from "@plane/utils";
import { updateDistribution, orderModules, shouldFilterModule } from "@plane/utils";
// helpers
// services
import { syncIssuesWithDeletedModules } from "@/local-db/utils/load-workspace";
import { ModuleService } from "@/services/module.service";
import { ModuleArchiveService } from "@/services/module_archive.service";
import { ProjectService } from "@/services/project";
@ -453,7 +452,6 @@ export class ModulesStore implements IModuleStore {
runInAction(() => {
delete this.moduleMap[moduleId];
if (this.rootStore.favorite.entityMap[moduleId]) this.rootStore.favorite.removeFavoriteFromStore(moduleId);
syncIssuesWithDeletedModules([moduleId]);
});
});
};

View file

@ -7,7 +7,6 @@ import type { IState } from "@plane/types";
// helpers
import { sortStates } from "@plane/utils";
// plane web
import { syncIssuesWithDeletedStates } from "@/local-db/utils/load-workspace";
import { ProjectStateService } from "@/plane-web/services/project/project-state.service";
import type { RootStore } from "@/plane-web/store/root.store";
@ -248,7 +247,6 @@ export class StateStore implements IStateStore {
await this.stateService.deleteState(workspaceSlug, projectId, stateId).then(() => {
runInAction(() => {
delete this.stateMap[stateId];
syncIssuesWithDeletedStates([stateId]);
});
});
};

View file

@ -3,8 +3,6 @@ import { action, makeObservable, observable, runInAction, computed } from "mobx"
// plane imports
import { EUserPermissions, API_BASE_URL } from "@plane/constants";
import type { IUser, TUserPermissions } from "@plane/types";
// local
import { persistence } from "@/local-db/storage.sqlite";
// plane web imports
import type { RootStore } from "@/plane-web/store/root.store";
import type { IUserPermissionStore } from "@/plane-web/store/user/permission.store";
@ -48,7 +46,6 @@ export interface IUserStore {
reset: () => void;
signOut: () => Promise<void>;
// computed
localDBEnabled: boolean;
canPerformAnyCreateAction: boolean;
projectsWithCreatePermissions: { [projectId: string]: number } | null;
}
@ -99,8 +96,6 @@ export class UserStore implements IUserStore {
// computed
canPerformAnyCreateAction: computed,
projectsWithCreatePermissions: computed,
localDBEnabled: computed,
});
}
@ -253,7 +248,6 @@ export class UserStore implements IUserStore {
*/
signOut = async (): Promise<void> => {
await this.authService.signOut(API_BASE_URL);
await persistence.clearStorage(true);
this.store.resetOnSignOut();
};
@ -296,8 +290,4 @@ export class UserStore implements IUserStore {
const filteredProjects = this.fetchProjectsWithCreatePermissions();
return filteredProjects ? Object.keys(filteredProjects).length > 0 : false;
}
get localDBEnabled() {
return this.userSettings.canUseLocalDB;
}
}

View file

@ -14,7 +14,6 @@ export interface IUserSettingsStore {
isLoading: boolean;
error: TError | undefined;
data: IUserSettings;
canUseLocalDB: boolean;
sidebarCollapsed: boolean;
isScrolled: boolean;
// actions
@ -42,7 +41,6 @@ export class UserSettingsStore implements IUserSettingsStore {
invites: undefined,
},
};
canUseLocalDB: boolean = false;
// services
userService: UserService;
@ -52,7 +50,6 @@ export class UserSettingsStore implements IUserSettingsStore {
isLoading: observable.ref,
error: observable,
data: observable,
canUseLocalDB: observable.ref,
sidebarCollapsed: observable.ref,
isScrolled: observable.ref,
// actions