TagSpaces is an offline, open source, document manager with tagging support
Add the location id to the currently edited file (#1797)
Stanimir5da80215f561
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 4d3a9a883..6d0a3d6a1 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -89,6 +89,7 @@ import useEventListener from '-/utils/useEventListener';import { TS } from '-/tagspaces.namespace';import FileView from '-/components/FileView';import { Pro } from '-/pro';+import { actions as LocationActions } from '-/reducers/locations';const defaultSplitSize = '7.86%'; // '7.2%'; // 103;// const openedSplitSize = AppConfig.isElectron ? 560 : 360;@@ -170,7 +171,7 @@ interface Props {updateOpenedFile: (entryPath: string,fsEntryMeta: any // FileSystemEntryMeta- ) => void;+ ) => Promise<boolean>;// reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;updateThumbnailUrl: (path: string, thumbUrl: string) => void;// setLastSelectedEntry: (path: string) => void;@@ -184,6 +185,8 @@ interface Props {isDesktopMode: boolean;tileServer: TS.MapTileServer;currentLocationId: string;+ switchLocationType: (locationId: string) => Promise<boolean>;+ switchCurrentLocationType: () => Promise<boolean>;}const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};@@ -436,49 +439,52 @@ function EntryContainer(props: Props) {// if (!this.state.currentEntry.isFile) {// textFilePath += '/index.html';// }- PlatformIO.loadTextFilePromise(- textFilePath,- data.preview ? data.preview : false- )- .then(content => {- const UTF8_BOM = '\ufeff';- if (content.indexOf(UTF8_BOM) === 0) {- // eslint-disable-next-line no-param-reassign- content = content.substr(1);- }- let fileDirectory = extractContainingDirectoryPath(- textFilePath,- PlatformIO.getDirSeparator()- );- if (AppConfig.isWeb) {- fileDirectory =- extractContainingDirectoryPath(- // eslint-disable-next-line no-restricted-globals- location.href,- PlatformIO.getDirSeparator()- ) +- '/' +- fileDirectory;- }- if (- fileViewer &&- fileViewer.current &&- fileViewer.current.contentWindow &&- // @ts-ignore- fileViewer.current.contentWindow.setContent- ) {- // @ts-ignore call setContent from iframe- fileViewer.current.contentWindow.setContent(- content,- fileDirectory,- !openedFile.editMode+ props.switchLocationType(openedFile.locationId).then(() => {+ PlatformIO.loadTextFilePromise(+ textFilePath,+ data.preview ? data.preview : false+ )+ .then(content => {+ const UTF8_BOM = '\ufeff';+ if (content.indexOf(UTF8_BOM) === 0) {+ // eslint-disable-next-line no-param-reassign+ content = content.substr(1);+ }+ let fileDirectory = extractContainingDirectoryPath(+ textFilePath,+ PlatformIO.getDirSeparator());- }- return true;- })- .catch(err => {- console.warn('Error loading text content ' + err);- });+ if (AppConfig.isWeb) {+ fileDirectory =+ extractContainingDirectoryPath(+ // eslint-disable-next-line no-restricted-globals+ location.href,+ PlatformIO.getDirSeparator()+ ) ++ '/' ++ fileDirectory;+ }+ if (+ fileViewer &&+ fileViewer.current &&+ fileViewer.current.contentWindow &&+ // @ts-ignore+ fileViewer.current.contentWindow.setContent+ ) {+ // @ts-ignore call setContent from iframe+ fileViewer.current.contentWindow.setContent(+ content,+ fileDirectory,+ !openedFile.editMode+ );+ }+ return props.switchCurrentLocationType();+ })+ .catch(err => {+ console.warn('Error loading text content ' + err);+ return props.switchCurrentLocationType();+ });+ });break;case 'contentChangedInEditor': {if (!fileChanged.current) {@@ -548,48 +554,55 @@ function EntryContainer(props: Props) {};const saveFile = (textContent: string) => {- PlatformIO.saveTextFilePromise(openedFile.path, textContent, true)- .then(result => {- // isChanged = false;- updateOpenedFile(openedFile.path, {- ...openedFile,- editMode: false,- // changed: false,- shouldReload: undefined- });- fileChanged.current = false;- showNotification(- i18n.t('core:fileSavedSuccessfully'),- NotificationTypes.default- );- if (Pro) {- Pro.history.saveHistory(- historyKeys.fileEditKey,- openedFile.path,- openedFile.url,- currentLocationId,- settings[historyKeys.fileEditKey]+ props.switchLocationType(openedFile.locationId).then(() => {+ PlatformIO.saveTextFilePromise(openedFile.path, textContent, true)+ .then(result => {+ // isChanged = false;+ updateOpenedFile(openedFile.path, {+ ...openedFile,+ editMode: false,+ // changed: false,+ shouldReload: undefined+ }).then(() => {+ props.switchCurrentLocationType();+ });+ fileChanged.current = false;+ showNotification(+ i18n.t('core:fileSavedSuccessfully'),+ NotificationTypes.default);- }- return result;- })- .catch(error => {- showNotification(- i18n.t('core:errorSavingFile'),- NotificationTypes.error- );- console.log('Error saving file ' + openedFile.path + ' - ' + error);- });+ if (Pro) {+ Pro.history.saveHistory(+ historyKeys.fileEditKey,+ openedFile.path,+ openedFile.url,+ currentLocationId,+ settings[historyKeys.fileEditKey]+ );+ }+ return result;+ })+ .catch(error => {+ showNotification(+ i18n.t('core:errorSavingFile'),+ NotificationTypes.error+ );+ console.log('Error saving file ' + openedFile.path + ' - ' + error);+ props.switchCurrentLocationType();+ });+ });};const editFile = () => {- updateOpenedFile(openedFile.path, {- ...openedFile,- editMode: true,- shouldReload: undefined+ props.switchLocationType(openedFile.locationId).then(() => {+ updateOpenedFile(openedFile.path, {+ ...openedFile,+ editMode: true,+ shouldReload: undefined+ }).then(() => {+ props.switchCurrentLocationType();+ });});-- // setFileView(renderFileView());};const shareFile = (filePath: string) => {@@ -1453,7 +1466,9 @@ function mapActionCreatorsToProps(dispatch) {removeAllTags: TaggingActions.removeAllTags,updateOpenedFile: AppActions.updateOpenedFile,updateThumbnailUrl: AppActions.updateThumbnailUrl,- setSelectedEntries: AppActions.setSelectedEntries+ setSelectedEntries: AppActions.setSelectedEntries,+ switchLocationType: LocationActions.switchLocationType,+ switchCurrentLocationType: AppActions.switchCurrentLocationType},dispatch);diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 7b6e15701..4036cbb03 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -16,13 +16,7 @@**/-import React, {- ChangeEvent,- useEffect,- useReducer,- useRef,- useState-} from 'react';+import React, { ChangeEvent, useEffect, useRef, useState } from 'react';import { useStateWithCallbackLazy } from 'use-state-with-callback';import { getBgndFileLocationForDirectory } from '@tagspaces/tagspaces-common/paths';import { v1 as uuidv1 } from 'uuid';@@ -102,6 +96,9 @@ import { connect } from 'react-redux';import FormHelperText from '@mui/material/FormHelperText';import { MilkdownRef } from '@tagspaces/tagspaces-md';import EditDescription from '-/components/EditDescription';+import { bindActionCreators } from 'redux';+import { actions as LocationActions } from '-/reducers/locations';+import { actions as AppActions } from '-/reducers/app';const ThumbnailChooserDialog =Pro && Pro.UI ? Pro.UI.ThumbnailChooserDialog : false;@@ -166,11 +163,13 @@ interface Props {renameFile: (path: string, nextPath: string) => Promise<boolean>;renameDirectory: (path: string, nextPath: string) => Promise<boolean>;showNotification: (message: string) => void;- updateOpenedFile: (entryPath: string, fsEntryMeta: any) => void;+ updateOpenedFile: (entryPath: string, fsEntryMeta: any) => Promise<boolean>;updateThumbnailUrl: (path: string, thumbUrl: string) => void;- addTags: (paths: Array<string>, tags: Array<TS.Tag>) => void;- removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => void;- removeAllTags: (paths: Array<string>) => void;+ addTags: (paths: Array<string>, tags: Array<TS.Tag>) => Promise<boolean>;+ removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => Promise<boolean>;+ removeAllTags: (paths: Array<string>) => Promise<boolean>;+ switchLocationType: (locationId: string) => Promise<boolean>;+ switchCurrentLocationType: () => Promise<boolean>;isReadOnlyMode: boolean;// currentDirectoryPath: string | null;tagDelimiter: string;@@ -276,19 +275,29 @@ function EntryProperties(props: Props) {);const nextPath = path + PlatformIO.getDirSeparator() + editName;- if (currentEntry.isFile) {- renameFile(currentEntry.path, nextPath)- .then(() => true)- .catch(() => {- fileNameRef.current.value = entryName;- });- } else {- renameDirectory(currentEntry.path, editName)- .then(() => true)- .catch(() => {- fileNameRef.current.value = entryName;- });- }+ props.switchLocationType(props.openedEntry.locationId).then(() => {+ if (currentEntry.isFile) {+ renameFile(currentEntry.path, nextPath)+ .then(() => {+ props.switchCurrentLocationType();+ return true;+ })+ .catch(() => {+ props.switchCurrentLocationType();+ fileNameRef.current.value = entryName;+ });+ } else {+ renameDirectory(currentEntry.path, editName)+ .then(() => {+ props.switchCurrentLocationType();+ return true;+ })+ .catch(() => {+ props.switchCurrentLocationType();+ fileNameRef.current.value = entryName;+ });+ }+ });setEditName(undefined);}@@ -324,20 +333,24 @@ function EntryProperties(props: Props) {return;}if (editDescription.current !== undefined) {- Pro.MetaOperations.saveDescription(- currentEntry.path,- editDescription.current- )- .then(entryMeta => {- editDescription.current = undefined;- props.updateOpenedFile(currentEntry.path, entryMeta);- return true;- })- .catch(error => {- console.warn('Error saving description ' + error);- editDescription.current = undefined;- props.showNotification(i18n.t('Error saving description'));- });+ props.switchLocationType(props.openedEntry.locationId).then(() => {+ Pro.MetaOperations.saveDescription(+ currentEntry.path,+ editDescription.current+ )+ .then(entryMeta => {+ editDescription.current = undefined;+ props.updateOpenedFile(currentEntry.path, entryMeta);+ props.switchCurrentLocationType();+ return true;+ })+ .catch(error => {+ console.warn('Error saving description ' + error);+ editDescription.current = undefined;+ props.switchCurrentLocationType();+ props.showNotification(i18n.t('Error saving description'));+ });+ });} else if (currentEntry.description) {editDescription.current = currentEntry.description;} else {@@ -379,29 +392,33 @@ function EntryProperties(props: Props) {const setThumb = (filePath, thumbFilePath) => {if (filePath !== undefined) {- if (- PlatformIO.haveObjectStoreSupport() ||- PlatformIO.haveWebDavSupport()- ) {- const thumbUrl = PlatformIO.getURLforPath(thumbFilePath);- props.updateThumbnailUrl(currentEntry.path, thumbUrl);- return Promise.resolve(true);- }- return replaceThumbnailURLPromise(filePath, thumbFilePath)- .then(objUrl => {- props.updateThumbnailUrl(- currentEntry.path,- objUrl.tmbPath +- (props.lastThumbnailImageChange- ? '?' + props.lastThumbnailImageChange- : '')- );+ props.switchLocationType(props.openedEntry.locationId).then(() => {+ if (+ PlatformIO.haveObjectStoreSupport() ||+ PlatformIO.haveWebDavSupport()+ ) {+ const thumbUrl = PlatformIO.getURLforPath(thumbFilePath);+ props.updateThumbnailUrl(currentEntry.path, thumbUrl);return true;- })- .catch(err => {- console.warn('Error replaceThumbnailURLPromise ' + err);- props.showNotification('Error replacing thumbnail');- });+ }+ return replaceThumbnailURLPromise(filePath, thumbFilePath)+ .then(objUrl => {+ props.updateThumbnailUrl(+ currentEntry.path,+ objUrl.tmbPath ++ (props.lastThumbnailImageChange+ ? '?' + props.lastThumbnailImageChange+ : '')+ );+ props.switchCurrentLocationType();+ return true;+ })+ .catch(err => {+ props.switchCurrentLocationType();+ console.warn('Error replaceThumbnailURLPromise ' + err);+ props.showNotification('Error replacing thumbnail');+ });+ });}// reset Thumbnailreturn getThumbnailURLPromise(currentEntry.path)@@ -435,19 +452,23 @@ function EntryProperties(props: Props) {// eslint-disable-next-line no-param-reassigncolor = 'transparent';}- Pro.MetaOperations.saveColor(currentEntry.path, color)- .then(entryMeta => {- // if (props.entryPath === props.currentDirectoryPath) {- props.updateOpenedFile(currentEntry.path, entryMeta);- /* } else {- setCurrentEntry({ ...currentEntry, color });- } */- return true;- })- .catch(error => {- console.warn('Error saving color for folder ' + error);- props.showNotification(i18n.t('Error saving color for folder'));- });+ props.switchLocationType(props.openedEntry.locationId).then(() => {+ Pro.MetaOperations.saveColor(currentEntry.path, color)+ .then(entryMeta => {+ // if (props.entryPath === props.currentDirectoryPath) {+ props.updateOpenedFile(currentEntry.path, entryMeta);+ props.switchCurrentLocationType();+ /* } else {+ setCurrentEntry({ ...currentEntry, color });+ } */+ return true;+ })+ .catch(error => {+ props.switchCurrentLocationType();+ console.warn('Error saving color for folder ' + error);+ props.showNotification(i18n.t('Error saving color for folder'));+ });+ });};const handleFileNameChange = (event: ChangeEvent<HTMLInputElement>) => {@@ -480,28 +501,40 @@ function EntryProperties(props: Props) {};*/const handleChange = (name: string, value: Array<TS.Tag>, action: string) => {- if (action === 'remove-value') {- if (!value) {- // no tags left in the select element- props.removeAllTags([currentEntry.path]); // TODO return promise- props.updateOpenedFile(currentEntry.path, { tags: [] });+ props.switchLocationType(props.openedEntry.locationId).then(() => {+ if (action === 'remove-value') {+ if (!value) {+ // no tags left in the select element+ props.removeAllTags([currentEntry.path]).then(() => {+ props.updateOpenedFile(currentEntry.path, { tags: [] }).then(() => {+ props.switchCurrentLocationType();+ });+ });+ } else {+ props.removeTags([currentEntry.path], value).then(() => {+ props.switchCurrentLocationType();+ });+ }+ } else if (action === 'clear') {+ props.removeAllTags([currentEntry.path]).then(() => {+ props.switchCurrentLocationType();+ });} else {- props.removeTags([currentEntry.path], value);+ // create-option or select-option+ const promises = value.map(tag => {+ if (+ currentEntry.tags === undefined ||+ currentEntry.tags.findIndex(obj => obj.title === tag.title) === -1+ ) {+ return props.addTags([currentEntry.path], [tag]);+ }+ return Promise.resolve(false);+ });+ Promise.all(promises).then(() => {+ props.switchCurrentLocationType();+ });}- } else if (action === 'clear') {- props.removeAllTags([currentEntry.path]);- } else {- // create-option or select-option- value.map(tag => {- if (- currentEntry.tags === undefined ||- currentEntry.tags.findIndex(obj => obj.title === tag.title) === -1- ) {- props.addTags([currentEntry.path], [tag]);- }- return true;- });- }+ });};const { classes, isReadOnlyMode, theme, sharingLink } = props;@@ -1339,11 +1372,25 @@ function mapStateToProps(state) {};}+function mapActionCreatorsToProps(dispatch) {+ return bindActionCreators(+ {+ switchLocationType: LocationActions.switchLocationType,+ switchCurrentLocationType: AppActions.switchCurrentLocationType+ },+ dispatch+ );+}+const areEqual = (prevProp: Props, nextProp: Props) =>JSON.stringify(nextProp.openedEntry) === JSON.stringify(prevProp.openedEntry);export default withLeaflet(- connect(mapStateToProps)(+ connect(+ mapStateToProps,+ mapActionCreatorsToProps+ )(+ // @ts-ignoreReact.memo(withStyles(styles, { withTheme: true })(EntryProperties),areEqualdiff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 056002717..b29302714 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -52,8 +52,8 @@ import {getNextFile,getPrevFile,loadJSONFile,- merge-} from '-/services/utils-io';+ merge, setLocationType+} from "-/services/utils-io";import i18n from '../services/i18n';import { Pro } from '../pro';import { actions as LocationIndexActions } from './location-index';@@ -146,6 +146,7 @@ export type OpenedEntry = {url?: string;size: number;lmdt: number;+ locationId: string;viewingExtensionPath: string;viewingExtensionId: string;editingExtensionPath?: string;@@ -1667,6 +1668,32 @@ export const actions = {dispatch(actions.setCurrentLocationId(location.uuid));}},+ switchLocationType: (location: TS.Location) => (+ dispatch: (action) => void,+ getState: () => any+ ): Promise<boolean> => {+ const { currentLocationId } = getState().app;+ if (location.uuid !== currentLocationId) {+ const currentLocation: TS.Location = getLocation(+ getState(),+ getState().app.currentLocationId+ );+ if (location.type !== currentLocation.type) {+ return setLocationType(location);+ }+ }+ return Promise.resolve(false);+ },+ switchCurrentLocationType: () => (+ dispatch: (action) => void,+ getState: () => any+ ): Promise<boolean> => {+ const location: TS.Location = getLocation(+ getState(),+ getState().app.currentLocationId+ );+ return setLocationType(location);+ },openLocationById: (locationId: string) => (dispatch: (action) => void,getState: () => any@@ -1843,10 +1870,10 @@ export const actions = {entryPath: string,fsEntryMeta: any // FileSystemEntryMeta,// isFile: boolean = true- ) => (dispatch: (action) => void, getState: () => any) => {+ ) => (dispatch: (action) => void, getState: () => any): Promise<boolean> => {const { openedFiles } = getState().app;if (openedFiles && openedFiles.length > 0) {- PlatformIO.getPropertiesPromise(entryPath)+ return PlatformIO.getPropertiesPromise(entryPath).then(entryProps => {if (entryProps) {const { supportedFileTypes } = getState().settings;@@ -1893,8 +1920,10 @@ export const actions = {}).catch(err => {console.error('updateOpenedFile ' + entryPath + ' not exist ' + err);+ return Promise.resolve(false);});}+ return Promise.resolve(false);},openEntry: (path: string) => (dispatch: (action) => void) => {return getAllPropertiesPromise(path)@@ -1986,10 +2015,12 @@ export const actions = {if (fsEntry.isNewFile) {entryForOpening.editMode = true;}+const currentLocation: TS.Location = getLocation(getState(),getState().app.currentLocationId);+ entryForOpening.locationId = currentLocation.uuid;const { currentDirectoryPath } = getState().app;updateHistory(currentLocation, currentDirectoryPath, fsEntry.path);diff --git a/app/reducers/locations.ts b/app/reducers/locations.tsindex c504fb944..25e4db9bc 100644--- a/app/reducers/locations.ts+++ b/app/reducers/locations.ts@@ -244,6 +244,18 @@ export const actions = {dispatch(AppActions.setReadOnlyMode(location.isReadOnly || false));}},+ switchLocationType: (locationId: string) => (+ dispatch: (actions) => Promise<boolean>,+ getState: () => any+ ): Promise<boolean> => {+ const { locations } = getState();+ const location: TS.Location = locations.find(+ location => location.uuid === locationId+ );+ if (location) {+ return dispatch(AppActions.switchLocationType(location));+ }+ },changeLocation: (location: TS.Location) => ({type: types.EDIT_LOCATION,locationdiff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.tsindex 6264549fd..bffc9b578 100644--- a/app/reducers/tagging-actions.ts+++ b/app/reducers/tagging-actions.ts@@ -61,7 +61,7 @@ const actions = {addTags: (paths: Array<string>, tags: Array<TS.Tag>, updateIndex = true) => (dispatch: (action) => void,getState: () => any- ) => {+ ): Promise<boolean> => {const { settings, taglibrary } = getState();let defaultTagLocation;if (settings.geoTaggingFormat.toLowerCase() === 'mgrs') {@@ -120,10 +120,9 @@ const actions = {});if (processedTags.length > 0) {- paths.map(path => {- dispatch(actions.addTagsToEntry(path, processedTags, updateIndex));- return true;- });+ const promises = paths.map(path =>+ dispatch(actions.addTagsToEntry(path, processedTags, updateIndex))+ );if (settings.addTagsToLibrary) {// collecting tags@@ -160,13 +159,18 @@ const actions = {dispatch(TagLibraryActions.mergeTagGroup(tagGroup));}}+ return Promise.all(promises).then(() => true);}+ return Promise.resolve(false);},addTagsToEntry: (path: string,tags: Array<TS.Tag>,updateIndex = true- ) => async (dispatch: (actions: Object) => void, getState: () => any) => {+ ) => async (+ dispatch: (actions: Object) => Promise<boolean>,+ getState: () => any+ ): Promise<boolean> => {const { settings } = getState();const entryProperties = await PlatformIO.getPropertiesPromise(path);let fsEntryMeta;@@ -196,7 +200,7 @@ const actions = {...fsEntryMeta,tags: newTags};- saveMetaDataPromise(path, updatedFsEntryMeta)+ return saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {dispatch(// TODO rethink this updateCurrentDirEntry and not need for KanBan@@ -204,7 +208,7 @@ const actions = {);const { openedFiles } = getState().app;if (openedFiles.find(obj => obj.path === path)) {- dispatch(+ return dispatch(AppActions.updateOpenedFile(path, {tags: newTags})@@ -221,11 +225,12 @@ const actions = {true));+ return false;});}} else {const newFsEntryMeta = { tags };- saveMetaDataPromise(path, newFsEntryMeta)+ return saveMetaDataPromise(path, newFsEntryMeta).then(() => {dispatch(// TODO rethink this updateCurrentDirEntry and not need for KanBan@@ -233,7 +238,7 @@ const actions = {);const { openedFiles } = getState().app;if (openedFiles.find(obj => obj.path === path)) {- dispatch(+ return dispatch(AppActions.updateOpenedFile(path, { tags, changed: true }));}@@ -248,6 +253,7 @@ const actions = {true));+ return true;});}} else if (fsEntryMeta) {@@ -277,7 +283,7 @@ const actions = {? containingDirectoryPath + PlatformIO.getDirSeparator(): '') +generateFileName(fileName, extractedTags, settings.tagDelimiter);- dispatch(AppActions.renameFile(path, newFilePath));+ return dispatch(AppActions.renameFile(path, newFilePath));}} else {// Handling tags in filename by no sidecar@@ -304,9 +310,10 @@ const actions = {: '') +generateFileName(fileName, extractedTags, settings.tagDelimiter);if (path !== newFilePath) {- dispatch(AppActions.renameFile(path, newFilePath));+ return dispatch(AppActions.renameFile(path, newFilePath));}}+ return Promise.resolve(false);function getNonExistingTags(newTagsArray: Array<TS.Tag>,@@ -535,33 +542,33 @@ const actions = {}},removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => (- dispatch: (actions: Object) => void- ) => {- paths.map(path => {- dispatch(actions.removeTagsFromEntry(path, tags));- return true;- });+ dispatch: (actions: Object) => Promise<boolean>+ ): Promise<boolean> => {+ const promises: Array<Promise<boolean>> = paths.map(path =>+ dispatch(actions.removeTagsFromEntry(path, tags))+ );+ return Promise.all(promises).then(() => true);},removeTagsFromEntry: (path: string, tags: Array<TS.Tag>) => (dispatch: (actions: Object) => void,getState: () => any- ) => {+ ): Promise<boolean> => {const { settings } = getState();const tagTitlesForRemoving = tags.map(tag => tag.title);- loadMetaDataPromise(path)+ return loadMetaDataPromise(path).then((fsEntryMeta: TS.FileSystemEntryMeta) => {const newTags = fsEntryMeta.tags.filter(sidecarTag => !tagTitlesForRemoving.includes(sidecarTag.title));- removeTagsFromFilename(fsEntryMeta.isFile).then(newFilePath => {+ return removeTagsFromFilename(fsEntryMeta.isFile).then(newFilePath => {// no file rename - only sidecar tags removedif (newFilePath === path) {const updatedFsEntryMeta = {...fsEntryMeta,tags: newTags};- saveMetaDataPromise(path, updatedFsEntryMeta)+ return saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {dispatch(AppActions.reflectUpdateSidecarTags(newFilePath, newTags)@@ -579,6 +586,7 @@ const actions = {true));+ return false;});}// dispatch(AppActions.reflectEditedEntryPaths([newFilePath]));@@ -591,12 +599,11 @@ const actions = {);}});- return true;}).catch(error => {console.warn('Error removing tags for ' + path + ' with ' + error);// dispatch(AppActions.showNotification(i18n.t('core:removingSidecarTagsFailed'), 'error', true));- removeTagsFromFilename();+ return removeTagsFromFilename().then(() => true);});/**@@ -645,17 +652,13 @@ const actions = {},removeAllTags: (paths: Array<string>) => async (dispatch: (action) => Promise<boolean>- ) => {+ ): Promise<boolean> => {+ const promises = [];for (const path of paths) {- // eslint-disable-next-line no-await-in-loop- const resultMeta = await dispatch(- actions.removeAllTagsFromMetaData(path)- );- // eslint-disable-next-line no-await-in-loop- const resultName = await dispatch(- actions.removeAllTagsFromFilename(path)- );+ promises.push(dispatch(actions.removeAllTagsFromMetaData(path)));+ promises.push(dispatch(actions.removeAllTagsFromFilename(path)));}+ return Promise.all(promises).then(() => true);},removeAllTagsFromFilename: (path: string) => (dispatch: (action) => Promise<boolean>,diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 7dac179d8..2e74ba6d5 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -385,6 +385,7 @@ export function findExtensionsForEntry(viewingExtensionId: '',isFile,// changed: false,+ locationId: undefined,lmdt: 0,size: 0};@@ -1364,3 +1365,18 @@ export function getBgndPath((lastBackgroundImageChange ? '?' + lastBackgroundImageChange : ''));}++export function setLocationType(location: TS.Location): Promise<boolean> {+ if (location) {+ if (location.type === locationType.TYPE_CLOUD) {+ return PlatformIO.enableObjectStoreSupport(location);+ } else if (location.type === locationType.TYPE_WEBDAV) {+ PlatformIO.enableWebdavSupport(location);+ } else if (location.type === locationType.TYPE_LOCAL) {+ PlatformIO.disableObjectStoreSupport();+ PlatformIO.disableWebdavSupport();+ }+ return Promise.resolve(true);+ }+ return Promise.resolve(false);+}