Skip to content

Commit

Permalink
Prioritize new forgotten cards (#12)
Browse files Browse the repository at this point in the history
* Prioritize new forgotten cards
  • Loading branch information
kubk authored Feb 5, 2024
1 parent 853e0da commit 45a7f9a
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 114 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ ngrok
.dev.vars

dumper/dump.sql
gitexporter.config.json
2 changes: 1 addition & 1 deletion src/lib/mobx-form/persistable-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makePersistable } from "mobx-persist-store";
import { FieldWithValue } from "./field-with-value.ts";
import { storageAdapter } from "../telegram/storage-adapter.ts";

export const persistableField = <T extends FieldWithValue<any>>(
export const persistableField = <T extends FieldWithValue<unknown>>(
field: T,
storageKey: string,
expireIn?: number,
Expand Down
11 changes: 9 additions & 2 deletions src/screens/component-catalog/components.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Button } from "../../ui/button.tsx";
import { ReactNode } from "react";
import { CardPreviewStory } from "./card-preview-story.tsx";
import { SelectStory } from "./select-story.tsx";

export type Component = { name: string; component: ReactNode };
export type Component = {
name: string;
component: ReactNode;
};

export const components: Array<Component> = [
{
name: "Button",
component: <Button>Button</Button>,
},

{
name: "Button - outline",
component: <Button outline>Button</Button>,
Expand Down Expand Up @@ -39,4 +42,8 @@ export const components: Array<Component> = [
/>
),
},
{
name: "Select",
component: <SelectStory />,
},
];
23 changes: 23 additions & 0 deletions src/screens/component-catalog/select-story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Select } from "../../ui/select.tsx";
import { useState } from "react";

const countries = [
{ value: "us", label: "United States" },
{ value: "fr", label: "France" },
{ value: "de", label: "Germany" },
];

type Country = (typeof countries)[number]["value"];

export const SelectStory = () => {
const [value, setValue] = useState<Country>("us");
return (
<Select
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
options={countries}
/>
);
};
7 changes: 6 additions & 1 deletion src/screens/deck-review/store/card-under-review-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { assert } from "../../../lib/typescript/assert.ts";
import { removeAllTags } from "../../../lib/sanitize-html/remove-all-tags.ts";
import { userStore } from "../../../store/user-store.ts";
import { BooleanToggle } from "../../../lib/mobx-form/boolean-toggle.ts";
import { CardReviewType } from "../../../../functions/db/deck/get-cards-to-review-db.ts";

export enum CardState {
Remember = "remember",
Expand All @@ -36,7 +37,11 @@ export class CardUnderReviewStore {
// A hack for iOS when the card content is too large
isOverflowing = new BooleanToggle(false);

constructor(card: DeckCardDbType, deck: DeckWithCardsWithReviewType) {
constructor(
card: DeckCardDbType,
deck: DeckWithCardsWithReviewType,
public cardReviewType: CardReviewType,
) {
this.id = card.id;
this.front = card.front;
this.back = card.back;
Expand Down
Loading

0 comments on commit 45a7f9a

Please sign in to comment.