TagSpaces is an offline, open source, document manager with tagging support
add enable/disable WS settings (#1554)
Stanimir3a6716a0fe95
diff --git a/app/components/dialogs/settings/SettingsAdvanced.tsx b/app/components/dialogs/settings/SettingsAdvanced.tsxindex 0962004d3..df7f9e946 100644--- a/app/components/dialogs/settings/SettingsAdvanced.tsx+++ b/app/components/dialogs/settings/SettingsAdvanced.tsx@@ -37,7 +37,8 @@ import i18n from '-/services/i18n';import {actions as SettingsActions,getSettings,- getMapTileServers+ getMapTileServers,+ getEnableWS} from '-/reducers/settings';import { TS } from '-/tagspaces.namespace';import MapTileServerDialog from '-/components/dialogs/settings/MapTileServerDialog';@@ -67,6 +68,7 @@ interface Props {classes: any;settings: any;setDesktopMode: (desktopMode: boolean) => void;+ setEnableWS: (enableWS: boolean) => void;setWarningOpeningFilesExternally: (warningOpeningFilesExternally: boolean) => void;@@ -125,6 +127,14 @@ const SettingsAdvanced = (props: Props) => {checked={!props.settings.desktopMode}/></ListItem>+ <ListItem className={classes.listItem}>+ <ListItemText primary={i18n.t('enableWS')} />+ <Switch+ data-tid="settingsEnableWS"+ onClick={() => props.setEnableWS(!props.settings.enableWS)}+ checked={props.settings.enableWS}+ />+ </ListItem><ListItem className={classes.listItem}><ListItemText primary={i18n.t('warningOpeningFilesExternally')} /><Switch@@ -258,7 +268,8 @@ const SettingsAdvanced = (props: Props) => {function mapStateToProps(state) {return {settings: getSettings(state),- tileServers: getMapTileServers(state)+ tileServers: getMapTileServers(state),+ enableWS: getEnableWS(state)};}@@ -268,6 +279,7 @@ function mapActionCreatorsToProps(dispatch) {setWarningOpeningFilesExternally:SettingsActions.setWarningOpeningFilesExternally,setDesktopMode: SettingsActions.setDesktopMode,+ setEnableWS: SettingsActions.setEnableWS,setSaveTagInLocation: SettingsActions.setSaveTagInLocation,setGeoTaggingFormat: SettingsActions.setGeoTaggingFormat},diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 1f5d07a7e..2cc7a981f 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -289,6 +289,7 @@"moreOperations": "More Operations","options": "Options","desktopMode": "Desktop mode",+ "enableWS": "Enable Web Service","locationManager": "Location Manager","chooseLocation": "Open Location","colorPickerDialogTitle": "Choose color",diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex 87c5f4506..dcee6798b 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -190,12 +190,14 @@ export const actions = {isCurrentLocation: boolean = true,locationID: string = undefined,ignorePatterns: Array<string> = []- ) => (dispatch: (actions: Object) => void) => {+ ) => (dispatch: (actions: Object) => void, getState: () => any) => {+ const { settings } = getState();dispatch(actions.startDirectoryIndexing());createDirectoryIndex({ path: directoryPath, locationID },extractText,- ignorePatterns+ ignorePatterns,+ settings.enableWS).then(directoryIndex => {if (isCurrentLocation) {@@ -266,7 +268,8 @@ export const actions = {createDirectoryIndex({ path: nextPath, location: location.uuid },extractText,- location.ignorePatternPaths+ location.ignorePatternPaths,+ state.settings.enableWS)/* .then(directoryIndex => {if (Pro && Pro.Indexer) {@@ -396,7 +399,8 @@ export const actions = {...(isCloudLocation && { bucketName: currentLocation.bucketName })},currentLocation.fullTextIndex,- currentLocation.ignorePatternPaths+ currentLocation.ignorePatternPaths,+ state.settings.enableWS);if (GlobalSearch.index && GlobalSearch.index.length > 0) {@@ -489,8 +493,7 @@ export const actions = {// cancel search if max search result count reachedif (searchResultCount >= searchQuery.maxSearchResults) {maxSearchResultReached = true;- Promise.resolve();- return true;+ return Promise.resolve();}const nextPath = getLocationPath(location);let directoryIndex = [];@@ -526,7 +529,8 @@ export const actions = {...(isCloudLocation && { bucketName: location.bucketName })},location.fullTextIndex,- location.ignorePatternPaths+ location.ignorePatternPaths,+ state.settings.enableWS);/* if (Pro && Pro.Indexer && Pro.Indexer.persistIndex) {Pro.Indexer.persistIndex(diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.tsindex 0ad42e023..ac3214082 100644--- a/app/reducers/settings-default.ts+++ b/app/reducers/settings-default.ts@@ -130,6 +130,7 @@ export default {contentHash: '',isUpdateInProgress: false,isUpdateAvailable: false,+ enableWS: true,warningOpeningFilesExternally: true,tagDelimiter: ' ',maxSearchResult: 1000,diff --git a/app/reducers/settings.ts b/app/reducers/settings.tsindex f993b45d4..d8c6737c3 100644--- a/app/reducers/settings.ts+++ b/app/reducers/settings.ts@@ -33,6 +33,7 @@ export const types = {SET_LANGUAGE: 'SETTINGS/SET_LANGUAGE',TOGGLE_SHOWUNIXHIDDENENTRIES: 'SETTINGS/TOGGLE_SHOWUNIXHIDDENENTRIES',SET_DESKTOPMODE: 'SETTINGS/SET_DESKTOPMODE',+ SET_ENABLE_WS: 'SETTINGS/SET_ENABLE_WS',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',@@ -144,6 +145,9 @@ export default (state: any = defaultSettings, action: any) => {case types.SET_DESKTOPMODE: {return { ...state, desktopMode: action.desktopMode };}+ case types.SET_ENABLE_WS: {+ return { ...state, enableWS: action.enableWS };+ }case types.WARNING_OPENING_FILES_EXTERNALLY: {return {...state,@@ -432,6 +436,10 @@ export const actions = {type: types.SET_DESKTOPMODE,desktopMode}),+ setEnableWS: (enableWS: boolean) => ({+ type: types.SET_ENABLE_WS,+ enableWS+ }),setWarningOpeningFilesExternally: (warningOpeningFilesExternally: boolean) => ({@@ -635,6 +643,7 @@ export const getMapTileServer = (state: any): TS.MapTileServer =>export const getMapTileServers = (state: any): Array<TS.MapTileServer> =>AppConfig.mapTileServers || state.settings.mapTileServers;export const getSettings = (state: any) => state.settings;+export const getEnableWS = (state: any) => state.settings.enableWS;export const getDesktopMode = (state: any) => {if (typeof window.ExtDisplayMode === 'undefined') {return state.settings.desktopMode;diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 68a4d5895..77916bed4 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -79,12 +79,13 @@ export function enhanceDirectoryContent(showUnixHiddenEntries,useGenerateThumbnails,showDirs = true,- limit = undefined+ limit = undefined,+ enableWS = true) {const directoryContent = [];const tmbGenerationPromises = [];const tmbGenerationList = [];- const isWorkerAvailable = PlatformIO.isWorkerAvailable();+ const isWorkerAvailable = enableWS && PlatformIO.isWorkerAvailable();dirEntries.map(entry => {if (!showUnixHiddenEntries && entry.name.startsWith('.')) {@@ -264,7 +265,10 @@ export function prepareDirectoryContent(dirEntries,isCloudLocation,settings.showUnixHiddenEntries,- generateThumbnails && useGenerateThumbnails()+ generateThumbnails && useGenerateThumbnails(),+ true,+ undefined,+ settings.enableWS);function handleTmbGenerationResults(results) {@@ -476,8 +480,9 @@ function persistIndex(param: string | any, directoryIndex: any) {export function createDirectoryIndex(param: string | any,extractText: boolean = false,- ignorePatterns: Array<string> = []- // disableIndexing = true+ ignorePatterns: Array<string> = [],+ enableWS = true+ // disableIndexing = true,): Promise<Array<TS.FileSystemEntry>> {let directoryPath;let locationID;@@ -488,7 +493,11 @@ export function createDirectoryIndex(directoryPath = param;}const dirPath = cleanTrailingDirSeparator(directoryPath);- if (PlatformIO.isWorkerAvailable() && !PlatformIO.haveObjectStoreSupport()) {+ if (+ enableWS &&+ PlatformIO.isWorkerAvailable() &&+ !PlatformIO.haveObjectStoreSupport()+ ) {// Start indexing in worker if not in the object store modereturn PlatformIO.createDirectoryIndexInWorker(dirPath,