Skip to content

Commit

Permalink
Merge pull request #394 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat PS-2478: clear cache after logout and academic year changed
  • Loading branch information
itsvick authored Nov 14, 2024
2 parents 39584f6 + 7453da0 commit a30e25f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/MenuDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { getAcademicYear } from '../services/AcademicYearService';
import { AcademicYear } from '@/utils/Interfaces';
import { telemetryFactory } from '@/utils/telemetry';
import { Telemetry } from '@/utils/app.constant';
import { useQueryClient } from '@tanstack/react-query';

interface DrawerProps {
toggleDrawer?: (open: boolean) => () => void;
Expand All @@ -52,7 +53,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
AcademicYear[]
>([]);
const [selectedSessionId, setSelectedSessionId] = useState<string>('');

const queryClient = useQueryClient();
const { i18n, t } = useTranslation();
const router = useRouter();
const store = useStore();
Expand Down Expand Up @@ -123,6 +124,8 @@ const MenuDrawer: React.FC<DrawerProps> = ({
const isActive = selectedYear ? selectedYear.isActive : false;
// localStorage.setItem('isActiveYearSelected', JSON.stringify(isActive));
setIsActiveYearSelected(isActive);
queryClient.clear();

if (isActive) {
window.location.reload();
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { logout } from '../services/LoginService';
import { telemetryFactory } from '@/utils/telemetry';
import ReactGA from 'react-ga4';
import { Telemetry } from '@/utils/app.constant';

import { useQueryClient } from '@tanstack/react-query';
function Logout() {
const queryClient = useQueryClient();
const router = useRouter();
const clearLocalStorage = () => {
if (typeof window !== 'undefined' && window.localStorage) {
Expand All @@ -26,7 +27,7 @@ function Logout() {

// Clear all local storage
localStorage.clear();

queryClient.clear();
// Re-add the keys to keep with their values
keysToKeep.forEach((key: string) => {
if (valuesToKeep[key] !== null) {
Expand Down

0 comments on commit a30e25f

Please sign in to comment.