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"; import { StickyEditor } from "../../editor";
type TProps = { type TProps = {
stickyData: TSticky | undefined; stickyData: Partial<TSticky> | undefined;
workspaceSlug: string; workspaceSlug: string;
handleUpdate: (payload: Partial<TSticky>) => void; handleUpdate: (payload: Partial<TSticky>) => void;
stickyId: string | undefined; 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 { STICKY_COLORS_LIST } from "../../editor/sticky-editor/color-palette";
import { StickyDeleteModal } from "../delete-modal"; import { StickyDeleteModal } from "../delete-modal";
import { StickyInput } from "./inputs"; import { StickyInput } from "./inputs";
import { useStickyOperations } from "./use-operations"; import { getRandomStickyColor, useStickyOperations } from "./use-operations";
type TProps = { type TProps = {
onClose?: () => void; onClose?: () => void;
@ -33,7 +33,7 @@ export const StickyNote = observer((props: TProps) => {
// sticky operations // sticky operations
const { stickyOperations } = useStickyOperations({ workspaceSlug }); const { stickyOperations } = useStickyOperations({ workspaceSlug });
// derived values // derived values
const stickyData = stickyId ? stickies[stickyId] : undefined; const stickyData: Partial<TSticky> = stickyId ? stickies[stickyId] : { background_color: getRandomStickyColor() };
// const isStickiesPage = pathName?.includes("stickies"); // const isStickiesPage = pathName?.includes("stickies");
const backgroundColor = const backgroundColor =
STICKY_COLORS_LIST.find((c) => c.key === stickyData?.background_color)?.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); await stickyOperations.update(stickyId, payload);
} else { } else {
await stickyOperations.create({ await stickyOperations.create({
...stickyData,
...payload, ...payload,
}); });
} }
@ -73,7 +74,7 @@ export const StickyNote = observer((props: TProps) => {
handleClose={() => setIsDeleteModalOpen(false)} handleClose={() => setIsDeleteModalOpen(false)}
/> />
<div <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={{ style={{
backgroundColor, backgroundColor,
}} }}

View file

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

View file

@ -96,7 +96,7 @@ export class StickyStore implements IStickyStore {
}; };
fetchRecentSticky = async (workspaceSlug: string) => { 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(() => { runInAction(() => {
this.recentStickyId = response.results[0]?.id; this.recentStickyId = response.results[0]?.id;
this.stickies[response.results[0]?.id] = response.results[0]; this.stickies[response.results[0]?.id] = response.results[0];