From 8aad1bdf75304e820c7efe09856b115547b6981f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 8 Jun 2025 01:55:29 +0200 Subject: [PATCH] Reduce final useAppSelector((s) => s.settings.X) to useSettings((s) => s.X) (#390) --- src-gui/src/renderer/components/other/Units.tsx | 7 +++---- src-gui/src/renderer/components/pages/help/SettingsBox.tsx | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src-gui/src/renderer/components/other/Units.tsx b/src-gui/src/renderer/components/other/Units.tsx index d40aad90..7ed764ae 100644 --- a/src-gui/src/renderer/components/other/Units.tsx +++ b/src-gui/src/renderer/components/other/Units.tsx @@ -1,5 +1,5 @@ import { Tooltip } from "@mui/material"; -import { useAppSelector } from "store/hooks"; +import { useAppSelector, useSettings } from "store/hooks"; import { getMarkup, piconerosToXmr, satsToBtc } from "utils/conversionUtils"; type Amount = number | null | undefined; @@ -17,10 +17,9 @@ export function AmountWithUnit({ exchangeRate?: Amount; parenthesisText?: string; }) { - const fetchFiatPrices = useAppSelector( - (state) => state.settings.fetchFiatPrices, + const [fetchFiatPrices, fiatCurrency] = useSettings( + (settings) => [settings.fetchFiatPrices, settings.fiatCurrency], ); - const fiatCurrency = useAppSelector((state) => state.settings.fiatCurrency); const title = fetchFiatPrices && exchangeRate != null && diff --git a/src-gui/src/renderer/components/pages/help/SettingsBox.tsx b/src-gui/src/renderer/components/pages/help/SettingsBox.tsx index eb09ab97..85e847f4 100644 --- a/src-gui/src/renderer/components/pages/help/SettingsBox.tsx +++ b/src-gui/src/renderer/components/pages/help/SettingsBox.tsx @@ -37,7 +37,6 @@ import { } from "store/features/settingsSlice"; import { useAppDispatch, - useAppSelector, useNodes, useSettings, } from "store/hooks"; @@ -329,7 +328,7 @@ function MoneroNodeUrlSetting() { * A setting that allows you to select the theme of the GUI. */ function ThemeSetting() { - const theme = useAppSelector((s) => s.settings.theme); + const theme = useSettings((s) => s.theme); const dispatch = useAppDispatch(); return (