Add clear cache button
This commit is contained in:
parent
87952491f0
commit
fa800d81bb
@ -1,11 +1,14 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useContext } from "react";
|
||||||
import { Box, Label, Flex, Button, useColorMode, Checkbox } from "theme-ui";
|
import { Box, Label, Flex, Button, useColorMode, Checkbox } from "theme-ui";
|
||||||
|
|
||||||
import Modal from "../components/Modal";
|
import Modal from "../components/Modal";
|
||||||
|
|
||||||
|
import AuthContext from "../contexts/AuthContext";
|
||||||
|
|
||||||
import db from "../database";
|
import db from "../database";
|
||||||
|
|
||||||
function SettingsModal({ isOpen, onRequestClose }) {
|
function SettingsModal({ isOpen, onRequestClose }) {
|
||||||
|
const { userId } = useContext(AuthContext);
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
|
|
||||||
async function handleEraseAllData() {
|
async function handleEraseAllData() {
|
||||||
@ -13,6 +16,12 @@ function SettingsModal({ isOpen, onRequestClose }) {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleClearCache() {
|
||||||
|
await db.table("maps").where("owner").notEqual(userId).delete();
|
||||||
|
// TODO: With custom tokens look up all tokens that aren't being used in a state
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
const [colorMode, setColorMode] = useColorMode();
|
const [colorMode, setColorMode] = useColorMode();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -30,6 +39,11 @@ function SettingsModal({ isOpen, onRequestClose }) {
|
|||||||
pl={1}
|
pl={1}
|
||||||
/>
|
/>
|
||||||
</Label>
|
</Label>
|
||||||
|
<Flex py={2}>
|
||||||
|
<Button sx={{ flexGrow: 1 }} onClick={handleClearCache}>
|
||||||
|
Clear cache
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
<Flex py={2}>
|
<Flex py={2}>
|
||||||
<Button
|
<Button
|
||||||
sx={{ flexGrow: 1 }}
|
sx={{ flexGrow: 1 }}
|
||||||
|
Loading…
Reference in New Issue
Block a user