Skip to content

Commit

Permalink
switch to useMainButton hook everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Oct 13, 2023
1 parent 4f0d8b6 commit a848de5
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/screens/deck-review/deck-finished.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { random } from "../../lib/array/random.ts";
import WebApp from "@twa-dev/sdk";
import { useMount } from "../../lib/react/use-mount.ts";
import { screenStore } from "../../store/screen-store.ts";
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";

const encouragingMessages = [
"Consistency is the key to mastery, and each step you take brings you closer to your learning goals",
Expand All @@ -21,22 +22,14 @@ export const DeckFinished = observer(() => {
const reviewStore = useReviewStore();

useMount(() => {
WebApp.MainButton.show();
WebApp.MainButton.setText("Go back");
WebApp.MainButton.showProgress();
const onClick = () => {
screenStore.navigateToMain();
};
WebApp.MainButton.onClick(onClick);

reviewStore.submit().finally(() => {
WebApp.MainButton.hideProgress();
});
});

return () => {
WebApp.MainButton.hide();
WebApp.MainButton.offClick(onClick);
};
useMainButton("Go back", () => {
screenStore.navigateToMain();
});

return (
Expand Down

0 comments on commit a848de5

Please sign in to comment.