Date: Sat, 2 Apr 2022 18:08:00 +0200
Subject: [PATCH 6/8] Fix for preview window for images in a newly added
location
---
.../containers/ContentView/Placeholder.tsx | 47 ++++++++++++++++++-
src/frontend/stores/FileStore.ts | 2 +-
src/renderer.tsx | 18 +++++--
3 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/src/frontend/containers/ContentView/Placeholder.tsx b/src/frontend/containers/ContentView/Placeholder.tsx
index 103f06247..c5681e5e3 100644
--- a/src/frontend/containers/ContentView/Placeholder.tsx
+++ b/src/frontend/containers/ContentView/Placeholder.tsx
@@ -1,12 +1,16 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { observer } from 'mobx-react-lite';
import LOGO_FC from 'resources/logo/svg/full-color/allusion-logomark-fc.svg';
+import { IS_PREVIEW_WINDOW } from 'common/window';
import { useStore } from '../../contexts/StoreContext';
const Placeholder = observer(() => {
const { fileStore, tagStore } = useStore();
+ if (IS_PREVIEW_WINDOW) {
+ return ;
+ }
if (fileStore.showsAllContent && tagStore.isEmpty) {
// No tags exist, and no images added: Assuming it's a new user -> Show a welcome screen
return ;
@@ -26,6 +30,47 @@ const Placeholder = observer(() => {
export default Placeholder;
import { IconSet, Button, ButtonGroup, SVG } from 'widgets';
+import { RendererMessenger } from 'src/Messaging';
+import useMountState from 'src/frontend/hooks/useMountState';
+
+const PreviewWindowPlaceholder = observer(() => {
+ const { fileStore } = useStore();
+ const [isLoading, setIsLoading] = useState(true);
+ const [, isMounted] = useMountState();
+ useEffect(() => {
+ setIsLoading(true);
+ setTimeout(() => {
+ if (isMounted.current) {
+ setIsLoading(false);
+ }
+ }, 1000);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [fileStore.fileListLastModified]);
+
+ if (isLoading) {
+ return (
+ }>
+ {IconSet.LOADING}
+
+ );
+ }
+
+ // There should always be images to preview.
+ // If the placeholder is shown, something went wrong (probably the DB of the preview window is out of sync with the main window)
+ return (
+ }>
+ Something went wrong while previewing the selected images
+
+
+
+