TagSpaces is an offline, open source, document manager with tagging support
Prev and next button do not work in gallery and mapique (#2096)
Stanimir4f6342fa5883
diff --git a/package-lock.json b/package-lock.jsonindex 56915d5a5..77f15214c 100644--- a/package-lock.json+++ b/package-lock.json@@ -196,7 +196,7 @@"yarn": "please-use-npm"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.34"+ "@tagspacespro/tagspacespro": "5.0.36"}},"node_modules/@aashutoshrathi/word-wrap": {@@ -13529,9 +13529,9 @@}},"node_modules/@tagspacespro/tagspacespro": {- "version": "5.0.34",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.34/f93136bac5b4a58377f0f27c665600a3be022123",- "integrity": "sha512-TwIrJK+p05TwaoOlfFEFZd4Br4lj7oumXX/1hyVMGl3rvHrxcNy7vp44XfKd3Bw4u4j4yVbegk51FZhMiSCnwg==",+ "version": "5.0.36",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.36/0101f14364b95797fc113e62536821a807402bed",+ "integrity": "sha512-ukfPYlFh7cdEehtBfcUzxZBFj5cSLAUysH6lQW2vEYNEbZaeDyjUyy2WbU2mopXKb8xrp4lplWak07BZFFbUSg==","license": "Proprietary","optional": true},@@ -59428,9 +59428,9 @@}},"@tagspacespro/tagspacespro": {- "version": "5.0.34",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.34/f93136bac5b4a58377f0f27c665600a3be022123",- "integrity": "sha512-TwIrJK+p05TwaoOlfFEFZd4Br4lj7oumXX/1hyVMGl3rvHrxcNy7vp44XfKd3Bw4u4j4yVbegk51FZhMiSCnwg==",+ "version": "5.0.36",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.36/0101f14364b95797fc113e62536821a807402bed",+ "integrity": "sha512-ukfPYlFh7cdEehtBfcUzxZBFj5cSLAUysH6lQW2vEYNEbZaeDyjUyy2WbU2mopXKb8xrp4lplWak07BZFFbUSg==","optional": true},"@teamsupercell/typings-for-css-modules-loader": {diff --git a/package.json b/package.jsonindex 5ffc71c3a..9014dd4d4 100644--- a/package.json+++ b/package.json@@ -228,7 +228,7 @@"uuid": "^9.0.0"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.34"+ "@tagspacespro/tagspacespro": "5.0.36"},"devDependencies": {"@electron/notarize": "^2.3.2",diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsxindex 5e278d12d..80b648bd4 100644--- a/src/renderer/components/EntryContainer.tsx+++ b/src/renderer/components/EntryContainer.tsx@@ -69,6 +69,7 @@ import { getRelativeEntryPath } from '-/services/utils-io';import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';import { SaveIcon, EditIcon } from '-/components/CommonIcons';import { useIOActionsContext } from '-/hooks/useIOActionsContext';+import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};@@ -84,6 +85,7 @@ function EntryContainer() {reflectUpdateOpenedFileContent,addToEntryContainer,} = useOpenedEntryContext();+ const { setActions } = usePerspectiveActionsContext();const { saveDescription, description } = useDescriptionContext();const { setAutoSave, getMetadataID } = useIOActionsContext();const { findLocation, readOnlyMode } = useCurrentLocationContext();@@ -594,13 +596,15 @@ function EntryContainer() {setPanelOpened(!isPanelOpened);};const openNextFileAction = () => {- window.dispatchEvent(new Event('next-file'));- //openNextFile(openedEntry.path);+ const action: TS.PerspectiveActions = { action: 'openNext' };+ setActions(action);+ // window.dispatchEvent(new Event('next-file'));};const openPrevFileAction = () => {- window.dispatchEvent(new Event('previous-file'));- //openPrevFile(openedEntry.path);+ const action: TS.PerspectiveActions = { action: 'openPrevious' };+ setActions(action);+ //window.dispatchEvent(new Event('previous-file'));};const fileExtension =diff --git a/src/renderer/components/EntryContainerNav.tsx b/src/renderer/components/EntryContainerNav.tsxindex 873e9ae71..24375f287 100644--- a/src/renderer/components/EntryContainerNav.tsx+++ b/src/renderer/components/EntryContainerNav.tsx@@ -8,6 +8,8 @@ import NextDocumentIcon from '@mui/icons-material/ExpandCircleDownOutlined';import Tooltip from '-/components/Tooltip';import { useTranslation } from 'react-i18next';import { getKeyBindingObject } from '-/reducers/settings';+import { TS } from '-/tagspaces.namespace';+import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';interface Props {isFile: boolean;@@ -16,6 +18,7 @@ interface Props {function EntryContainerNav(props: Props) {const { isFile, startClosingEntry } = props;+ const { setActions } = usePerspectiveActionsContext();const keyBindings = useSelector(getKeyBindingObject);const { t } = useTranslation();const theme = useTheme();@@ -42,8 +45,11 @@ function EntryContainerNav(props: Props) {aria-label={t('core:openPrevFileTooltip')}data-tid="fileContainerPrevFile"onClick={() => {- window.dispatchEvent(new Event('previous-file'));- //openPrevFile()+ const action: TS.PerspectiveActions = {+ action: 'openPrevious',+ };+ setActions(action);+ //window.dispatchEvent(new Event('previous-file'));}}// size="large">@@ -58,8 +64,9 @@ function EntryContainerNav(props: Props) {aria-label={t('core:openNextFileTooltip')}data-tid="fileContainerNextFile"onClick={() => {- window.dispatchEvent(new Event('next-file'));- // openNextFile()+ const action: TS.PerspectiveActions = { action: 'openNext' };+ setActions(action);+ //window.dispatchEvent(new Event('next-file'));}}// size="large">diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsxindex 1c766deab..ed6b47d59 100644--- a/src/renderer/containers/Root.tsx+++ b/src/renderer/containers/Root.tsx@@ -43,6 +43,7 @@ import { EditedEntryMetaContextProvider } from '-/hooks/EditedEntryMetaContextPrimport { TagGroupsLocationContextProvider } from '-/hooks/TagGroupsLocationContextProvider';import { EditedTagLibraryContextProvider } from '-/hooks/EditedTagLibraryContextProvider';import { EditedKanBanMetaContextProvider } from '-/hooks/EditedKanBanMetaContextProvider';+import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsContextProvider';type RootType = {store: Store<{}>;@@ -69,29 +70,31 @@ export default function Root({ store, persistor }: RootType) {<EditedEntryContextProvider><EditedEntryMetaContextProvider><EditedTagLibraryContextProvider>- <EditedKanBanMetaContextProvider>- <SelectedEntryContextProvider>- <DirectoryContentContextProvider>- <FSWatcherContextProvider>- <PlatformFacadeContextProvider>- <LocationIndexContextProvider>- <OpenedEntryContextProvider>- <IOActionsContextProvider>- <TagGroupsLocationContextProvider>- <TaggingActionsContextProvider>- <DndProvider backend={HTML5Backend}>- <MainPage />- </DndProvider>- </TaggingActionsContextProvider>- </TagGroupsLocationContextProvider>- </IOActionsContextProvider>- </OpenedEntryContextProvider>- </LocationIndexContextProvider>- </PlatformFacadeContextProvider>- </FSWatcherContextProvider>- </DirectoryContentContextProvider>- </SelectedEntryContextProvider>- </EditedKanBanMetaContextProvider>+ <PerspectiveActionsContextProvider>+ <EditedKanBanMetaContextProvider>+ <SelectedEntryContextProvider>+ <DirectoryContentContextProvider>+ <FSWatcherContextProvider>+ <PlatformFacadeContextProvider>+ <LocationIndexContextProvider>+ <OpenedEntryContextProvider>+ <IOActionsContextProvider>+ <TagGroupsLocationContextProvider>+ <TaggingActionsContextProvider>+ <DndProvider backend={HTML5Backend}>+ <MainPage />+ </DndProvider>+ </TaggingActionsContextProvider>+ </TagGroupsLocationContextProvider>+ </IOActionsContextProvider>+ </OpenedEntryContextProvider>+ </LocationIndexContextProvider>+ </PlatformFacadeContextProvider>+ </FSWatcherContextProvider>+ </DirectoryContentContextProvider>+ </SelectedEntryContextProvider>+ </EditedKanBanMetaContextProvider>+ </PerspectiveActionsContextProvider></EditedTagLibraryContextProvider></EditedEntryMetaContextProvider></EditedEntryContextProvider>diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsxindex 14980c639..e738ba169 100644--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx@@ -30,6 +30,8 @@ import { TS } from '-/tagspaces.namespace';import {findExtensionPathForId,getDirProperties,+ getNextFile,+ getPrevFile,getRelativeEntryPath,openURLExternally,} from '-/services/utils-io';@@ -85,6 +87,8 @@ type OpenedEntryContextData = {fsEntry: TS.FileSystemEntry,showDetails?,) => Promise<boolean>;+ openNextFile: (entries: TS.FileSystemEntry[]) => TS.FileSystemEntry;+ openPrevFile: (entries: TS.FileSystemEntry[]) => TS.FileSystemEntry;toggleEntryFullWidth: () => void;openLink: (url: string, options?) => void;goForward: () => void;@@ -113,6 +117,8 @@ export const OpenedEntryContext = createContext<OpenedEntryContextData>({openEntry: undefined,openFsEntry: undefined,openEntryInternal: undefined,+ openNextFile: undefined,+ openPrevFile: undefined,toggleEntryFullWidth: () => {},openLink: () => {},goForward: () => {},@@ -141,7 +147,7 @@ export const OpenedEntryContextProvider = ({getAllPropertiesPromise,} = useDirectoryContentContext();- const { selectedEntries } = useSelectedEntriesContext();+ const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();const { showNotification } = useNotificationContext();const { actions } = useEditedEntryContext();const { metaActions } = useEditedEntryMetaContext();@@ -260,6 +266,40 @@ export const OpenedEntryContextProvider = ({}}, [currentDirectoryPerspective]);*/+ function openNextFile(entries: TS.FileSystemEntry[]): TS.FileSystemEntry {+ const nextFile = getNextFile(+ currentEntry.current?.path,+ selectedEntries && selectedEntries.length > 0+ ? selectedEntries[selectedEntries.length - 1].path+ : undefined,+ entries,+ );+ if (nextFile !== undefined) {+ openFsEntry(nextFile);+ // dispatch(actions.setLastSelectedEntry(nextFile.path));+ setSelectedEntries([nextFile]);+ return nextFile;+ }+ return undefined;+ }++ function openPrevFile(entries: TS.FileSystemEntry[]): TS.FileSystemEntry {+ const prevFile = getPrevFile(+ currentEntry.current?.path,+ selectedEntries && selectedEntries.length > 0+ ? selectedEntries[selectedEntries.length - 1].path+ : undefined,+ entries,+ );+ if (prevFile !== undefined) {+ openFsEntry(prevFile);+ // dispatch(actions.setLastSelectedEntry(prevFile.path));+ setSelectedEntries([prevFile]);+ return prevFile;+ }+ return undefined;+ }+function getOpenedDirProps(): Promise<TS.DirProp> {if (currentEntry.current &&@@ -949,6 +989,8 @@ export const OpenedEntryContextProvider = ({openEntry,openFsEntry,openEntryInternal,+ openNextFile,+ openPrevFile,toggleEntryFullWidth,goForward,goBack,diff --git a/src/renderer/hooks/PerspectiveActionsContextProvider.tsx b/src/renderer/hooks/PerspectiveActionsContextProvider.tsxnew file mode 100644index 000000000..acc7663ca--- /dev/null+++ b/src/renderer/hooks/PerspectiveActionsContextProvider.tsx@@ -0,0 +1,61 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import { TS } from '-/tagspaces.namespace';++type PerspectiveActionsContextData = {+ actions: TS.PerspectiveActions[];+ setActions: (...actionsArray: TS.PerspectiveActions[]) => void;+};++export const PerspectiveActionsContext =+ createContext<PerspectiveActionsContextData>({+ actions: undefined,+ setActions: undefined,+ });++export type PerspectiveActionsContextProviderProps = {+ children: React.ReactNode;+};++export const PerspectiveActionsContextProvider = ({+ children,+}: PerspectiveActionsContextProviderProps) => {+ const actions = useRef<TS.PerspectiveActions[]>(undefined);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function setActions(...actionsArray: TS.PerspectiveActions[]) {+ actions.current = actionsArray;+ forceUpdate();+ }++ const context = useMemo(() => {+ return {+ actions: actions.current,+ setActions,+ };+ }, [actions.current]);++ return (+ <PerspectiveActionsContext.Provider value={context}>+ {children}+ </PerspectiveActionsContext.Provider>+ );+};diff --git a/src/renderer/hooks/usePerspectiveActionsContext.tsx b/src/renderer/hooks/usePerspectiveActionsContext.tsxnew file mode 100644index 000000000..e38455fee--- /dev/null+++ b/src/renderer/hooks/usePerspectiveActionsContext.tsx@@ -0,0 +1,24 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import { useContext } from 'react';++import { PerspectiveActionsContext } from './PerspectiveActionsContextProvider';++export const usePerspectiveActionsContext = () =>+ useContext(PerspectiveActionsContext);diff --git a/src/renderer/perspectives/grid/components/MainContainer.tsx b/src/renderer/perspectives/grid/components/MainContainer.tsxindex 5c9822b4c..4c34da744 100644--- a/src/renderer/perspectives/grid/components/MainContainer.tsx+++ b/src/renderer/perspectives/grid/components/MainContainer.tsx@@ -16,7 +16,7 @@**/-import React, { useRef, useState } from 'react';+import React, { useEffect, useRef, useState } from 'react';import { useSelector, useDispatch } from 'react-redux';import { GlobalHotKeys } from 'react-hotkeys';import { getDesktopMode, getKeyBindingObject } from '-/reducers/settings';@@ -49,6 +49,8 @@ import { GridCellsStyleContextProvider } from '-/perspectives/grid/hooks/GridCelimport { useRendererListenerContext } from '-/hooks/useRendererListenerContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';+import useFirstRender from '-/utils/useFirstRender';interface Props {openRenameEntryDialog: () => void;@@ -58,6 +60,7 @@ function GridPerspective(props: Props) {const { openRenameEntryDialog } = props;const { openEntry } = useOpenedEntryContext();+ const { actions } = usePerspectiveActionsContext();const { openPrevFile, openNextFile } = useRendererListenerContext();const { showDirectories } = usePerspectiveSettingsContext();const { currentLocation } = useCurrentLocationContext();@@ -108,6 +111,19 @@ function GridPerspective(props: Props) {useState<boolean>(false);const [isGridSettingsDialogOpened, setIsGridSettingsDialogOpened] =useState<boolean>(false);+ const firstRender = useFirstRender();++ useEffect(() => {+ if (!firstRender && actions && actions.length > 0) {+ for (const action of actions) {+ if (action.action === 'openNext') {+ openNextFile();+ } else if (action.action === 'openPrevious') {+ openPrevFile();+ }+ }+ }+ }, [actions]);const handleSortBy = (handleSort) => {if (sortBy !== handleSort) {diff --git a/src/renderer/perspectives/list/components/MainContainer.tsx b/src/renderer/perspectives/list/components/MainContainer.tsxindex 953293318..f7c061f8a 100644--- a/src/renderer/perspectives/list/components/MainContainer.tsx+++ b/src/renderer/perspectives/list/components/MainContainer.tsx@@ -16,7 +16,7 @@**/-import React, { useRef, useState } from 'react';+import React, { useEffect, useRef, useState } from 'react';import { useSelector, useDispatch } from 'react-redux';import { GlobalHotKeys } from 'react-hotkeys';import { getDesktopMode, getKeyBindingObject } from '-/reducers/settings';@@ -49,6 +49,8 @@ import { ListCellsStyleContextProvider } from '../hooks/ListCellsStyleProvider';import { useRendererListenerContext } from '-/hooks/useRendererListenerContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';+import useFirstRender from '-/utils/useFirstRender';interface Props {openRenameEntryDialog: () => void;@@ -58,6 +60,7 @@ function ListPerspective(props: Props) {const { openRenameEntryDialog } = props;const { openEntry } = useOpenedEntryContext();+ const { actions } = usePerspectiveActionsContext();const { openPrevFile, openNextFile } = useRendererListenerContext();const { showDirectories } = usePerspectiveSettingsContext();const { currentLocation } = useCurrentLocationContext();@@ -108,6 +111,19 @@ function ListPerspective(props: Props) {useState<boolean>(false);const [isGridSettingsDialogOpened, setIsGridSettingsDialogOpened] =useState<boolean>(false);+ const firstRender = useFirstRender();++ useEffect(() => {+ if (!firstRender && actions && actions.length > 0) {+ for (const action of actions) {+ if (action.action === 'openNext') {+ openNextFile();+ } else if (action.action === 'openPrevious') {+ openPrevFile();+ }+ }+ }+ }, [actions]);const handleSortBy = (handleSort) => {if (sortBy !== handleSort) {diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.tsindex fecaf969b..dd6359d98 100644--- a/src/renderer/tagspaces.namespace.d.ts+++ b/src/renderer/tagspaces.namespace.d.ts@@ -134,6 +134,10 @@ export namespace TS {entry: TS.FileSystemEntry;}+ interface PerspectiveActions {+ action: 'openNext' | 'openPrevious';+ }+interface KanBanMetaActions {action: 'directoryVisibilityChange';meta: TS.FileSystemEntryMeta;