Skip to content

TagSpaces is an offline, open source, document manager with tagging support

TSN720 option for disabling the warning on opening external files added (#1495)

Stanimir351acadcf27e
diff --git a/app/components/dialogs/settings/SettingsAdvanced.tsx b/app/components/dialogs/settings/SettingsAdvanced.tsx
index e73760fb2..2e54c870f 100644
--- a/app/components/dialogs/settings/SettingsAdvanced.tsx
+++ b/app/components/dialogs/settings/SettingsAdvanced.tsx
@@ -63,6 +63,9 @@ interface Props {
classes: any;
settings: any;
setDesktopMode: (desktopMode: boolean) => void;
+ setWarningOpeningFilesExternally: (
+ warningOpeningFilesExternally: boolean
+ ) => void;
setSaveTagInLocation: (saveTagInLocation: boolean) => void;
showResetSettings: (showDialog: boolean) => void;
tileServers: Array<TS.MapTileServer>;
@@ -115,6 +118,18 @@ const SettingsAdvanced = (props: Props) => {
checked={!props.settings.desktopMode}
/>
</ListItem>
+ <ListItem className={classes.listItem}>
+ <ListItemText primary={i18n.t('warningOpeningFilesExternally')} />
+ <Switch
+ data-tid="warningOpeningFilesExternally"
+ onClick={() =>
+ props.setWarningOpeningFilesExternally(
+ !props.settings.warningOpeningFilesExternally
+ )
+ }
+ checked={props.settings.warningOpeningFilesExternally}
+ />
+ </ListItem>
<ListItem className={classes.listItem}>
<ListItemText
primary={
@@ -216,6 +231,8 @@ function mapStateToProps(state) {
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
+ setWarningOpeningFilesExternally:
+ SettingsActions.setWarningOpeningFilesExternally,
setDesktopMode: SettingsActions.setDesktopMode,
setSaveTagInLocation: SettingsActions.setSaveTagInLocation
},
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 0c7f5ca07..41557d318 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -614,5 +614,6 @@
"searchTypeSemiStrictTooltip": "Exact search in file path, description and text content (by enabled full-text search)",
"searchTypeStrict": "Strict",
"searchTypeStrictTooltip": "Same as semi-strict but case sensitive",
+ "warningOpeningFilesExternally": "Show warning on opening files externally",
"-": "-"
}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index b4c6518cf..dfde2f6ae 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -1907,12 +1907,14 @@ export const actions = {
return;
}
if (fsEntry.isFile) {
- PlatformIO.openFile(fsEntry.path);
+ const { warningOpeningFilesExternally } = getState().settings;
+ PlatformIO.openFile(fsEntry.path, warningOpeningFilesExternally);
} else {
PlatformIO.openDirectory(fsEntry.path);
}
} else {
- PlatformIO.openFile(selectedFile);
+ const { warningOpeningFilesExternally } = getState().settings;
+ PlatformIO.openFile(selectedFile, warningOpeningFilesExternally);
}
},
openLink: (url: string) => (
diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.ts
index d34eaaa83..4e961faed 100644
--- a/app/reducers/settings-default.ts
+++ b/app/reducers/settings-default.ts
@@ -126,6 +126,7 @@ export default {
contentHash: '',
isUpdateInProgress: false,
isUpdateAvailable: false,
+ warningOpeningFilesExternally: true,
tagDelimiter: ' ',
maxSearchResult: 1000,
desktopMode,
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 7e53f23ff..d0ac8df78 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -32,6 +32,7 @@ export const types = {
SET_LANGUAGE: 'SETTINGS/SET_LANGUAGE',
TOGGLE_SHOWUNIXHIDDENENTRIES: 'SETTINGS/TOGGLE_SHOWUNIXHIDDENENTRIES',
SET_DESKTOPMODE: 'SETTINGS/SET_DESKTOPMODE',
+ WARNING_OPENING_FILES_EXTERNALLY: 'SETTINGS/WARNING_OPENING_FILES_EXTERNALLY',
SET_SAVE_TAGS_IN_LOCATION: 'SETTINGS/SET_SAVE_TAGS_IN_LOCATION',
SET_TAG_DELIMITER: 'SETTINGS/SET_TAG_DELIMITER',
SET_MAX_SEARCH_RESULT: 'SETTINGS/SET_MAX_SEARCH_RESULT',
@@ -124,6 +125,12 @@ export default (state: any = defaultSettings, action: any) => {
case types.SET_DESKTOPMODE: {
return { ...state, desktopMode: action.desktopMode };
}
+ case types.WARNING_OPENING_FILES_EXTERNALLY: {
+ return {
+ ...state,
+ warningOpeningFilesExternally: action.warningOpeningFilesExternally
+ };
+ }
case types.SET_SAVE_TAGS_IN_LOCATION: {
return { ...state, saveTagInLocation: action.saveTagInLocation };
}
@@ -406,6 +413,12 @@ export const actions = {
type: types.SET_DESKTOPMODE,
desktopMode
}),
+ setWarningOpeningFilesExternally: (
+ warningOpeningFilesExternally: boolean
+ ) => ({
+ type: types.WARNING_OPENING_FILES_EXTERNALLY,
+ warningOpeningFilesExternally
+ }),
setSaveTagInLocation: (saveTagInLocation: boolean) => ({
type: types.SET_SAVE_TAGS_IN_LOCATION,
saveTagInLocation
@@ -589,6 +602,8 @@ export const getDesktopMode = (state: any) => {
}
return window.ExtDisplayMode !== 'mobile';
};
+export const getWarningOpeningFilesExternally = (state: any) =>
+ state.settings.warningOpeningFilesExternally;
export const getCheckForUpdateOnStartup = (state: any) =>
state.settings.checkForUpdates;
export const getLastPublishedVersion = (state: any) =>
diff --git a/app/services/platform-io.ts b/app/services/platform-io.ts
index 581054def..7117ef6f6 100644
--- a/app/services/platform-io.ts
+++ b/app/services/platform-io.ts
@@ -23,6 +23,7 @@ import NativePlatformIO from './_PLATFORMIO_';
import ObjectStoreIO from './objectstore-io';
import AppConfig from '-/config';
import { TS } from '-/tagspaces.namespace';
+import settings from '-/reducers/settings';
const nativeAPI: any = new NativePlatformIO();
let objectStoreAPI;
@@ -414,8 +415,12 @@ export default class PlatformIO {
static showInFileManager = (dirPath: string): void =>
nativeAPI.showInFileManager(dirPath);
- static openFile = (filePath: string): void => {
+ static openFile = (
+ filePath: string,
+ warningOpeningFilesExternally: boolean
+ ): void => {
if (
+ !warningOpeningFilesExternally ||
confirm(
'Do you really want to open "' +
filePath +