replace localStorage with pglite for persistent data, force-add previously ignored lib/ files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useDb } from "@/shared/db/provider"
|
||||
import { useDeviceId } from "@/shared/hooks/use-device-id"
|
||||
import { useFollows } from "@/shared/hooks/use-follows"
|
||||
import { usePush } from "@/shared/hooks/use-push"
|
||||
@@ -28,6 +29,7 @@ function isStandalone(): boolean {
|
||||
}
|
||||
|
||||
export function SettingsPage() {
|
||||
const db = useDb()
|
||||
const deviceId = useDeviceId()
|
||||
const { needRefresh, checkForUpdate, applyUpdate } = usePwaUpdate()
|
||||
const push = usePush()
|
||||
@@ -43,37 +45,41 @@ export function SettingsPage() {
|
||||
const [devPoliticians, setDevPoliticians] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const cached = loadCachedResult()
|
||||
if (cached) setResult(cached)
|
||||
}, [])
|
||||
loadCachedResult(db).then((cached) => {
|
||||
if (cached) setResult(cached)
|
||||
})
|
||||
}, [db])
|
||||
|
||||
const detect = useCallback((skipCache: boolean) => {
|
||||
if (!navigator.geolocation) {
|
||||
setErrorMsg("Standortbestimmung wird nicht unterstützt")
|
||||
return
|
||||
}
|
||||
setLoading(true)
|
||||
setErrorMsg(null)
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
async (pos) => {
|
||||
try {
|
||||
const r = await detectFromCoords(pos.coords.latitude, pos.coords.longitude, skipCache)
|
||||
setResult(r)
|
||||
} catch (e) {
|
||||
setErrorMsg(String(e))
|
||||
} finally {
|
||||
const detect = useCallback(
|
||||
(skipCache: boolean) => {
|
||||
if (!navigator.geolocation) {
|
||||
setErrorMsg("Standortbestimmung wird nicht unterstützt")
|
||||
return
|
||||
}
|
||||
setLoading(true)
|
||||
setErrorMsg(null)
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
async (pos) => {
|
||||
try {
|
||||
const r = await detectFromCoords(db, pos.coords.latitude, pos.coords.longitude, skipCache)
|
||||
setResult(r)
|
||||
} catch (e) {
|
||||
setErrorMsg(String(e))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
setErrorMsg(err.message)
|
||||
setLoading(false)
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
setErrorMsg(err.message)
|
||||
setLoading(false)
|
||||
},
|
||||
)
|
||||
}, [])
|
||||
},
|
||||
)
|
||||
},
|
||||
[db],
|
||||
)
|
||||
|
||||
function handleClearCache() {
|
||||
clearGeoCache()
|
||||
clearGeoCache(db)
|
||||
setResult(null)
|
||||
}
|
||||
|
||||
@@ -310,9 +316,9 @@ export function SettingsPage() {
|
||||
<Button
|
||||
small
|
||||
outline
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
setDevPoliticians(null)
|
||||
const cached = loadCachedResult()
|
||||
const cached = await loadCachedResult(db)
|
||||
if (!cached || cached.mandates.length === 0) {
|
||||
setDevPoliticians("Kein Standort-Cache")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user