TagSpaces is an offline, open source, document manager with tagging support
Optimize KanBan init (#2326)
Stanimirb5534ddf6cba
diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex 17011faf8..fe13d58c0 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -77,7 +77,7 @@ function FolderContainer(props: Props) {const {currentDirectoryEntries,currentDirectoryPath,- getPerspective,+ currentPerspective,setManualDirectoryPerspective,enterSearchMode,isSearchMode,@@ -326,7 +326,7 @@ function FolderContainer(props: Props) {</div>{isDesktopMode && (<ToggleButtonGroup- value={getPerspective()}+ value={currentPerspective}size="small"data-tid="floatingPerspectiveSwitcher"disabled={showWelcomePanel}diff --git a/src/renderer/components/RenderPerspective.tsx b/src/renderer/components/RenderPerspective.tsxindex e4748ac04..a459abaa9 100644--- a/src/renderer/components/RenderPerspective.tsx+++ b/src/renderer/components/RenderPerspective.tsx@@ -154,7 +154,7 @@ interface Props {}function RenderPerspective(props: Props) {const { currentLocationId } = useCurrentLocationContext();- const { getPerspective } = useDirectoryContentContext();+ const { currentPerspective } = useDirectoryContentContext();const { metaActions } = useEditedEntryMetaContext();const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);const firstRender = useFirstRender();@@ -177,20 +177,19 @@ function RenderPerspective(props: Props) {}function getPerspectiveComponent() {- const perspective = getPerspective();- if (perspective === PerspectiveIDs.LIST) {+ if (currentPerspective === PerspectiveIDs.LIST) {return <ListPerspectiveAsync />;}- if (Pro && perspective === PerspectiveIDs.GALLERY) {+ if (Pro && currentPerspective === PerspectiveIDs.GALLERY) {return <GalleryPerspectiveAsync />;}- if (Pro && perspective === PerspectiveIDs.MAPIQUE) {+ if (Pro && currentPerspective === PerspectiveIDs.MAPIQUE) {return <MapiquePerspectiveAsync />;}- if (Pro && perspective === PerspectiveIDs.KANBAN) {+ if (Pro && currentPerspective === PerspectiveIDs.KANBAN) {return <KanBanPerspectiveAsync />;}- if (Pro && perspective === PerspectiveIDs.FOLDERVIZ) {+ if (Pro && currentPerspective === PerspectiveIDs.FOLDERVIZ) {return <FolderVizPerspectiveAsync />;}diff --git a/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx b/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsxindex 52d0f8472..2272f0498 100644--- a/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx+++ b/src/renderer/components/dialogs/hooks/TargetPathContextProvider.tsx@@ -40,14 +40,15 @@ export const TargetPathContextProvider = ({}: TargetPathContextProviderProps) => {const { findLocation, getFirstRWLocation } = useCurrentLocationContext();const { selectedEntries } = useSelectedEntriesContext();- const { currentDirectoryPath, getPerspective } = useDirectoryContentContext();+ const { currentDirectoryPath, currentPerspective } =+ useDirectoryContentContext();const firstRWLocation = getFirstRWLocation();const context = useMemo(() => {let targetDirectoryPath = currentDirectoryPath;if (- getPerspective() === PerspectiveIDs.KANBAN &&+ currentPerspective === PerspectiveIDs.KANBAN &&selectedEntries &&selectedEntries.length === 1 &&!selectedEntries[0].isFilediff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsxindex 0b038ae18..840bc46a8 100644--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx@@ -136,7 +136,7 @@ type DirectoryContentContextData = {enterSearchMode: () => void;exitSearchMode: () => void;getDefaultPerspectiveSettings: (perspective: string) => TS.FolderSettings;- getPerspective: () => TS.PerspectiveType;+ currentPerspective: TS.PerspectiveType;getAllPropertiesPromise: (entryPath: string,locationID?: string,@@ -196,7 +196,7 @@ export const DirectoryContentContext =enterSearchMode: () => {},exitSearchMode: () => {},getDefaultPerspectiveSettings: undefined,- getPerspective: undefined,+ currentPerspective: undefined,getAllPropertiesPromise: undefined,loadCurrentDirMeta: undefined,openIsTruncatedConfirmDialog: undefined,@@ -616,7 +616,6 @@ export const DirectoryContentContextProvider = ({}function getDefaultDirMeta(): TS.FileSystemEntryMeta {- // const perspective = getPerspective();const settings: TS.PerspectiveSettings = {[defaultPerspective]: getDefaultPerspectiveSettings(defaultPerspective),};@@ -1142,16 +1141,11 @@ export const DirectoryContentContextProvider = ({return directoryContent;}- /*const perspective = useMemo(- () => getPerspective(),- [directoryMeta.current?.perspective, manualPerspective.current],- );*/-function isSearching(): boolean {return Object.keys(searchQuery.current).length > 0;}- function getPerspective(): TS.PerspectiveType {+ const currentPerspective: TS.PerspectiveType = useMemo(() => {if (manualPerspective.current === 'unspecified') {if (!directoryMeta.current ||@@ -1163,7 +1157,7 @@ export const DirectoryContentContextProvider = ({return directoryMeta.current.perspective;}return manualPerspective.current;- }+ }, [currentDirectory.current, manualPerspective.current]);function setManualDirectoryPerspective(perspective: TS.PerspectiveType,@@ -1584,7 +1578,6 @@ export const DirectoryContentContextProvider = ({currentLocationPath: currentLocationPath.current,currentDirectoryEntries: currentDirectoryEntries.current,directoryMeta: directoryMeta.current,- //currentDirectoryPerspective: currentPerspective.current,currentDirectoryPath: currentDirectory.current?.path,currentDirectory: currentDirectory.current,currentDirectoryFiles: currentDirectoryFiles.current,@@ -1594,7 +1587,7 @@ export const DirectoryContentContextProvider = ({isSearchMode: isSearchMode.current,isSearching,sendDirMessage,- getPerspective,+ currentPerspective,updateCurrentDirEntry,setSearchQuery,loadDirectoryContent,diff --git a/src/renderer/hooks/FSWatcherContextProvider.tsx b/src/renderer/hooks/FSWatcherContextProvider.tsxindex f92a95116..5fafa5113 100644--- a/src/renderer/hooks/FSWatcherContextProvider.tsx+++ b/src/renderer/hooks/FSWatcherContextProvider.tsx@@ -65,7 +65,7 @@ export const FSWatcherContextProvider = ({currentDirectoryEntries,loadDirectoryContent,currentDirectoryPath,- getPerspective,+ currentPerspective,} = useDirectoryContentContext();const { setReflectActions, reflectUpdateMeta } = useEditedEntryContext();const ignored = useRef<string[]>([]);@@ -81,7 +81,7 @@ export const FSWatcherContextProvider = ({currentLocation.type !== locationType.TYPE_CLOUD) {if (currentDirectoryPath && currentDirectoryPath.length > 0) {- const depth = getPerspective() === PerspectiveIDs.KANBAN ? 3 : 1;+ const depth = currentPerspective === PerspectiveIDs.KANBAN ? 3 : 1;watchFolder(currentDirectoryPath, depth);}diff --git a/src/renderer/hooks/PerspectiveSettingsContextProvider.tsx b/src/renderer/hooks/PerspectiveSettingsContextProvider.tsxindex 5fff15a98..4c232e36e 100644--- a/src/renderer/hooks/PerspectiveSettingsContextProvider.tsx+++ b/src/renderer/hooks/PerspectiveSettingsContextProvider.tsx@@ -92,20 +92,20 @@ export const PerspectiveSettingsContextProvider = ({directoryMeta,setDirectoryMeta,getDefaultPerspectiveSettings,- getPerspective,+ currentPerspective,} = useDirectoryContentContext();const { metaActions } = useEditedEntryMetaContext();const { removeFolderCustomSettings, saveCurrentLocationMetaData } =useIOActionsContext();const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);const settings = useRef<TS.FolderSettings>(- getSettings(getPerspective(), directoryMeta),+ getSettings(currentPerspective, directoryMeta),);const firstRender = useFirstRender();useEffect(() => {if (!firstRender) {- settings.current = getSettings(getPerspective(), directoryMeta);+ settings.current = getSettings(currentPerspective, directoryMeta);forceUpdate();}}, [currentDirectoryPath, directoryMeta]);@@ -114,7 +114,7 @@ export const PerspectiveSettingsContextProvider = ({if (!firstRender && metaActions && metaActions.length > 0) {for (const action of metaActions) {if (action.action === 'perspectiveChange') {- settings.current = getSettings(getPerspective(), directoryMeta);+ settings.current = getSettings(currentPerspective, directoryMeta);forceUpdate();}}@@ -160,7 +160,7 @@ export const PerspectiveSettingsContextProvider = ({return (directoryMeta &&directoryMeta.perspectiveSettings &&- directoryMeta.perspectiveSettings[getPerspective()]+ directoryMeta.perspectiveSettings[currentPerspective]);}@@ -168,10 +168,10 @@ export const PerspectiveSettingsContextProvider = ({* remove custom folder settings*/function resetLocalSetting() {- removeFolderCustomSettings(currentDirectoryPath, getPerspective()).then(+ removeFolderCustomSettings(currentDirectoryPath, currentPerspective).then((fsEntryMeta: TS.FileSystemEntryMeta) => {setDirectoryMeta(fsEntryMeta);- settings.current = getSettings(getPerspective(), fsEntryMeta);+ settings.current = getSettings(currentPerspective, fsEntryMeta);forceUpdate();},);@@ -187,14 +187,14 @@ export const PerspectiveSettingsContextProvider = ({if (Pro && !isDefaultSetting) {setPerspectiveSettings(currentDirectoryPath,- getPerspective(),+ currentPerspective,settings.current,).then((updatedFsEntryMeta: TS.FileSystemEntryMeta) => {saveCurrentLocationMetaData(currentDirectoryPath, updatedFsEntryMeta);setDirectoryMeta(updatedFsEntryMeta);});} else {- const defaultSettings = getDefaultPerspectiveSettings(getPerspective());+ const defaultSettings = getDefaultPerspectiveSettings(currentPerspective);localStorage.setItem(defaultSettings.settingsKey,JSON.stringify(settings.current),