diff --git a/web/ce/components/workspace/sidebar/extended-sidebar-item.tsx b/web/ce/components/workspace/sidebar/extended-sidebar-item.tsx index 22cfe08421..5bb2fe885f 100644 --- a/web/ce/components/workspace/sidebar/extended-sidebar-item.tsx +++ b/web/ce/components/workspace/sidebar/extended-sidebar-item.tsx @@ -5,7 +5,7 @@ import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag- import { observer } from "mobx-react"; import Link from "next/link"; import { useParams, usePathname } from "next/navigation"; -import { Eye, EyeClosed } from "lucide-react"; +import { Pin, PinOff } from "lucide-react"; // plane imports import { EUserPermissionsLevel, IWorkspaceSidebarNavigationItem } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; @@ -197,16 +197,16 @@ export const ExtendedSidebarItem: FC = observer((prop )} {isPinned ? ( - - + unPinNavigationItem(workspaceSlug.toString(), item.key)} /> ) : ( - - + pinNavigationItem(workspaceSlug.toString(), item.key)} /> diff --git a/web/core/store/workspace/index.ts b/web/core/store/workspace/index.ts index f46ecc273e..811d0f9633 100644 --- a/web/core/store/workspace/index.ts +++ b/web/core/store/workspace/index.ts @@ -1,3 +1,4 @@ +import clone from "lodash/clone"; import set from "lodash/set"; import { action, computed, observable, makeObservable, runInAction } from "mobx"; // types @@ -214,18 +215,29 @@ export class WorkspaceRootStore implements IWorkspaceRootStore { key: string, data: Partial ) => { + // Store the data before update to use for reverting if needed + const beforeUpdateData = clone(this.navigationPreferencesMap[workspaceSlug]?.[key]); try { - const response = await this.workspaceService.updateSidebarPreference(workspaceSlug, key, data); - runInAction(() => { this.navigationPreferencesMap[workspaceSlug] = { ...this.navigationPreferencesMap[workspaceSlug], - [key]: response, + [key]: { + ...beforeUpdateData, + ...data, + }, }; }); + const response = await this.workspaceService.updateSidebarPreference(workspaceSlug, key, data); return response; } catch (error) { + // Revert to original data if API call fails + runInAction(() => { + this.navigationPreferencesMap[workspaceSlug] = { + ...this.navigationPreferencesMap[workspaceSlug], + [key]: beforeUpdateData, + }; + }); console.error("Failed to update sidebar preference:", error); } };