fix: new sticky color + recent sticky api call + sticky max height (#6438)

This commit is contained in:
Akshita Goyal 2025-01-21 20:34:00 +05:30 committed by GitHub
parent 12501d0597
commit 0f7bc6979f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 7 deletions

View file

@ -12,7 +12,7 @@ import { useWorkspace } from "@/hooks/store";
import { StickyEditor } from "../../editor";
type TProps = {
stickyData: TSticky | undefined;
stickyData: Partial<TSticky> | undefined;
workspaceSlug: string;
handleUpdate: (payload: Partial<TSticky>) => void;
stickyId: string | undefined;

View file

@ -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<TSticky> = 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)}
/>
<div
className={cn("w-full flex flex-col h-fit rounded p-4 group/sticky", className)}
className={cn("w-full flex flex-col h-fit rounded p-4 group/sticky max-h-[650px] overflow-y-scroll", className)}
style={{
backgroundColor,
}}

View file

@ -21,12 +21,13 @@ export class StickyService extends APIService {
async getStickies(
workspaceSlug: string,
cursor: string,
query?: string
query?: string,
per_page?: number
): Promise<{ results: TSticky[]; total_pages: number }> {
return this.get(`/api/workspaces/${workspaceSlug}/stickies/`, {
params: {
cursor,
per_page: STICKIES_PER_PAGE,
per_page: per_page || STICKIES_PER_PAGE,
query,
},
})

View file

@ -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];