Fork of atp.tools as a universal profile for people on the ATmosphere

feat: redirect to prev page on refresh session

+20 -2
+4
src/providers/qtprovider.tsx
··· 210 210 ); 211 211 return; 212 212 } 213 + // what url are we at? 214 + const url = new URL(window.location.href); 215 + // store it in local storage, with the timestamp 216 + localStorage.setItem("previousUrl", `${url.toString()}:${Date.now()}`); 213 217 const resolved = await this.resolveHandle(did); 214 218 let oauth = await this.getOAuthRedirectUri(resolved); 215 219 // log out before we redirect
+16 -2
src/routes/auth/callback.lazy.tsx
··· 19 19 const handleAuthorization = async () => { 20 20 try { 21 21 const params = new URLSearchParams(location.hash.slice(1)); 22 - console.log(params); 23 22 if (params) { 24 23 await qt.client.finalizeAuthorization(params); 25 24 } ··· 29 28 } finally { 30 29 setIsDone(true); 31 30 setTimeout(() => { 32 - window.location.href = "/"; 31 + // get location from local storage 32 + const previousUrl = localStorage.getItem("previousUrl"); 33 + if (previousUrl) { 34 + const [url, timestamp] = previousUrl.split(":"); 35 + if (Date.now() - parseInt(timestamp) < 5000) { 36 + console.log(`Redirecting to previous URL: ${url}`); 37 + localStorage.removeItem("previousUrl"); 38 + window.location.href = url; 39 + } else { 40 + console.log(`Previous URL expired`); 41 + localStorage.removeItem("previousUrl"); 42 + window.location.href = "/"; 43 + } 44 + } else { 45 + window.location.href = "/"; 46 + } 33 47 }, 200); 34 48 } 35 49 };