Skip to content

Commit

Permalink
refactor: remove "back" usage where not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
heyqbnk committed Oct 12, 2024
1 parent 9d191a1 commit cec0585
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/components/Page/Page.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEffect } from 'solid-js';
import { createEffect, createMemo } from 'solid-js';
import { backButton } from '@telegram-apps/sdk-solid';

import { useNavigate } from '@solidjs/router';
Expand All @@ -7,9 +7,10 @@ import './Page.css';

export function Page(props) {
const navigate = useNavigate();
const back = createMemo(() => typeof props.back === 'boolean' ? props.back : true);

createEffect(() => {
if (props.back) {
if (back()) {
backButton.show();
return backButton.onClick(() => {
navigate(-1);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/IndexPage/IndexPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './IndexPage.css';

export function IndexPage() {
return (
<Page title="Home Page" back>
<Page title="Home Page" back={false}>
<p>
This page is a home page in this boilerplate. You can use the links below to visit other
pages with their own functionality.
Expand Down
1 change: 0 additions & 1 deletion src/pages/InitDataPage/InitDataPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export function InitDataPage() {

return (
<Page
back
title="Init Data"
disclaimer={(
<>
Expand Down
1 change: 0 additions & 1 deletion src/pages/LaunchParamsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function LaunchParamsPage() {

return (
<Page
back
title="Launch Params"
disclaimer={(
<>
Expand Down
1 change: 0 additions & 1 deletion src/pages/ThemeParamsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function ThemeParamsPage() {

return (
<Page
back
title="Theme Params"
disclaimer={(
<>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TonConnectPage/TonConnectPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function TonConnectPage() {
const wallet = useTonWallet();

return (
<Page title="TON Connect" back>
<Page title="TON Connect">
<Show
when={wallet()}
fallback={
Expand Down

0 comments on commit cec0585

Please sign in to comment.