Skip to content

Commit

Permalink
Fixed flickering of splashscreen's contents
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Jan 10, 2024
1 parent f069910 commit a6c7509
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
6 changes: 1 addition & 5 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const translatedAttributes = (t: typeof i18n.t) => ({

const App = () => {
const [settings, setSettings] = useState<Settings>(store.get());
const [splashScreen, setSplashScreen] = useState<string | null>(null);
const [snackBarOpen, setSnackBarOpen] = useState<boolean>(false);
const [snackBarContent, setSnackBarContent] = useState<string | null>(null);
const [snackBarSeverity, setSnackBarSeverity] = useState<AlertColor | undefined>();
Expand Down Expand Up @@ -66,7 +65,6 @@ const App = () => {
setVisibleRowCount(30);
setLoadMoreRows(true);
if(settings.files?.length === 0) {
setSplashScreen('noFiles');
setTodoObjects(null);
}
}, [settings.files]);
Expand All @@ -91,7 +89,6 @@ const App = () => {
setSnackBarSeverity={setSnackBarSeverity}
setSnackBarContent={setSnackBarContent}
setSettings={setSettings}
setSplashScreen={setSplashScreen}
setIsSettingsOpen={setIsSettingsOpen}
/>
{settings.matomo && (
Expand Down Expand Up @@ -163,11 +160,10 @@ const App = () => {
</>
)}
<SplashScreen
splashScreen={splashScreen}
setDialogOpen={setDialogOpen}
setSearchString={setSearchString}
setSplashScreen={setSplashScreen}
headers={headers}
settings={settings}
/>
</Box>
</Box>
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/IpcRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface Props {
setSnackBarSeverity: React.Dispatch<React.SetStateAction<AlertColor | undefined>>;
setSnackBarContent: React.Dispatch<React.SetStateAction<string | null>>;
setSettings: React.Dispatch<React.SetStateAction<Settings>>;
setSplashScreen: React.Dispatch<React.SetStateAction<string | null>>;
setIsSettingsOpen: React.Dispatch<React.SetStateAction<boolean>>;
}

Expand All @@ -27,7 +26,6 @@ const IpcComponent: React.FC<Props> = ({
setSnackBarSeverity,
setSnackBarContent,
setSettings,
setSplashScreen,
setIsSettingsOpen,
}) => {

Expand All @@ -36,7 +34,6 @@ const IpcComponent: React.FC<Props> = ({
if(requestedData?.attributes) setAttributes(requestedData.attributes);
if(requestedData?.filters) setFilters(requestedData.filters);
if(requestedData?.todoObjects) setTodoObjects(requestedData.todoObjects);
setSplashScreen(null);
};

const handleUpdateAttributeFields = (todoObject: TodoObject) => {
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const Prompt: React.FC<Props> = ({
{promptItem?.headline && <DialogTitle>{promptItem.headline}</DialogTitle>}
{promptItem?.text && <DialogContent><p>{promptItem.text}</p></DialogContent>}
<DialogActions>

<Button
onClick={onClose}
data-testid="prompt-button-cancel"
Expand All @@ -46,7 +45,6 @@ const Prompt: React.FC<Props> = ({
</Button>
{promptItem?.button1 && <Button onClick={() => onClick(promptItem.onButton1)} data-testid={`prompt-button-${promptItem.button1}`}>{promptItem.button1}</Button>}
{promptItem?.button2 && <Button onClick={() => onClick(promptItem.onButton2)} data-testid={`prompt-button-${promptItem.button2}`}>{promptItem.button2}</Button>}

</DialogActions>
</Dialog>
);
Expand Down
28 changes: 7 additions & 21 deletions src/renderer/SplashScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<React.SetStateAction<string>>;
setDialogOpen: React.Dispatch<React.SetStateAction<boolean>>;
setSplashScreen: React.Dispatch<React.SetStateAction<string | null>>;
headers: HeadersObject | null;
settings: Settings;
t: typeof i18n.t;
}

const { ipcRenderer, store } = window.api;

const SplashScreen: FC<Props> = memo(({
splashScreen,
const SplashScreen: FC<SplashScreenProps> = memo(({
setSearchString,
setDialogOpen,
setSplashScreen,
headers,
settings,
t,
}) => {
const handleCreateTodo = () => {
Expand All @@ -43,21 +41,9 @@ const SplashScreen: FC<Props> = 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 (
<Box id='splashScreen'>
{splashScreen === 'noTodosVisible' && (
{settings.files?.length > 0 && headers?.visibleObjects === 0 && headers?.availableObjects > 0 && (
<>
<DryCleaningIcon />
<p>{t('splashscreen.noTodosVisible.text')}</p>
Expand All @@ -68,7 +54,7 @@ const SplashScreen: FC<Props> = memo(({
</Box>
</>
)}
{splashScreen === 'noTodosAvailable' && (
{settings.files?.length > 0 && headers?.availableObjects === 0 && (
<>
<BeachAccessIcon />
<p>{t('splashscreen.noTodosAvailable.text')}</p>
Expand All @@ -79,7 +65,7 @@ const SplashScreen: FC<Props> = memo(({
</Box>
</>
)}
{splashScreen === 'noFiles' && (
{settings.files?.length === 0 && (
<Box className="fileDropZone">
<SaveAltIcon />
<p>{t('splashscreen.noFiles.text')}</p>
Expand Down

0 comments on commit a6c7509

Please sign in to comment.