From a6c75099754fd185ed7b4c06fad909cf050af90a Mon Sep 17 00:00:00 2001 From: ransome1 Date: Wed, 10 Jan 2024 21:19:47 +0100 Subject: [PATCH] Fixed flickering of splashscreen's contents --- src/renderer/App.tsx | 6 +----- src/renderer/IpcRenderer.tsx | 3 --- src/renderer/Prompt.tsx | 2 -- src/renderer/SplashScreen.tsx | 28 +++++++--------------------- 4 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 2e948560..f7cee891 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -36,7 +36,6 @@ const translatedAttributes = (t: typeof i18n.t) => ({ const App = () => { const [settings, setSettings] = useState(store.get()); - const [splashScreen, setSplashScreen] = useState(null); const [snackBarOpen, setSnackBarOpen] = useState(false); const [snackBarContent, setSnackBarContent] = useState(null); const [snackBarSeverity, setSnackBarSeverity] = useState(); @@ -66,7 +65,6 @@ const App = () => { setVisibleRowCount(30); setLoadMoreRows(true); if(settings.files?.length === 0) { - setSplashScreen('noFiles'); setTodoObjects(null); } }, [settings.files]); @@ -91,7 +89,6 @@ const App = () => { setSnackBarSeverity={setSnackBarSeverity} setSnackBarContent={setSnackBarContent} setSettings={setSettings} - setSplashScreen={setSplashScreen} setIsSettingsOpen={setIsSettingsOpen} /> {settings.matomo && ( @@ -163,11 +160,10 @@ const App = () => { )} diff --git a/src/renderer/IpcRenderer.tsx b/src/renderer/IpcRenderer.tsx index 923ae5ad..b3333ea5 100644 --- a/src/renderer/IpcRenderer.tsx +++ b/src/renderer/IpcRenderer.tsx @@ -13,7 +13,6 @@ interface Props { setSnackBarSeverity: React.Dispatch>; setSnackBarContent: React.Dispatch>; setSettings: React.Dispatch>; - setSplashScreen: React.Dispatch>; setIsSettingsOpen: React.Dispatch>; } @@ -27,7 +26,6 @@ const IpcComponent: React.FC = ({ setSnackBarSeverity, setSnackBarContent, setSettings, - setSplashScreen, setIsSettingsOpen, }) => { @@ -36,7 +34,6 @@ const IpcComponent: React.FC = ({ if(requestedData?.attributes) setAttributes(requestedData.attributes); if(requestedData?.filters) setFilters(requestedData.filters); if(requestedData?.todoObjects) setTodoObjects(requestedData.todoObjects); - setSplashScreen(null); }; const handleUpdateAttributeFields = (todoObject: TodoObject) => { diff --git a/src/renderer/Prompt.tsx b/src/renderer/Prompt.tsx index 5667a609..d1c9101c 100644 --- a/src/renderer/Prompt.tsx +++ b/src/renderer/Prompt.tsx @@ -37,7 +37,6 @@ const Prompt: React.FC = ({ {promptItem?.headline && {promptItem.headline}} {promptItem?.text &&

{promptItem.text}

} - {promptItem?.button1 && } {promptItem?.button2 && } - ); diff --git a/src/renderer/SplashScreen.tsx b/src/renderer/SplashScreen.tsx index e5db8e69..8a9a9d94 100644 --- a/src/renderer/SplashScreen.tsx +++ b/src/renderer/SplashScreen.tsx @@ -7,23 +7,21 @@ import { withTranslation, WithTranslation } from 'react-i18next'; import './SplashScreen.scss'; import { i18n } from './Settings/LanguageSelector'; -interface Props extends WithTranslation { - splashScreen: string | null; +interface SplashScreenProps extends WithTranslation { setSearchString: React.Dispatch>; setDialogOpen: React.Dispatch>; - setSplashScreen: React.Dispatch>; headers: HeadersObject | null; + settings: Settings; t: typeof i18n.t; } const { ipcRenderer, store } = window.api; -const SplashScreen: FC = memo(({ - splashScreen, +const SplashScreen: FC = memo(({ setSearchString, setDialogOpen, - setSplashScreen, headers, + settings, t, }) => { const handleCreateTodo = () => { @@ -43,21 +41,9 @@ const SplashScreen: FC = memo(({ ipcRenderer.send('createFile', false); }; - useEffect(() => { - if(!headers) { - return; - } else if(headers.availableObjects === 0) { - if(splashScreen !== 'noTodosAvailable') setSplashScreen('noTodosAvailable') - } else if(headers.visibleObjects === 0) { - if(splashScreen !== 'noTodosVisible') setSplashScreen('noTodosVisible'); - } else { - setSplashScreen(null); - } - }, [headers]); - return ( - {splashScreen === 'noTodosVisible' && ( + {settings.files?.length > 0 && headers?.visibleObjects === 0 && headers?.availableObjects > 0 && ( <>

{t('splashscreen.noTodosVisible.text')}

@@ -68,7 +54,7 @@ const SplashScreen: FC = memo(({
)} - {splashScreen === 'noTodosAvailable' && ( + {settings.files?.length > 0 && headers?.availableObjects === 0 && ( <>

{t('splashscreen.noTodosAvailable.text')}

@@ -79,7 +65,7 @@ const SplashScreen: FC = memo(({ )} - {splashScreen === 'noFiles' && ( + {settings.files?.length === 0 && (

{t('splashscreen.noFiles.text')}