From 8d35f409172916daf0e02e6fc470c40bd4e554d7 Mon Sep 17 00:00:00 2001 From: gakshita Date: Tue, 21 Jan 2025 19:54:57 +0530 Subject: [PATCH] fix: new sticky color + recent sticky api call + sticky max height --- web/core/components/stickies/sticky/inputs.tsx | 2 +- web/core/components/stickies/sticky/root.tsx | 7 ++++--- web/core/services/sticky.service.ts | 5 +++-- web/core/store/sticky/sticky.store.ts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web/core/components/stickies/sticky/inputs.tsx b/web/core/components/stickies/sticky/inputs.tsx index e56f6927e04..84b7b8af706 100644 --- a/web/core/components/stickies/sticky/inputs.tsx +++ b/web/core/components/stickies/sticky/inputs.tsx @@ -10,7 +10,7 @@ import { useWorkspace } from "@/hooks/store"; import { StickyEditor } from "../../editor"; type TProps = { - stickyData: TSticky | undefined; + stickyData: Partial | undefined; workspaceSlug: string; handleUpdate: (payload: Partial) => void; stickyId: string | undefined; diff --git a/web/core/components/stickies/sticky/root.tsx b/web/core/components/stickies/sticky/root.tsx index bee67f913c9..50605184b40 100644 --- a/web/core/components/stickies/sticky/root.tsx +++ b/web/core/components/stickies/sticky/root.tsx @@ -12,7 +12,7 @@ import { useSticky } from "@/hooks/use-stickies"; import { STICKY_COLORS_LIST } from "../../editor/sticky-editor/color-palette"; import { StickyDeleteModal } from "../delete-modal"; import { StickyInput } from "./inputs"; -import { useStickyOperations } from "./use-operations"; +import { getRandomStickyColor, useStickyOperations } from "./use-operations"; type TProps = { onClose?: () => void; @@ -33,7 +33,7 @@ export const StickyNote = observer((props: TProps) => { // sticky operations const { stickyOperations } = useStickyOperations({ workspaceSlug }); // derived values - const stickyData = stickyId ? stickies[stickyId] : undefined; + const stickyData: Partial = stickyId ? stickies[stickyId] : { background_color: getRandomStickyColor() }; // const isStickiesPage = pathName?.includes("stickies"); const backgroundColor = STICKY_COLORS_LIST.find((c) => c.key === stickyData?.background_color)?.backgroundColor || @@ -45,6 +45,7 @@ export const StickyNote = observer((props: TProps) => { await stickyOperations.update(stickyId, payload); } else { await stickyOperations.create({ + ...stickyData, ...payload, }); } @@ -73,7 +74,7 @@ export const StickyNote = observer((props: TProps) => { handleClose={() => setIsDeleteModalOpen(false)} />
{ return this.get(`/api/workspaces/${workspaceSlug}/stickies/`, { params: { cursor, - per_page: STICKIES_PER_PAGE, + per_page: per_page || STICKIES_PER_PAGE, query, }, }) diff --git a/web/core/store/sticky/sticky.store.ts b/web/core/store/sticky/sticky.store.ts index e3d292173e3..08725517586 100644 --- a/web/core/store/sticky/sticky.store.ts +++ b/web/core/store/sticky/sticky.store.ts @@ -96,7 +96,7 @@ export class StickyStore implements IStickyStore { }; fetchRecentSticky = async (workspaceSlug: string) => { - const response = await this.stickyService.getStickies(workspaceSlug, "1:0:0"); + const response = await this.stickyService.getStickies(workspaceSlug, "1:0:0", undefined, 1); runInAction(() => { this.recentStickyId = response.results[0]?.id; this.stickies[response.results[0]?.id] = response.results[0];