Skip to content

Commit

Permalink
feat: export / import db
Browse files Browse the repository at this point in the history
- other fixes
  • Loading branch information
h16nning committed Feb 10, 2024
1 parent 2da79e9 commit 23d420d
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 181 deletions.
22 changes: 11 additions & 11 deletions .firebase/hosting.YnVpbGQ.cache
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
index.html,1707506186415,185d22983d01f190f88163132235032df27cdfd027ab43b9158c71405797c274
badge.svg,1707506186007,4edd75f1d7084efc0ef8a502c6034d114374a681693b0c00b5b28b03fd157671
manifest.json,1707506186009,55750b48311acbc8a8e79a712b06c86159fb6e31d8dedaf965408b92da601522
service-worker.js,1707506186010,fd9ec6132f3af5770dd0924ed3356930a669a9274fce81ec82baa79d58d99611
robots.txt,1707506186009,391d14b3c2f8c9143a27a28c7399585142228d4d1bdbe2c87ac946de411fa9a2
logo.svg,1707506186007,861ef96db8e9adace3f580944747289b6a5704bc798e917dc5449dd7a49dd560
logo256.png,1707506186008,174027c4e97105e2e006e42620822304e0d3fdee4d390a423f15f0abc16ef781
assets/web-vitals-BptxjviT.js,1707506186415,3ffd55f59352ddeafd5ff621f81d31444c53f3ae25242797564de702ed442492
logo512.png,1707506186008,3db7a8824f96f862029199fbb398ab312bb4688d52b1a0ab0e2a311422a21ab3
assets/index-uqoGVHGe.css,1707506186415,e8d03bd716c716adad3b78b29b513b3f29ebbaa60ce1fd7a86fce8526aa9b384
assets/index-j4mQTXfm.js,1707506186417,52576d3c9dceb5f8704a06e4a950cc851c77d37c6429d09fbe7ab4092ca7f27f
badge.svg,1707590450489,4edd75f1d7084efc0ef8a502c6034d114374a681693b0c00b5b28b03fd157671
index.html,1707590450911,947688a46e1a8d2bf058fc2bd7dfbaf7ea8444135a142f7c266d7b7198d05bc0
logo.svg,1707590450489,861ef96db8e9adace3f580944747289b6a5704bc798e917dc5449dd7a49dd560
manifest.json,1707590450490,55750b48311acbc8a8e79a712b06c86159fb6e31d8dedaf965408b92da601522
robots.txt,1707590450490,391d14b3c2f8c9143a27a28c7399585142228d4d1bdbe2c87ac946de411fa9a2
logo256.png,1707590450490,174027c4e97105e2e006e42620822304e0d3fdee4d390a423f15f0abc16ef781
service-worker.js,1707590450491,a3f50c6b1b991c1283d72c591d4a539309f211f23277f34c97b315672698e7ad
logo512.png,1707590450490,3db7a8824f96f862029199fbb398ab312bb4688d52b1a0ab0e2a311422a21ab3
assets/web-vitals-BptxjviT.js,1707590450915,3ffd55f59352ddeafd5ff621f81d31444c53f3ae25242797564de702ed442492
assets/index-GFucon3z.css,1707590450915,c3fbc77ed030c76efde8028c7525eba676ad96eaa3f9289036d714639706151c
assets/index-vT9CBK8Y.js,1707590450916,d282cd8eb80e3040b8a9b56595639786f580501e8f4c1e0cf1278993b787501b
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@types/uuid": "^9.0.1",
"dayjs": "^1.11.7",
"dexie": "^3.2.3",
"dexie-export-import": "^4.1.1",
"dexie-react-hooks": "^1.1.1",
"embla-carousel-react": "^7.0.9",
"firebase": "^9.18.0",
Expand Down
1 change: 1 addition & 0 deletions public/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ self.addEventListener("activate", (event) => {

// eslint-disable-next-line no-restricted-globals
self.addEventListener("fetch", (event) => {
console.log("service-worker: fetch", event.request.url);
// Skip cross-origin requests, like those for Google Analytics.

// eslint-disable-next-line no-restricted-globals
Expand Down
30 changes: 0 additions & 30 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ import i18n from "./i18n";
import { useSetting } from "./logic/Settings";
import { cssVariablesResolver, presetTheme } from "./style/StyleProvider";

async function persist() {
return (
(await navigator.storage) &&
navigator.storage.persist &&
navigator.storage.persist()
);
}

async function isStoragePersisted() {
return (
(await navigator.storage) &&
navigator.storage.persisted &&
navigator.storage.persisted()
);
}
function useRestoreLanguage() {
const [language] = useSetting("language");
useEffect(() => {
Expand All @@ -46,21 +31,6 @@ export default function App() {
defaultValue: false,
});

useEffect(() => {
isStoragePersisted().then(async (isPersisted) => {
if (isPersisted) {
console.log(":) Storage is successfully persisted.");
} else {
console.log(":( Storage is not persisted.");
console.log("Trying to persist..:");
if (await persist()) {
console.log(":) We successfully turned the storage to be persisted.");
} else {
console.log(":( Failed to make storage persisted");
}
}
});
}, []);
return (
<I18nextProvider i18n={i18n}>
<MantineProvider
Expand Down
17 changes: 8 additions & 9 deletions src/components/CardManagerView/CardManagerView.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import classes from "./CardManagerView.module.css";
import React, { useState } from "react";
import { ActionIcon, Group, Stack, TextInput } from "@mantine/core";
import { Card, CardType, useCardsWith } from "../../logic/card";
import { useDebouncedState } from "@mantine/hooks";
import { IconChevronLeft, IconSearch } from "@tabler/icons-react";
import { useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import CardTable from "../CardTable/CardTable";
import EditCardView from "../editcard/EditCardView";
import { Card, CardType, useCardsWith } from "../../logic/card";
import selectCards from "../../logic/card_filter";
import { useDecks } from "../../logic/deck";
import { IconChevronLeft, IconSearch } from "@tabler/icons-react";
import CardTable from "../CardTable/CardTable";
import SelectDecksHeader from "../custom/SelectDecksHeader";
import { useDebouncedState } from "@mantine/hooks";
import selectCards from "../../logic/card_filter";
import CardHistory from "../statistics/CardHistory";
import EditCardView from "../editcard/EditCardView";
import classes from "./CardManagerView.module.css";

function CardManagerView() {
const navigate = useNavigate();
Expand Down
5 changes: 1 addition & 4 deletions src/components/DebugCardModal/DebugCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
& thead {
font-family: var(--mantine-font-family-headings);
font-size: var(--mantine-font-size-sm);
& th {
padding: 0;
padding-top: var(--mantine-spacing-md);
}

}
}

Expand Down
214 changes: 110 additions & 104 deletions src/components/DebugCardModal/DebugCardTable.tsx
Original file line number Diff line number Diff line change
@@ -1,122 +1,128 @@
import classes from "./DebugCard.module.css";
import { Fragment } from "react";
import { Card, CardType } from "../../logic/card";
import { Anchor, Space, Text } from "@mantine/core";
import { Anchor, Space, Stack, Text } from "@mantine/core";
import { Rating, State } from "fsrs.js";

export default function DebugCardTable({
card,
}: { card: Card<CardType> | undefined }) {
return card ? (
<table className={classes.table}>
<tbody>
<tr>
<th>Card Type:</th>
<td>{card.content.type}</td>
</tr>
<tr>
<th>ID:</th>
<td>{card.id}</td>
</tr>
<tr>
<th>Content:</th>
<td>{JSON.stringify(card.content)}</td>
</tr>
<tr>
<th>Decks:</th>
<td>
<Anchor href={"/deck/" + card.deck}>{card.deck}</Anchor>,{" "}
</td>
</tr>
</tbody>
<tbody>
<Stack className={classes.container}>
<table className={classes.table}>
<tbody>
<tr>
<th>Card Type:</th>
<td>{card.content.type}</td>
</tr>
<tr>
<th>ID:</th>
<td>{card.id}</td>
</tr>
<tr>
<th>Content:</th>
<td>{JSON.stringify(card.content)}</td>
</tr>
<tr>
<th>Decks:</th>
<td>
<Anchor href={"/deck/" + card.deck}>{card.deck}</Anchor>,{" "}
</td>
</tr>
</tbody>
</table>
<table className={classes.table}>
<thead>
<th>FSRS Model</th>
</thead>
<tr>
<th>Due:</th>
<td>
{card.model.due.toLocaleDateString()},
{card.model.due.toLocaleTimeString()}
</td>
</tr>
<tr>
<th>Stability:</th>
<td>{card.model.stability}</td>
</tr>
<tr>
<th>Difficulty:</th>
<td>{card.model.difficulty}</td>
</tr>
<tr>
<th>Elapsed Days:</th>
<td>{card.model.elapsed_days}</td>
</tr>
<tr>
<th>Scheduled Days:</th>
<td>{card.model.scheduled_days}</td>
</tr>
<tr>
<th>Repetitions:</th>
<td>{card.model.reps}</td>
</tr>
<tr>
<th>Lapses:</th>
<td>{card.model.lapses}</td>
</tr>
<tr>
<th>State:</th>
<td>{card.model.state}</td>
</tr>
<tr>
<th>Last Review:</th>
<td>
{card.model.last_review.toLocaleDateString()},
{card.model.last_review.toLocaleTimeString()}
</td>
</tr>
</tbody>
<tbody>
<tbody>
<tr>
<th>Due:</th>
<td>
{card.model.due.toLocaleDateString()},
{card.model.due.toLocaleTimeString()}
</td>
</tr>
<tr>
<th>Stability:</th>
<td>{card.model.stability}</td>
</tr>
<tr>
<th>Difficulty:</th>
<td>{card.model.difficulty}</td>
</tr>
<tr>
<th>Elapsed Days:</th>
<td>{card.model.elapsed_days}</td>
</tr>
<tr>
<th>Scheduled Days:</th>
<td>{card.model.scheduled_days}</td>
</tr>
<tr>
<th>Repetitions:</th>
<td>{card.model.reps}</td>
</tr>
<tr>
<th>Lapses:</th>
<td>{card.model.lapses}</td>
</tr>
<tr>
<th>State:</th>
<td>{card.model.state}</td>
</tr>
<tr>
<th>Last Review:</th>
<td>
{card.model.last_review.toLocaleDateString()},
{card.model.last_review.toLocaleTimeString()}
</td>
</tr>
</tbody>
</table>
<table className={classes.table}>
<thead>
<th>History</th>
</thead>
{card.history.length}
{card.history.map((log) => (
<Fragment key={log.review.toISOString()}>
<tr>
<th>Date: </th>
<td>
{log.review.toLocaleDateString()},
{log.review.toLocaleTimeString()}
</td>
</tr>
<tr>
<th>Result: </th>
<td>
{Rating[log.rating]} ({log.rating})
</td>
</tr>
<tr>
<th>State: </th>
<td>
{State[log.state]} ({log.state})
</td>
</tr>
<tr>
<th>Elapsed Days: </th>
<td>{log.elapsed_days}</td>
</tr>
<tr>
<th>Scheduled Days: </th>
<td>{log.scheduled_days}</td>
</tr>
<tr>
<Space h="xs" />
</tr>
</Fragment>
))}
</tbody>
</table>
<tbody>
{card.history.length}
{card.history.map((log) => (
<Fragment key={log.review.toISOString()}>
<tr>
<th>Date: </th>
<td>
{log.review.toLocaleDateString()},
{log.review.toLocaleTimeString()}
</td>
</tr>
<tr>
<th>Result: </th>
<td>
{Rating[log.rating]} ({log.rating})
</td>
</tr>
<tr>
<th>State: </th>
<td>
{State[log.state]} ({log.state})
</td>
</tr>
<tr>
<th>Elapsed Days: </th>
<td>{log.elapsed_days}</td>
</tr>
<tr>
<th>Scheduled Days: </th>
<td>{log.scheduled_days}</td>
</tr>
<tr>
<Space h="xs" />
</tr>
</Fragment>
))}
</tbody>
</table>
</Stack>
) : (
<Text color="dimmed" fz="sm">
This card could not be found.
Expand Down
Loading

0 comments on commit 23d420d

Please sign in to comment.