Skip to content

Commit

Permalink
fixes #6822; invalidate filters cache upon login attempt (#6823)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Dec 8, 2023
1 parent f992917 commit 896f51b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

0 comments on commit 896f51b

Please sign in to comment.