Skip to content

Commit

Permalink
Remove redundant useState as now using localSession for this specific…
Browse files Browse the repository at this point in the history
… confetti scenario
  • Loading branch information
pH-7 committed May 5, 2024
1 parent fe2411b commit 8d02416
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions client/components/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ interface SearchFormProps {

export function SearchForm({ query, updateQuery }: SearchFormProps) {
const textAreaRef = useRef<HTMLTextAreaElement>(null);
const [isFirstClick, setIsFirstClick] = useState<boolean>(
!sessionStorage.getItem(LocalStorageKeys.FIRST_VISIT)
);

const windowInnerHeight = useWindowInnerHeight();
const [suggestedQuery, setSuggestedQuery] = useState<string>(
Expand Down Expand Up @@ -57,10 +54,10 @@ export function SearchForm({ query, updateQuery }: SearchFormProps) {
};

const handleTextAreaClick = () => {
if (isFirstClick) {
const isFirstVisit = localStorage.getItem(LocalStorageKeys.FIRST_VISIT);
if (!isFirstVisit) {
confetti();
setIsFirstClick(false);
sessionStorage.setItem(LocalStorageKeys.FIRST_VISIT, "true");
localStorage.setItem(LocalStorageKeys.FIRST_VISIT, "true");
}
};

Expand Down

0 comments on commit 8d02416

Please sign in to comment.