TagSpaces is an offline, open source, document manager with tagging support
fix: reducing the usage of openFileNatively, fixing #1420
Ilian Sapundshiev0bed17e14681
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 53f4fa982..9b68dee3c 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -334,10 +334,6 @@ const EntryContainer = (props: Props) => {// console.log('Open link externally: ' + data.link);props.openLink(data.link);break;- case 'openFileNatively':- console.log('Open file natively: ' + data.link);- props.openFileNatively(data.link);- break;case 'loadDefaultTextContent':if (!openedFile || !openedFile.path) {// || openedFile.changed) {diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex be61114e5..a962c2807 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -215,7 +215,6 @@ interface Props {removeTags: () => void;removeAllTags: () => void;editTagForEntry: () => void;- openFileNatively: (path: string) => void;renameFile: () => void;openDirectory: () => void;showInFileManager: () => void;@@ -629,7 +628,6 @@ function mapActionCreatorsToProps(dispatch) {removeTags: TaggingActions.removeTags,removeAllTags: TaggingActions.removeAllTags,editTagForEntry: TaggingActions.editTagForEntry,- openFileNatively: AppActions.openFileNatively,renameFile: AppActions.renameFile,openDirectory: AppActions.openDirectory,showInFileManager: AppActions.showInFileManager,diff --git a/app/components/HelpFeedbackPanel.tsx b/app/components/HelpFeedbackPanel.tsxindex eacfcdbd5..e371c2489 100644--- a/app/components/HelpFeedbackPanel.tsx+++ b/app/components/HelpFeedbackPanel.tsx@@ -63,7 +63,6 @@ interface Props {classes?: any;theme?: any;openURLExternally: (url: string, skipConfirmation?: boolean) => void;- openFileNatively: (url: string) => void;toggleAboutDialog?: () => void;toggleKeysDialog: () => void;toggleOnboardingDialog: () => void;@@ -81,7 +80,6 @@ const HelpFeedbackPanel = (props: Props) => {const {classes,openURLExternally,- openFileNatively,toggleAboutDialog,toggleKeysDialog,toggleOnboardingDialog,@@ -303,7 +301,9 @@ const HelpFeedbackPanel = (props: Props) => {<Divider /><ListItembutton- onClick={() => openURLExternally(AppConfig.links.suggestFeature)}+ onClick={() =>+ openURLExternally(AppConfig.links.suggestFeature, true)+ }><ListItemIcon><NewFeatureIcon />@@ -314,7 +314,7 @@ const HelpFeedbackPanel = (props: Props) => {</ListItem><ListItembutton- onClick={() => openURLExternally(AppConfig.links.reportIssue)}+ onClick={() => openURLExternally(AppConfig.links.reportIssue, true)}><ListItemIcon><IssueIcon />@@ -325,7 +325,9 @@ const HelpFeedbackPanel = (props: Props) => {</ListItem><ListItembutton- onClick={() => openURLExternally(AppConfig.links.helpTranslating)}+ onClick={() =>+ openURLExternally(AppConfig.links.helpTranslating, true)+ }><ListItemIcon><TranslationIcon />@@ -337,7 +339,9 @@ const HelpFeedbackPanel = (props: Props) => {<Divider /><ListItembutton- onClick={() => openFileNatively(AppConfig.links.emailContact)}+ onClick={() =>+ openURLExternally(AppConfig.links.emailContact, true)+ }><ListItemIcon><EmailIcon />diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsxindex 1055a4cd1..440eb8507 100644--- a/app/components/LocationManager.tsx+++ b/app/components/LocationManager.tsx@@ -57,7 +57,6 @@ interface Props {perspectives: Array<Object>;hideDrawer: () => void;openURLExternally: (path: string) => void;- openFileNatively: (path: string) => void;toggleOpenLinkDialog: () => void;setDefaultLocations: () => void;addLocation: (location: Location, openAfterCreate?: boolean) => void;@@ -258,7 +257,6 @@ function mapDispatchToProps(dispatch) {addLocations: LocationActions.addLocations,editLocation: LocationActions.editLocation,removeLocation: LocationActions.removeLocation,- openFileNatively: AppActions.openFileNatively,toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,openURLExternally: AppActions.openURLExternally},diff --git a/app/components/MobileNavigation.tsx b/app/components/MobileNavigation.tsxindex 25893c1e2..4ba2a80b9 100644--- a/app/components/MobileNavigation.tsx+++ b/app/components/MobileNavigation.tsx@@ -99,7 +99,6 @@ interface Props {isHelpFeedbackPanelOpened: boolean;openHelpFeedbackPanel: () => void;closeAllVerticalPanels: () => void;- openFileNatively: (url: string) => void;openURLExternally: (url: string) => void;switchTheme: () => void;hideDrawer: () => void;@@ -129,7 +128,6 @@ const MobileNavigation = (props: Props) => {openHelpFeedbackPanel,showNotification,hideDrawer,- openFileNatively,openURLExternally,directoryPath,user@@ -152,7 +150,6 @@ const MobileNavigation = (props: Props) => {{/* {isPerspectivesPanelOpened && <PerspectiveManager />} */}{props.isHelpFeedbackPanelOpened && (<HelpFeedbackPanel- openFileNatively={openFileNatively}openURLExternally={openURLExternally}toggleAboutDialog={toggleAboutDialog}toggleKeysDialog={toggleKeysDialog}@@ -297,7 +294,6 @@ function mapActionCreatorsToProps(dispatch) {openSearchPanel: AppActions.openSearchPanel,openPerspectivesPanel: AppActions.openPerspectivesPanel,openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,- openFileNatively: AppActions.openFileNatively,openURLExternally: AppActions.openURLExternally,showNotification: AppActions.showNotification,closeAllVerticalPanels: AppActions.closeAllVerticalPanels,diff --git a/app/components/VerticalNavigation.tsx b/app/components/VerticalNavigation.tsxindex 9853e54a2..30f533967 100644--- a/app/components/VerticalNavigation.tsx+++ b/app/components/VerticalNavigation.tsx@@ -129,7 +129,6 @@ interface Props {isHelpFeedbackPanelOpened: boolean;openHelpFeedbackPanel: () => void;closeAllVerticalPanels: () => void;- openFileNatively: (url: string) => void;openURLExternally: (url: string) => void;switchTheme: () => void;showNotification: (message: string) => void;@@ -171,7 +170,6 @@ const VerticalNavigation = (props: Props) => {openHelpFeedbackPanel,closeAllVerticalPanels,switchTheme,- openFileNatively,openURLExternally,showNotification,directoryPath,@@ -395,7 +393,6 @@ const VerticalNavigation = (props: Props) => {{isSearchPanelOpened && <Search />}{isHelpFeedbackPanelOpened && (<HelpFeedbackPanel- openFileNatively={openFileNatively}openURLExternally={openURLExternally}toggleAboutDialog={toggleAboutDialog}toggleKeysDialog={toggleKeysDialog}@@ -465,7 +462,6 @@ function mapActionCreatorsToProps(dispatch) {openSearchPanel: AppActions.openSearchPanel,openPerspectivesPanel: AppActions.openPerspectivesPanel,openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,- openFileNatively: AppActions.openFileNatively,openURLExternally: AppActions.openURLExternally,closeAllVerticalPanels: AppActions.closeAllVerticalPanels,showNotification: AppActions.showNotification,diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsxindex b9c154e27..ceefc30d3 100644--- a/app/components/WelcomePanel.tsx+++ b/app/components/WelcomePanel.tsx@@ -79,19 +79,12 @@ interface Props {classes: any;toggleKeysDialog: () => void;openURLExternally: (url: string, skipConfirmation?: boolean) => void;- openFileNatively: (url: string) => void;toggleAboutDialog: () => void;isDesktopMode: boolean;}const WelcomePanel = (props: Props) => {- const {- classes,- openURLExternally,- openFileNatively,- toggleKeysDialog,- isDesktopMode- } = props;+ const { classes, openURLExternally, toggleKeysDialog, isDesktopMode } = props;return (<div className={classes.mainPanel}>{/* <div className={classes.slogan}>@@ -154,7 +147,9 @@ const WelcomePanel = (props: Props) => {<Divider /><ListItembutton- onClick={() => openURLExternally(AppConfig.links.suggestFeature)}+ onClick={() =>+ openURLExternally(AppConfig.links.suggestFeature, true)+ }><Button startIcon={<NewFeatureIcon />}>{i18n.t('core:suggestNewFeatures')}@@ -162,7 +157,7 @@ const WelcomePanel = (props: Props) => {</ListItem><ListItembutton- onClick={() => openURLExternally(AppConfig.links.reportIssue)}+ onClick={() => openURLExternally(AppConfig.links.reportIssue, true)}><Button startIcon={<IssueIcon />}>{i18n.t('core:reportIssues')}@@ -187,7 +182,7 @@ const WelcomePanel = (props: Props) => {</ListItem><ListItembutton- onClick={() => openFileNatively(AppConfig.links.twitter)}+ onClick={() => openURLExternally(AppConfig.links.twitter)}><Button startIcon={<Social2Icon />}>{i18n.t('core:followOnTwitter')}@@ -238,7 +233,6 @@ function mapActionCreatorsToProps(dispatch) {{setFirstRun: SettingsActions.setFirstRun,openURLExternally: AppActions.openURLExternally,- openFileNatively: AppActions.openFileNatively,toggleKeysDialog: AppActions.toggleKeysDialog,toggleAboutDialog: AppActions.toggleAboutDialog},diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex 5af923b4a..9bd8250be 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -191,8 +191,7 @@ interface Props {// setLastSelectedEntry: (path: string) => void; // needed by electron-menussetSelectedEntries: (selectedEntries: Array<Object>) => void; // needed by electron-menusopenFsEntry: (fsEntry: FileSystemEntry) => void; // needed by electron-menus- openFileNatively: (url: string) => void; // needed by electron-menus- openURLExternally: (url: string) => void;+ openURLExternally: (url: string, skipConfirm: boolean) => void;openNextFile: (path?: string) => void; // needed by electron-menusopenPrevFile: (path?: string) => void; // needed by electron-menusopenLocationManagerPanel: () => void;@@ -455,13 +454,13 @@ const MainPage = (props: Props) => {false);} else {- props.openFileNatively(AppConfig.links.downloadURL);+ props.openURLExternally(AppConfig.links.downloadURL, true);}props.setUpdateAvailable(false);};const openChangelogPage = () => {- props.openFileNatively(AppConfig.links.changelogURL);+ props.openURLExternally(AppConfig.links.changelogURL, true);};const handleFileDrop = (item, monitor) => {@@ -916,7 +915,6 @@ function mapDispatchToProps(dispatch) {setSelectedEntries: AppActions.setSelectedEntries,setGeneratingThumbnails: AppActions.setGeneratingThumbnails,openFsEntry: AppActions.openFsEntry,- openFileNatively: AppActions.openFileNatively,openURLExternally: AppActions.openURLExternally,setEntryFullWidth: AppActions.setEntryFullWidth,setUpdateAvailable: AppActions.setUpdateAvailable,diff --git a/app/services/platform-io.ts b/app/services/platform-io.tsindex fd7b2ec73..76dab7c31 100644--- a/app/services/platform-io.ts+++ b/app/services/platform-io.ts@@ -394,7 +394,17 @@ export default class PlatformIO {static showInFileManager = (dirPath: string): void =>nativeAPI.showInFileManager(dirPath);- static openFile = (filePath: string): void => nativeAPI.openFile(filePath);+ static openFile = (filePath: string): void => {+ if (+ confirm(+ 'Do you really want to open "' ++ filePath ++ '"? Execution of some files can be potentially dangerous!'+ )+ ) {+ nativeAPI.openFile(filePath);+ }+ };static resolveFilePath = (filePath: string): string =>objectStoreAPI ? filePath : nativeAPI.resolveFilePath(filePath);