Files
splitt-the-bill/app/composables/usePaymentLinkCache.ts
T
anbraten cbe1b42f6e
tinyedge/deploy Deployed by TinyEdge
🐛 add env to useDb and apply prettier
2026-08-07 13:28:26 +02:00

21 lines
553 B
TypeScript

import {
readCachedPaymentLink,
writeCachedPaymentLink,
} from '../utils/paymentLinkCache';
export function usePaymentLinkCache() {
const lastLink = useState<string | null>('payment-link-cache', () => null);
if (import.meta.client && lastLink.value === null) {
lastLink.value = readCachedPaymentLink(window.localStorage);
}
function rememberLink(link: string) {
if (!import.meta.client || !link) return;
lastLink.value = link;
writeCachedPaymentLink(window.localStorage, link);
}
return { lastLink, rememberLink };
}