diff --git a/public/locales/en.json b/public/locales/en.json index f3230c1..15e4455 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -323,6 +323,7 @@ "subMenuAutoRefresh": "Auto-refresh", "autoRefreshTables": "Auto-refresh tables", "autoRefreshTablesDescription": "Whether or not large table listings (e.g. transactions, names) should automatically refresh when a change is detected on the network.", + "autoRefreshAddressPage": "Auto-refresh address page", "subMenuAdvanced": "Advanced settings", "alwaysIncludeMined": "Always include mined transactions in transaction listings (may require refresh)", diff --git a/src/components/addresses/picker/Header.tsx b/src/components/addresses/picker/Header.tsx index 6e2102e..e63bdae 100644 --- a/src/components/addresses/picker/Header.tsx +++ b/src/components/addresses/picker/Header.tsx @@ -3,7 +3,9 @@ // Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt import React from "react"; -export function getCategoryHeader(category: string) { +import { OptionChildren } from "./options"; + +export function getCategoryHeader(category: string): Omit { return { label: (
diff --git a/src/components/addresses/picker/options.ts b/src/components/addresses/picker/options.ts index 3732dfd..efcf3c2 100644 --- a/src/components/addresses/picker/options.ts +++ b/src/components/addresses/picker/options.ts @@ -21,10 +21,13 @@ "data-wallet-label"?: string; value: string; } + export interface OptionChildren { label: React.ReactNode; + "data-picker-category": string; options: OptionValue[]; } + export type Option = OptionValue | OptionChildren; // ----------------------------------------------------------------------------- diff --git a/src/pages/CheckStatus.tsx b/src/pages/CheckStatus.tsx index 62620df..1811700 100644 --- a/src/pages/CheckStatus.tsx +++ b/src/pages/CheckStatus.tsx @@ -3,7 +3,7 @@ // Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt import React from "react"; -import { AppLayout } from "../layout/AppLayout"; +import { AppLayout } from "@layout/AppLayout"; import { StatusPage } from "./StatusPage"; export function CheckStatus(): JSX.Element { diff --git a/src/pages/addresses/AddressPage.tsx b/src/pages/addresses/AddressPage.tsx index 7278970..8df7455 100644 --- a/src/pages/addresses/AddressPage.tsx +++ b/src/pages/addresses/AddressPage.tsx @@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next"; import { useParams } from "react-router-dom"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { Statistic } from "@comp/Statistic"; @@ -18,6 +18,7 @@ import { lookupAddress, KristAddressWithNames } from "@api/lookup"; import { useWallets } from "@wallets"; import { useSubscription } from "@global/ws/WebsocketSubscription"; +import { useBooleanSetting } from "@utils/settings"; import { AddressButtonRow } from "./AddressButtonRow"; import { AddressTransactionsCard } from "./AddressTransactionsCard"; @@ -126,6 +127,8 @@ // Used to refresh the address data when a transaction is made to it const lastTransactionID = useSubscription({ address }); + const shouldAutoRefresh = useBooleanSetting("autoRefreshAddressPage"); + const usedRefreshID = shouldAutoRefresh ? lastTransactionID : 0; // Load the address on page load // TODO: passthrough router state to pre-load from search @@ -143,7 +146,7 @@ lookupAddress(address, true) .then(setKristAddress) .catch(setError); - }, [syncNode, address, lastTransactionID]); + }, [syncNode, address, usedRefreshID]); // Change the page title depending on whether or not the address has loaded const title = kristAddress @@ -172,7 +175,7 @@ ? ( ) : )} diff --git a/src/pages/blocks/BlockPage.tsx b/src/pages/blocks/BlockPage.tsx index fee9fe2..f129a88 100644 --- a/src/pages/blocks/BlockPage.tsx +++ b/src/pages/blocks/BlockPage.tsx @@ -11,7 +11,7 @@ import { useSelector } from "react-redux"; import { RootState } from "@store"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { Statistic } from "@comp/Statistic"; diff --git a/src/pages/blocks/BlocksPage.tsx b/src/pages/blocks/BlocksPage.tsx index 526e69e..d3b60a8 100644 --- a/src/pages/blocks/BlocksPage.tsx +++ b/src/pages/blocks/BlocksPage.tsx @@ -6,7 +6,7 @@ import { useSelector } from "react-redux"; import { RootState } from "@store"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { BlocksTable } from "./BlocksTable"; diff --git a/src/pages/credits/CreditsPage.tsx b/src/pages/credits/CreditsPage.tsx index cf382fb..e701721 100644 --- a/src/pages/credits/CreditsPage.tsx +++ b/src/pages/credits/CreditsPage.tsx @@ -5,7 +5,7 @@ import { Typography, Descriptions, Divider } from "antd"; import { useTranslation, Trans } from "react-i18next"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { Supporters } from "./Supporters"; import { Translators } from "./Translators"; import { DateTime } from "@comp/DateTime"; diff --git a/src/pages/dashboard/DashboardPage.tsx b/src/pages/dashboard/DashboardPage.tsx index 4dbcde2..343d5d7 100644 --- a/src/pages/dashboard/DashboardPage.tsx +++ b/src/pages/dashboard/DashboardPage.tsx @@ -4,7 +4,7 @@ import React from "react"; import { Row, Col } from "antd"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { InDevBanner } from "./InDevBanner"; diff --git a/src/pages/dev/DevPage.tsx b/src/pages/dev/DevPage.tsx index 046a21d..edb3385 100644 --- a/src/pages/dev/DevPage.tsx +++ b/src/pages/dev/DevPage.tsx @@ -3,7 +3,7 @@ // Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt import React, { useState } from "react"; import { Button } from "antd"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { ImportBackupModal } from "../backup/ImportBackupModal"; import { AuthorisedAction } from "@comp/auth/AuthorisedAction"; diff --git a/src/pages/names/NamePage.tsx b/src/pages/names/NamePage.tsx index 9c36d6d..8eb4813 100644 --- a/src/pages/names/NamePage.tsx +++ b/src/pages/names/NamePage.tsx @@ -11,7 +11,7 @@ import { useSelector } from "react-redux"; import { RootState } from "@store"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { Statistic } from "@comp/Statistic"; diff --git a/src/pages/names/NamesPage.tsx b/src/pages/names/NamesPage.tsx index 22334d5..0d649df 100644 --- a/src/pages/names/NamesPage.tsx +++ b/src/pages/names/NamesPage.tsx @@ -9,7 +9,7 @@ import { useSelector } from "react-redux"; import { RootState } from "@store"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { NoWalletsResult } from "@comp/results/NoWalletsResult"; import { NamesTable } from "./NamesTable"; diff --git a/src/pages/settings/SettingsPage.tsx b/src/pages/settings/SettingsPage.tsx index f173f2e..a899356 100644 --- a/src/pages/settings/SettingsPage.tsx +++ b/src/pages/settings/SettingsPage.tsx @@ -8,7 +8,7 @@ import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; -import { PageLayout, PageLayoutProps } from "../../layout/PageLayout"; +import { PageLayout, PageLayoutProps } from "@layout/PageLayout"; import { SettingBoolean } from "./SettingBoolean"; import { SettingInteger } from "./SettingInteger"; import { getLanguageItems } from "./translations/LanguageItem"; @@ -50,6 +50,11 @@ descriptionKey="settings.autoRefreshTablesDescription" /> + + {/* Auto-refresh tables */} + + + {/* Advanced settings */} diff --git a/src/pages/transactions/TransactionPage.tsx b/src/pages/transactions/TransactionPage.tsx index b4c167e..61fe728 100644 --- a/src/pages/transactions/TransactionPage.tsx +++ b/src/pages/transactions/TransactionPage.tsx @@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next"; import { useParams } from "react-router-dom"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { Statistic } from "@comp/Statistic"; diff --git a/src/pages/transactions/TransactionsPage.tsx b/src/pages/transactions/TransactionsPage.tsx index 58119e4..fa9800d 100644 --- a/src/pages/transactions/TransactionsPage.tsx +++ b/src/pages/transactions/TransactionsPage.tsx @@ -12,7 +12,7 @@ import { RootState } from "@store"; import { State as NodeState } from "@reducers/NodeReducer"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { APIErrorResult } from "@comp/results/APIErrorResult"; import { NoWalletsResult } from "@comp/results/NoWalletsResult"; import { TransactionsTable } from "./TransactionsTable"; diff --git a/src/pages/wallets/WalletsPage.tsx b/src/pages/wallets/WalletsPage.tsx index d4079c6..9a072da 100644 --- a/src/pages/wallets/WalletsPage.tsx +++ b/src/pages/wallets/WalletsPage.tsx @@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next"; -import { PageLayout } from "../../layout/PageLayout"; +import { PageLayout } from "@layout/PageLayout"; import { AuthorisedAction } from "@comp/auth/AuthorisedAction"; import { AddWalletModal } from "./AddWalletModal"; import { WalletsTable } from "./WalletsTable"; diff --git a/src/utils/settings.ts b/src/utils/settings.ts index 47d7b72..f54abb7 100644 --- a/src/utils/settings.ts +++ b/src/utils/settings.ts @@ -22,6 +22,9 @@ /** Whether or not tables (e.g. transactions, names) should auto-refresh * when a change is detected on the network. */ readonly autoRefreshTables: boolean; + /** Whether or not the address page should auto-refresh when a change is + * detected on the network. */ + readonly autoRefreshAddressPage: boolean; // =========================================================================== // ADVANCED SETTINGS @@ -52,6 +55,7 @@ export const DEFAULT_SETTINGS: SettingsState = { autoRefreshTables: true, + autoRefreshAddressPage: true, alwaysIncludeMined: false, copyNameSuffixes: true, diff --git a/tsconfig.extend.json b/tsconfig.extend.json index 5ac721f..4c5d57f 100644 --- a/tsconfig.extend.json +++ b/tsconfig.extend.json @@ -11,6 +11,7 @@ "@store/*": ["./store/*"], "@comp/*": ["./components/*"], + "@layout/*": ["./layout/*"], "@pages/*": ["./pages/*"], "@api": ["./krist/api"],