diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index bdcac18ef2..a89ef293c6 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -919,6 +919,8 @@ "installed": "Installed components:", "installing": "Installation in progress: {{component}}", "loading": "Loading", + "loading-available": "Loading available components ...", + "no-components": "No available components", "nothingYet": "Nothing was installed by Winetricks yet", "openGUI": "Open Winetricks GUI", "search": "Search fonts or components" diff --git a/src/frontend/components/UI/Winetricks/index.tsx b/src/frontend/components/UI/Winetricks/index.tsx index 6631278730..4a0dfbeb19 100644 --- a/src/frontend/components/UI/Winetricks/index.tsx +++ b/src/frontend/components/UI/Winetricks/index.tsx @@ -15,12 +15,13 @@ export default function Winetricks({ onClose, runner }: Props) { const { appName } = useContext(SettingsContext) const { t } = useTranslation() - const [loading, setLoading] = useState(true) + const [loadingInstalled, setLoadingInstalled] = useState(true) + const [loadingAvailable, setLoadingAvailable] = useState(true) // keep track of all installed components for a game/app const [installed, setInstalled] = useState([]) async function listInstalled() { - setLoading(true) + setLoadingInstalled(true) try { const components = await window.api.winetricksListInstalled( runner, @@ -30,7 +31,7 @@ export default function Winetricks({ onClose, runner }: Props) { } catch { setInstalled([]) } - setLoading(false) + setLoadingInstalled(false) } useEffect(() => { listInstalled() @@ -39,6 +40,7 @@ export default function Winetricks({ onClose, runner }: Props) { const [allComponents, setAllComponents] = useState([]) useEffect(() => { async function listComponents() { + setLoadingAvailable(true) try { const components = await window.api.winetricksListAvailable( runner, @@ -48,7 +50,9 @@ export default function Winetricks({ onClose, runner }: Props) { } catch { setAllComponents([]) } + setLoadingAvailable(false) } + listComponents() }, []) @@ -108,9 +112,9 @@ export default function Winetricks({ onClose, runner }: Props) { const dialogContent = ( <> - {!loading && ( + {!loadingInstalled && (
- {!installing && ( + {!installing && allComponents.length !== 0 && (
)} + {loadingAvailable && ( + + {t( + 'winetricks.loading-available', + 'Loading available components ...' + )} + + )} + {!loadingAvailable && allComponents.length === 0 && ( + + {t('winetricks.no-components', 'No available components')} + + )} {installing && (

{t( @@ -140,8 +157,8 @@ export default function Winetricks({ onClose, runner }: Props) {

{t('winetricks.installed', 'Installed components:')} - {loading && {t('winetricks.loading', 'Loading')}} - {!loading && installed.length === 0 && ( + {loadingInstalled && {t('winetricks.loading', 'Loading')}} + {!loadingInstalled && installed.length === 0 && ( {t( 'winetricks.nothingYet', @@ -149,7 +166,7 @@ export default function Winetricks({ onClose, runner }: Props) { )} )} - {!loading && {installed.join(', ')}} + {!loadingInstalled && {installed.join(', ')}}
)