From 896f51bb3907a9e3103e3d77f4cb399353eda026 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 8 Dec 2023 18:44:57 +0530 Subject: [PATCH] fixes #6822; invalidate filters cache upon login attempt (#6823) --- src/Components/Auth/Login.tsx | 3 ++- src/Utils/utils.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Components/Auth/Login.tsx b/src/Components/Auth/Login.tsx index 58472c4ff25..4aad207c25a 100644 --- a/src/Components/Auth/Login.tsx +++ b/src/Components/Auth/Login.tsx @@ -12,7 +12,7 @@ import CircularProgress from "../Common/components/CircularProgress"; import { LocalStorageKeys } from "../../Common/constants"; import ReactMarkdown from "react-markdown"; import rehypeRaw from "rehype-raw"; -import { handleRedirection } from "../../Utils/utils"; +import { handleRedirection, invalidateFiltersCache } from "../../Utils/utils"; export const Login = (props: { forgot?: boolean }) => { const { @@ -91,6 +91,7 @@ export const Login = (props: { forgot?: boolean }) => { const handleSubmit = async (e: any) => { e.preventDefault(); + invalidateFiltersCache(); const valid = validateData(); if (valid) { // replaces button with spinner diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 7e34d027020..4c4fdacbc28 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -459,3 +459,11 @@ export const scrollTo = (id: string | boolean) => { const element = document.querySelector(`#${id}`); element?.scrollIntoView({ behavior: "smooth", block: "center" }); }; + +export const invalidateFiltersCache = () => { + for (const key in localStorage) { + if (key.startsWith("filters--")) { + localStorage.removeItem(key); + } + } +};