diff --git a/public/locales/en.json b/public/locales/en.json index d85940b..9f3e436 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -292,6 +292,7 @@ "blockHashCopyButtons": "Show copy buttons next to all block hashes", "showRelativeDates": "Show relative dates instead of absolute ones if recent", "showRelativeDatesDescription": "Everywhere on the site, if a date is less than 7 days ago, it will show as a relative date instead.", + "transactionDefaultRaw": "Default to the 'Raw' tab instead of 'CommonMeta' on the transaction page", "subMenuDebug": "Debug settings", "advancedWalletFormats": "Advanced wallet formats", diff --git a/src/pages/settings/SettingsPage.tsx b/src/pages/settings/SettingsPage.tsx index 4437fec..6a3240b 100644 --- a/src/pages/settings/SettingsPage.tsx +++ b/src/pages/settings/SettingsPage.tsx @@ -86,6 +86,11 @@ descriptionKey="settings.showRelativeDatesDescription" /> + + {/* Default to 'Raw' on transaction page */} + + + {/* Debug settings */} diff --git a/src/pages/transactions/TransactionMetadataCard.tsx b/src/pages/transactions/TransactionMetadataCard.tsx index c6083cd..adae6e1 100644 --- a/src/pages/transactions/TransactionMetadataCard.tsx +++ b/src/pages/transactions/TransactionMetadataCard.tsx @@ -12,13 +12,19 @@ import { parseCommonMeta } from "../../utils/commonmeta"; import { HelpIcon } from "../../components/HelpIcon"; +import { useBooleanSetting } from "../../utils/settings"; const { Text, Title } = Typography; // TODO: This is definitely too crude for my taste, but I had no better ideas const HAS_COMMONMETA = /[=;]/; -export function CommonMetaTable({ metadata, nameSuffix }: { metadata: string; nameSuffix: string }): JSX.Element { +interface CommonMetaTableProps { + metadata: string; + nameSuffix: string; +} + +export function CommonMetaTable({ metadata, nameSuffix }: CommonMetaTableProps): JSX.Element { const { t } = useTranslation(); // Parse the CommonMeta from the transaction, showing an error if it fails @@ -89,10 +95,13 @@ const { t } = useTranslation(); const nameSuffix = useSelector((s: RootState) => s.node.currency.name_suffix); + // Default to the 'Raw' tab instead of 'CommonMeta' + const defaultRaw = useBooleanSetting("transactionDefaultRaw"); + // Estimate in advance if a CommonMeta tab should be showed const hasCommonMeta = HAS_COMMONMETA.test(metadata); const [activeTab, setActiveTab] = useState<"commonMeta" | "raw">( - hasCommonMeta ? "commonMeta" : "raw" + hasCommonMeta && !defaultRaw ? "commonMeta" : "raw" ); // Tab list for the card diff --git a/src/utils/settings.ts b/src/utils/settings.ts index 5dd2931..95f6d24 100644 --- a/src/utils/settings.ts +++ b/src/utils/settings.ts @@ -29,6 +29,8 @@ readonly blockHashCopyButtons: boolean; /** Show relative dates instead of absolute ones when they are recent. */ readonly showRelativeDates: boolean; + /** Default to the 'Raw' tab instead of 'CommonMeta' on the transaction page. */ + readonly transactionDefaultRaw: boolean; /** Whether or not advanced wallet formats are enabled. */ readonly walletFormats: boolean; @@ -43,6 +45,7 @@ nameCopyButtons: false, blockHashCopyButtons: false, showRelativeDates: false, + transactionDefaultRaw: false, walletFormats: false };