dev: create separate folder for page service (#4764)

This commit is contained in:
Aaryan Khandelwal 2024-06-11 16:18:42 +05:30 committed by GitHub
parent bdaef179b1
commit b5bbdbfa8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 10 deletions

View File

@ -6,9 +6,9 @@ import { EditorRefApi, generateJSONfromHTML } from "@plane/editor-core";
// hooks
import useReloadConfirmations from "@/hooks/use-reload-confirmation";
// services
import { PageService } from "@/services/page.service";
import { ProjectPageService } from "@/services/page";
import { IPageStore } from "@/store/pages/page.store";
const pageService = new PageService();
const projectPageService = new ProjectPageService();
type Props = {
editorRef: React.RefObject<EditorRefApi>;
@ -32,7 +32,7 @@ export const usePageDescription = (props: Props) => {
const { data: descriptionYJS, mutate: mutateDescriptionYJS } = useSWR(
workspaceSlug && projectId && pageId ? `PAGE_DESCRIPTION_${workspaceSlug}_${projectId}_${pageId}` : null,
workspaceSlug && projectId && pageId
? () => pageService.fetchDescriptionYJS(workspaceSlug.toString(), projectId.toString(), pageId.toString())
? () => projectPageService.fetchDescriptionYJS(workspaceSlug.toString(), projectId.toString(), pageId.toString())
: null,
{
revalidateOnFocus: false,

View File

@ -0,0 +1 @@
export * from "./project-page.service";

View File

@ -5,7 +5,7 @@ import { API_BASE_URL } from "@/helpers/common.helper";
// services
import { APIService } from "@/services/api.service";
export class PageService extends APIService {
export class ProjectPageService extends APIService {
constructor() {
super(API_BASE_URL);
}

View File

@ -6,7 +6,7 @@ import { TLogoProps, TPage } from "@plane/types";
import { EPageAccess } from "@/constants/page";
import { EUserProjectRoles } from "@/constants/project";
// services
import { PageService } from "@/services/page.service";
import { ProjectPageService } from "@/services/page";
import { RootStore } from "../root.store";
export type TLoader = "submitting" | "submitted" | "saved";
@ -69,7 +69,7 @@ export class PageStore implements IPageStore {
// reactions
disposers: Array<() => void> = [];
// services
pageService: PageService;
pageService: ProjectPageService;
constructor(
private store: RootStore,
@ -144,7 +144,7 @@ export class PageStore implements IPageStore {
removeFromFavorites: action,
});
this.pageService = new PageService();
this.pageService = new ProjectPageService();
const titleDisposer = reaction(
() => this.name,

View File

@ -7,7 +7,7 @@ import { TPage, TPageFilters, TPageNavigationTabs } from "@plane/types";
// helpers
import { filterPagesByPageType, getPageName, orderPages, shouldFilterPage } from "@/helpers/page.helper";
// services
import { PageService } from "@/services/page.service";
import { ProjectPageService } from "@/services/page";
// store
import { IPageStore, PageStore } from "@/store/pages/page.store";
import { RootStore } from "../root.store";
@ -48,7 +48,7 @@ export class ProjectPageStore implements IProjectPageStore {
sortBy: "desc",
};
// service
service: PageService;
service: ProjectPageService;
constructor(private store: RootStore) {
makeObservable(this, {
@ -67,7 +67,7 @@ export class ProjectPageStore implements IProjectPageStore {
removePage: action,
});
// service
this.service = new PageService();
this.service = new ProjectPageService();
// initialize display filters of the current project
reaction(
() => this.store.router.projectId,