Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Clear persisted form values if time has expired (#935)
Leendert de Borst1eecb8be384d
diff --git a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsxindex 910c4a674..977464116 100644--- a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx+++ b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx@@ -1,10 +1,11 @@import React, { createContext, useContext, useEffect, useState, useMemo, useCallback } from 'react';import { useLocation, useNavigate } from 'react-router-dom';+import { sendMessage } from 'webext-bridge/popup';import { storage } from '#imports';-const LAST_VISITED_PAGE_KEY = 'local:lastVisitedPage';-const LAST_VISITED_TIME_KEY = 'local:lastVisitedTime';+const LAST_VISITED_PAGE_KEY = 'session:lastVisitedPage';+const LAST_VISITED_TIME_KEY = 'session:lastVisitedTime';const PAGE_MEMORY_DURATION = 120 * 1000; // 2 minutes in millisecondstype NavigationContextType = {@@ -41,6 +42,13 @@ export const NavigationProvider: React.FC<{ children: React.ReactNode }> = ({ chconst timeSinceLastVisit = Date.now() - lastVisitTime;if (timeSinceLastVisit <= PAGE_MEMORY_DURATION) {navigate(lastPage);+ } else {+ // Duration has expired, clear the last visited page and time.+ await storage.removeItem(LAST_VISITED_PAGE_KEY);+ await storage.removeItem(LAST_VISITED_TIME_KEY);++ // Clear persisted form values if they exist.+ await sendMessage('CLEAR_PERSISTED_FORM_VALUES', null, 'background');}}}, [navigate]);