TagSpaces is an offline, open source, document manager with tagging support
TSN477 - fix opening prev and next files from the electron menus (#1232)
Stanimir0e24a2c40fa4
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex 14a60958b..786b0d076 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -185,6 +185,7 @@ interface Props {toggleAboutDialog: () => void; // needed by electron-menustoggleOnboardingDialog: () => void; // needed by electron-menussetLastSelectedEntry: (path: string) => void; // needed by electron-menus+ setSelectedEntries: (path: string) => void; // needed by electron-menusopenFsEntry: (fsEntry: FileSystemEntry) => void; // needed by electron-menusopenFileNatively: (url: string) => void; // needed by electron-menusopenURLExternally: (url: string) => void;@@ -1012,6 +1013,7 @@ function mapDispatchToProps(dispatch) {toggleAboutDialog: AppActions.toggleAboutDialog,toggleOnboardingDialog: AppActions.toggleOnboardingDialog,setLastSelectedEntry: AppActions.setLastSelectedEntry,+ setSelectedEntries: AppActions.setSelectedEntries,setGeneratingThumbnails: AppActions.setGeneratingThumbnails,openFsEntry: AppActions.openFsEntry,openFileNatively: AppActions.openFileNatively,diff --git a/app/services/electron-menus.ts b/app/services/electron-menus.tsindex 8454fbbca..16cbdabb8 100644--- a/app/services/electron-menus.ts+++ b/app/services/electron-menus.ts@@ -19,6 +19,7 @@import i18n from './i18n';import PlatformIO from './platform-io';import AppConfig from '../config';+import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';let ipcRenderer;@@ -46,14 +47,34 @@ export default function buildDesktopMenu(mainPageProps: any) {break;case 'next-file': {const path = mainPageProps.getNextFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);+ getAllPropertiesPromise(path)+ .then((fsEntry: FileSystemEntry) => {+ mainPageProps.openFsEntry(fsEntry);+ mainPageProps.setLastSelectedEntry(path);+ mainPageProps.setSelectedEntries([path]);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + path + ' - ' + error+ )+ );break;}case 'previous-file': {const path = mainPageProps.getPrevFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);+ getAllPropertiesPromise(path)+ .then((fsEntry: FileSystemEntry) => {+ mainPageProps.openFsEntry(fsEntry);+ mainPageProps.setLastSelectedEntry(path);+ mainPageProps.setSelectedEntries([path]);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + path + ' - ' + error+ )+ );break;}default:diff --git a/app/services/electron-tray-menu.ts b/app/services/electron-tray-menu.tsindex 59d340d02..bb4e8d42a 100644--- a/app/services/electron-tray-menu.ts+++ b/app/services/electron-tray-menu.ts@@ -20,6 +20,7 @@import PlatformIO from './platform-io';import i18n from './i18n';import AppConfig from '../config';+import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';export default function buildTrayIconMenu(mainPageProps: any) {if (!AppConfig.isElectron) {@@ -30,14 +31,34 @@ export default function buildTrayIconMenu(mainPageProps: any) {function openNextFile() {const path = mainPageProps.getNextFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);+ getAllPropertiesPromise(path)+ .then((fsEntry: FileSystemEntry) => {+ mainPageProps.openFsEntry(fsEntry);+ mainPageProps.setLastSelectedEntry(path);+ mainPageProps.setSelectedEntries([path]);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + path + ' - ' + error+ )+ );}function openPrevFile() {const path = mainPageProps.getPrevFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);+ getAllPropertiesPromise(path)+ .then((fsEntry: FileSystemEntry) => {+ mainPageProps.openFsEntry(fsEntry);+ mainPageProps.setLastSelectedEntry(path);+ mainPageProps.setSelectedEntries([path]);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + path + ' - ' + error+ )+ );}function playResumePlayback() {