From 6c3139325f4a5fd3884460ee21bab84e82458452 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Sat, 26 Sep 2026 03:07:37 +0200 Subject: [PATCH 1/2] chore: add cleanup to signout --- CHANGELOG.md | 5 ++++- client/src/__test__/views/Home.test.tsx | 3 ++- client/src/context/AuthProvider.tsx | 3 +++ client/src/views/Home/index.tsx | 14 +++++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44588d6c..776bdf44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 2026-09-25 +### Added +- Cache to Home to avoid fetching content when not neeedd. [PR 86](https://github.com/thermcampos/tasknote/pull/86) + ### Changed - Notes title and URLs moved to inside the note body. [Issue 83](https://github.com/thermcampos/tasknote/issues/83) - Notes works with live MD renderer, similar to Notion. [PR 88](https://github.com/thermcampos/tasknote/pull/88) ``` # Docker images -- ghcr.io/thermcampos/tasknote/client:app-v2026.09.25.13 +- ghcr.io/thermcampos/tasknote/client:app-v2026.09.25.16 ``` --- diff --git a/client/src/__test__/views/Home.test.tsx b/client/src/__test__/views/Home.test.tsx index e0510e9a..6bfb8f0b 100644 --- a/client/src/__test__/views/Home.test.tsx +++ b/client/src/__test__/views/Home.test.tsx @@ -41,7 +41,8 @@ vi.mock('../../utils/TranslatorUtils', () => ({ })); vi.mock('react-router', () => ({ - useLocation: () => ({ state: null }), + useLocation: () => ({ state: null, pathname: '/home' }), + useNavigate: () => vi.fn(), NavLink: ({ to, children }: { to: string, children: React.ReactNode }) => ( {children} ) diff --git a/client/src/context/AuthProvider.tsx b/client/src/context/AuthProvider.tsx index d9f9f8ac..c0e1d9b1 100644 --- a/client/src/context/AuthProvider.tsx +++ b/client/src/context/AuthProvider.tsx @@ -6,6 +6,7 @@ import api from '../api-service/api'; import ApiConfig from '../api-service/apiConfig'; import { UserResponse } from '../types/UserResponse'; import { UserRegistration } from '../types/UserRegistration'; +import { clearHomeCache } from '../utils/HomeCache'; interface Props { children: React.ReactNode; @@ -111,6 +112,7 @@ const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }: Pro localStorage.removeItem(API_TOKEN); localStorage.removeItem(REDIRECT_PATH); localStorage.removeItem(USER_DATA); + clearHomeCache(); }; useEffect(() => { @@ -127,6 +129,7 @@ const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }: Pro setSigned(false); setUser(undefined); localStorage.clear(); + clearHomeCache(); }); }, TWENTY_FIVE_MINUTES); return () => clearInterval(intervalId); diff --git a/client/src/views/Home/index.tsx b/client/src/views/Home/index.tsx index fa8f4183..d9252469 100644 --- a/client/src/views/Home/index.tsx +++ b/client/src/views/Home/index.tsx @@ -24,7 +24,7 @@ import FilterContext from '../../context/FilterContext'; import ContentHeader from '../../components/ContentHeader'; import AlertError from '../../components/AlertError'; import { CheckSquare, JournalText, ThreeDotsVertical } from 'react-bootstrap-icons'; -import { NavLink, useLocation } from 'react-router'; +import { NavLink, useLocation, useNavigate } from 'react-router'; import ModalMarkdown from '../../components/ModalMarkdown'; import TaskTitle from '../../components/TaskTitle'; import TaskTimeLeft from '../../components/TaskTimeLeft'; @@ -52,8 +52,10 @@ function Home(): React.ReactNode { const { filterText, selectedOption, setFilterText, setSelectedOption } = useContext(FilterContext); const { i18n, t } = useTranslation(); const location = useLocation(); - const refreshAfterSave - = (location.state as { refreshHome?: boolean } | null)?.refreshHome === true; + const navigate = useNavigate(); + const [refreshAfterSave] = useState( + () => (location.state as { refreshHome?: boolean } | null)?.refreshHome === true + ); const [errorMessage, setErrorMessage] = useState(''); const [tags, setTags] = useState([]); const [name, setName] = useState(user?.name ? user?.name : 'User'); @@ -463,6 +465,12 @@ function Home(): React.ReactNode { setSelectedOption(value); }; + useEffect(() => { + if (refreshAfterSave) { + navigate(location.pathname, { replace: true, state: null }); + } + }, [refreshAfterSave, navigate, location.pathname]); + useEffect(() => { handleDefaultLang(user?.lang); setName(user?.name ?? 'User'); From b7edf512f872319c486c0ed5ee9880560c01ae53 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Sun, 27 Sep 2026 20:13:08 +0200 Subject: [PATCH 2/2] docs: update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 776bdf44..c7f085a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## 2026-09-27 + +### Fixed +- Logout cache cleaning. [PR 89](https://github.com/thermcampos/tasknote/pull/89) + +--- + ## 2026-09-25 ### Added