|
18 | 18 | */ |
19 | 19 |
|
20 | 20 | import { Component } from "preact"; |
21 | | -import { Form, Button, Modal, Card, Container } from "react-bootstrap"; |
| 21 | +import { Form, Button, Modal, Card, Container, Collapse, Row, Col } from "react-bootstrap"; |
22 | 22 | import { useState } from "preact/hooks"; |
23 | 23 | import { fetchClient, isDebugMode, PASSWORD_PATTERN, concat_salts, generate_hash, generate_random_bytes, get_salt, get_salt_for_user } from "../utils"; |
24 | 24 | import sodium from "libsodium-wrappers"; |
25 | 25 | import { logout } from "../components/Navbar"; |
26 | 26 | import { useTranslation } from "react-i18next"; |
27 | | -import { signal } from "@preact/signals"; |
| 27 | +import { useSignal } from "@preact/signals"; |
28 | 28 | import { PasswordComponent } from "../components/PasswordComponent"; |
29 | 29 | import i18n from "../i18n"; |
30 | 30 | import { showAlert } from "../components/Alert"; |
@@ -147,7 +147,12 @@ export function User() { |
147 | 147 | const [newPasswordIsValid, setNewPasswordIsValid] = useState(true); |
148 | 148 | const [confirmNewPassword, setConfirmNewPassword] = useState(""); |
149 | 149 | const [confirmNewPasswordIsValid, setConfirmNewPasswordIsValid] = useState(true); |
150 | | - const validated = signal(false); |
| 150 | + const storagePersisted = useSignal(false); |
| 151 | + |
| 152 | + navigator.storage.persisted().then((persisted) => { |
| 153 | + storagePersisted.value = persisted; |
| 154 | + }); |
| 155 | + const validated = useSignal(false); |
151 | 156 |
|
152 | 157 | const handleUpdatePasswordClose = () => setShowPasswordReset(false); |
153 | 158 | const handleUpdatePasswordShow = () => setShowPasswordReset(true); |
@@ -295,6 +300,20 @@ export function User() { |
295 | 300 | localStorage.removeItem("debugMode"); |
296 | 301 | } |
297 | 302 | }} /> |
| 303 | + <Collapse in={isDebugMode.value}> |
| 304 | + <div className="mt-3"> |
| 305 | + <Row> |
| 306 | + <Col>{`Storage persisted: ${storagePersisted.value ? "yes" : "no"}`}</Col> |
| 307 | + </Row> |
| 308 | + <Button |
| 309 | + className="mt-2" |
| 310 | + variant="secondary" |
| 311 | + disabled={storagePersisted.value} |
| 312 | + size="sm" onClick={async () => { |
| 313 | + storagePersisted.value = await navigator.storage.persist(); |
| 314 | + }}>Request Storage Persistence</Button> |
| 315 | + </div> |
| 316 | + </Collapse> |
298 | 317 | </Card.Body> |
299 | 318 | <Card.Header className="border-top pb-2"> |
300 | 319 | <h5 className="mb-0">{t("account_actions")}</h5> |
|
0 commit comments