Skip to content

Commit 493e8a2

Browse files
authored
[Bug]-[Web] Fix missing persistence of selected view mode (Cards, Table, Blocks) on Home page (#4116)
* update constants * persist thee last view mode in local storage * get & apply the last selected team memebers view mode from the local storage * improve variable naming * Add ai bit suggestions * Add ai bit suggestions
1 parent f4b39d9 commit 493e8a2

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

apps/web/app/[locale]/page-component.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { clsxm } from '@/core/lib/utils';
66
import { withAuthentication } from '@/core/components/layouts/app/authenticator';
77
import { Container } from '@/core/components';
88
import { MainLayout } from '@/core/components/layouts/default-layout';
9-
import { IssuesView } from '@/core/constants/config/constants';
9+
import { IssuesView, LAST_SELECTED_TEAM_MEMBERS_VIEW_MODE } from '@/core/constants/config/constants';
1010
import { useTranslations } from 'next-intl';
1111

1212
import { Analytics } from '@vercel/analytics/react';
@@ -73,6 +73,14 @@ function MainPage() {
7373
if (view == IssuesView.KANBAN && path == '/') {
7474
setView(IssuesView.CARDS);
7575
}
76+
const lastTeamMembersViewMode = localStorage?.getItem(LAST_SELECTED_TEAM_MEMBERS_VIEW_MODE);
77+
if (lastTeamMembersViewMode && path == '/') {
78+
if (Object.values(IssuesView).includes(lastTeamMembersViewMode as IssuesView) &&
79+
lastTeamMembersViewMode != IssuesView.KANBAN
80+
) {
81+
setView(lastTeamMembersViewMode as IssuesView);
82+
}
83+
}
7684
// eslint-disable-next-line react-hooks/exhaustive-deps
7785
}, [path, setView]);
7886

apps/web/core/components/common/header-tabs.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { clsxm } from '@/core/lib/utils';
22
import LinkWrapper from './link-wrapper';
33
import { QueueListIcon, Squares2X2Icon, TableCellsIcon } from '@heroicons/react/20/solid';
44
import KanbanIcon from '@/core/components/svgs/kanban';
5-
import { IssuesView } from '@/core/constants/config/constants';
5+
import { IssuesView, LAST_SELECTED_TEAM_MEMBERS_VIEW_MODE } from '@/core/constants/config/constants';
66
import { useAtom } from 'jotai';
77
import { headerTabs } from '@/core/stores/common/header-tabs';
88
import { DottedLanguageObjectStringPaths, useTranslations } from 'next-intl';
@@ -19,6 +19,10 @@ const HeaderTabs = ({ linkAll, kanban = false }: { linkAll: boolean; kanban?: bo
1919
const links = linkAll ? ['/', '/', '/', '/kanban'] : [undefined, undefined, undefined, '/kanban'];
2020
const [view, setView] = useAtom(headerTabs);
2121
const activeView = kanban ? IssuesView.KANBAN : view;
22+
23+
const setLastTeamMembersViewMode = (viewMode: IssuesView) => {
24+
localStorage?.setItem(LAST_SELECTED_TEAM_MEMBERS_VIEW_MODE, viewMode);
25+
};
2226
return (
2327
<>
2428
{options.map(({ label, icon: Icon, view: optionView }, index) => (
@@ -38,6 +42,7 @@ const HeaderTabs = ({ linkAll, kanban = false }: { linkAll: boolean; kanban?: bo
3842
onClick={() => {
3943
if (links[index] !== '/kanban') {
4044
setView(optionView);
45+
setLastTeamMembersViewMode(optionView);
4146
}
4247
}}
4348
>

apps/web/core/constants/config/constants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ export const HAS_VISITED_OUTSTANDING_TASKS = 'has-visited-outstanding-tasks';
453453
export const HAS_SEEN_DAILY_PLAN_SUGGESTION_MODAL = 'has-seen-daily-plan-suggestion-modal';
454454
export const LAST_SELECTED_PROJECTS_VIEW = 'last-selected-projects-view';
455455
export const PROJECTS_TABLE_VIEW_LAST_SORTING = 'projects-table-view-last-sorting';
456+
export const LAST_SELECTED_TEAM_MEMBERS_VIEW_MODE = 'last-selected-team-members-view-mode';
456457

457458
// OAuth provider's keys
458459

0 commit comments

Comments
 (0)