TagSpaces is an offline, open source, document manager with tagging support
Tsn474 optimizations in the entry properties (#1215)
Stanimir912a900f4989
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex a72e08d7b..a1023a9ea 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -23,7 +23,6 @@ import { GlobalHotKeys } from 'react-hotkeys';import Button from '@material-ui/core/Button';import Fab from '@material-ui/core/Fab';import IconButton from '@material-ui/core/IconButton';-import uuidv1 from 'uuid';import SaveIcon from '@material-ui/icons/Save';import CloseIcon from '@material-ui/icons/Close';import BackIcon from '@material-ui/icons/RemoveRedEye';@@ -45,7 +44,7 @@ import ConfirmDialog from '-/components/dialogs/ConfirmDialog';import AppConfig from '-/config';import PlatformIO from '-/services/platform-io';import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';-import { FileSystemEntry, FileSystemEntryMeta } from '-/services/utils-io';+import { FileSystemEntry } from '-/services/utils-io';import i18n from '-/services/i18n';import {extractContainingDirectoryPath,@@ -177,7 +176,7 @@ interface Props {addTags: () => void;removeTags: () => void;// editTagForEntry: () => void;- openFile: (filePath: string) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;getNextFile: (path: string) => string;getPrevFile: (path: string) => string;openFileNatively: (path: string) => void;@@ -195,14 +194,13 @@ interface Props {entryPropertiesSplitSize?: number;updateOpenedFile: (entryPath: string,- fsEntryMeta: FileSystemEntryMeta,- isFile: boolean+ fsEntryMeta: any // FileSystemEntryMeta) => void;// reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;updateThumbnailUrl: (path: string, thumbUrl: string) => void;setLastSelectedEntry: (path: string) => void;setSelectedEntries: (selectedEntries: Array<Object>) => void;- directoryContent: Array<Object>;+ directoryContent: Array<FileSystemEntry>;currentDirectoryPath: string | null;}@@ -211,7 +209,7 @@ const EntryContainer = (props: Props) => {return null;}const openedFile = props.openedFiles[0];- const [currentEntry, setCurrentEntry] = useState<OpenedEntry>(openedFile);+ // const [currentEntry, setCurrentEntry] = useState<OpenedEntry>(openedFile);const [isPropertiesPanelVisible, setPropertiesPanelVisible] = useState<boolean@@ -274,18 +272,14 @@ const EntryContainer = (props: Props) => {openedFile.editingExtensionId &&openedFile.editingExtensionId.length > 3);+ if (+ openedFile.editMode &&+ openedFile.changed &&+ openedFile.shouldReload === false+ ) {+ setSaveBeforeReloadConfirmDialogOpened(true);+ }}-- // set tags- /* const tags = extractTagsAsObjects(- openedFile.path,- props.settings.tagDelimiter,- PlatformIO.getDirSeparator()- );- setCurrentEntry({- ...openedFile,- tags- }); */}}, [props.openedFiles, props.isReadOnlyMode, props.settings]);@@ -331,12 +325,12 @@ const EntryContainer = (props: Props) => {break;case 'playbackEnded':nextFilePath = props.getNextFile(openedFile.path);- nextFile = props.directoryContent.filter(+ nextFile = props.directoryContent.find((dirEntry: any) => dirEntry.path === nextFilePath);- props.openFile(nextFilePath);+ props.openFsEntry(nextFile);props.setLastSelectedEntry(nextFilePath);- props.setSelectedEntries(nextFile);+ props.setSelectedEntries([nextFile]);break;case 'openLinkExternally':// console.log('Open link externally: ' + data.link);@@ -400,7 +394,7 @@ const EntryContainer = (props: Props) => {fileViewer.current.contentWindow.setContent(content,fileDirectory,- !currentEntry.editMode+ !openedFile.editMode);}return true;@@ -410,12 +404,13 @@ const EntryContainer = (props: Props) => {});break;case 'contentChangedInEditor': {- if (currentEntry.editMode && !currentEntry.changed) {+ if (openedFile.editMode && !openedFile.changed) {// dummy state change to render DOT before file name (only first time)- setCurrentEntry({+ props.updateOpenedFile(openedFile.path, {...openedFile,changed: true,- editMode: true+ editMode: true,+ shouldReload: undefined});}break;@@ -429,12 +424,11 @@ const EntryContainer = (props: Props) => {};const reloadDocument = () => {- if (currentEntry) {- if (currentEntry.changed) {+ if (openedFile) {+ if (openedFile.changed) {setSaveBeforeReloadConfirmDialogOpened(true);} else {- // shouldReload = true;- setCurrentEntry({+ props.updateOpenedFile(openedFile.path, {...openedFile,editMode: false,shouldReload: true@@ -462,7 +456,7 @@ const EntryContainer = (props: Props) => {event.preventDefault(); // Let's stop this event.event.stopPropagation();}- if (currentEntry && currentEntry.changed) {+ if (openedFile && openedFile.changed && openedFile.editMode) {setSaveBeforeCloseConfirmDialogOpened(true);} else {closeFile();@@ -501,11 +495,11 @@ const EntryContainer = (props: Props) => {PlatformIO.saveTextFilePromise(openedFile.path, textContent, true).then(result => {// isChanged = false;- setCurrentEntry({+ props.updateOpenedFile(openedFile.path, {...openedFile,editMode: false,changed: false,- shouldReload: false+ shouldReload: undefined});props.showNotification(i18n.t('core:fileSavedSuccessfully'),@@ -523,7 +517,10 @@ const EntryContainer = (props: Props) => {};const editFile = () => {- setCurrentEntry({ ...openedFile, editMode: true });+ props.updateOpenedFile(openedFile.path, {+ ...openedFile,+ editMode: true+ });};const shareFile = (filePath: string) => {@@ -609,24 +606,24 @@ const EntryContainer = (props: Props) => {const openNextFile = () => {if (openedFile.path) {const nextFilePath = props.getNextFile(openedFile.path);- const nextFile = props.directoryContent.filter(+ const nextFile = props.directoryContent.find((dirEntry: FileSystemEntry) => dirEntry.path === nextFilePath);- props.openFile(nextFilePath);+ props.openFsEntry(nextFile);props.setLastSelectedEntry(nextFilePath);- props.setSelectedEntries(nextFile);+ props.setSelectedEntries([nextFile]);}};const openPrevFile = () => {if (openedFile.path) {const prevFilePath = props.getPrevFile(openedFile.path);- const prevFile = props.directoryContent.filter(+ const prevFile = props.directoryContent.find((dirEntry: FileSystemEntry) => dirEntry.path === prevFilePath);- props.openFile(prevFilePath);+ props.openFsEntry(prevFile);props.setLastSelectedEntry(prevFilePath);- props.setSelectedEntries(prevFile);+ props.setSelectedEntries([prevFile]);}};@@ -910,15 +907,15 @@ const EntryContainer = (props: Props) => {// fileTitle = fileTitle.substr(0, maxCharactersTitleLength) + '...';// }- if (currentEntry.editMode && currentEntry.editingExtensionPath) {+ if (openedFile.editMode && openedFile.editingExtensionPath) {fileOpenerURL =- currentEntry.editingExtensionPath ++ openedFile.editingExtensionPath +'/index.html?file=' +encodeURIComponent(openedFile.url ? openedFile.url : openedFile.path) +'&locale=' +i18n.language +'&edit=true' +- (currentEntry.shouldReload ? '&t=' + new Date().getTime() : '');+ (openedFile.shouldReload === true ? '&t=' + new Date().getTime() : '');// } else if (!currentEntry.isFile) { // TODO needed for loading folder's default html// fileOpenerURL = 'node_modules/@tagspaces/html-viewer/index.html?locale=' + i18n.language;} else {@@ -928,7 +925,7 @@ const EntryContainer = (props: Props) => {encodeURIComponent(openedFile.url ? openedFile.url : openedFile.path) +'&locale=' +i18n.language +- (currentEntry.shouldReload ? '&t=' + new Date().getTime() : '');+ (openedFile.shouldReload === true ? '&t=' + new Date().getTime() : '');}// this.shouldReload = false;@@ -1011,7 +1008,7 @@ const EntryContainer = (props: Props) => {// isChanged = false;// shouldReload = true;setSaveBeforeReloadConfirmDialogOpened(false);- setCurrentEntry({+ props.updateOpenedFile(openedFile.path, {...openedFile,editMode: false,changed: false,@@ -1109,7 +1106,7 @@ const EntryContainer = (props: Props) => {PlatformIO.getDirSeparator())}</div>- {currentEntry.changed+ {openedFile.editMode && openedFile.changed? String.fromCharCode(0x25cf) + ' ': ''}{fileTitle}@@ -1136,7 +1133,7 @@ const EntryContainer = (props: Props) => {</Button>)}</div>- {editingSupported && currentEntry.editMode && (+ {editingSupported && openedFile.editMode && (<div className={classes.entryCloseSection}><IconButtondisabled={false}@@ -1164,7 +1161,7 @@ const EntryContainer = (props: Props) => {</IconButton></div>)}- {editingSupported && !currentEntry.editMode && (+ {editingSupported && !openedFile.editMode && (<div className={classes.entryCloseSection}><Buttondisabled={false}@@ -1206,13 +1203,14 @@ const EntryContainer = (props: Props) => {? renderFileToolbar(classes): renderFolderToolbar()}<EntryProperties- key={uuidv1()}+ key={openedFile.path}// resetState={this.resetState}// setPropertiesEditMode={this.setPropertiesEditMode}- entryPath={openedFile.path}- perspective={openedFile.perspective}+ // entryPath={openedFile.path}+ // perspective={openedFile.perspective}+ openedEntry={openedFile}+ tagDelimiter={props.settings.tagDelimiter}// entryURL={currentEntry.url}- // openedEntry={openEntry}// shouldReload={reload}renameFile={props.renameFile}renameDirectory={props.renameDirectory}@@ -1271,7 +1269,7 @@ function mapActionCreatorsToProps(dispatch) {closeAllFiles: AppActions.closeAllFiles,renameFile: AppActions.renameFile,renameDirectory: AppActions.renameDirectory,- openFile: AppActions.openFile,+ openFsEntry: AppActions.openFsEntry,openFileNatively: AppActions.openFileNatively,openURLExternally: AppActions.openURLExternally,showNotification: AppActions.showNotification,diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex e8ddd7b0d..92137b770 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -52,20 +52,16 @@ import {} from 'react-leaflet';import OpenLocationCode from 'open-location-code-typescript';import TagDropContainer from './TagDropContainer';-// import EntryTagMenu from './menus/EntryTagMenu';import ColorPickerDialog from './dialogs/ColorPickerDialog';import MoveCopyFilesDialog from './dialogs/MoveCopyFilesDialog';import i18n from '../services/i18n';-import {- FileSystemEntry,- FileSystemEntryMeta,- getAllPropertiesPromise-} from '-/services/utils-io';+import { enhanceOpenedEntry, FileSystemEntryMeta } from '-/services/utils-io';import { formatFileSize, isPlusCode } from '-/utils/misc';import {extractContainingDirectoryPath,getThumbFileLocationForFile,- getThumbFileLocationForDirectory+ getThumbFileLocationForDirectory,+ extractFileName} from '-/utils/paths';import AppConfig from '../config';import { Pro } from '../pro';@@ -77,7 +73,7 @@ import {getThumbnailURLPromise} from '-/services/thumbsgenerator';import { Tag } from '-/reducers/taglibrary';-import { perspectives } from '-/reducers/app';+import { OpenedEntry, perspectives } from '-/reducers/app';import { savePerspective } from '-/utils/metaoperations';import MarkerIcon from '-/assets/icons/marker-icon.png';import Marker2xIcon from '-/assets/icons/marker-icon-2x.png';@@ -91,14 +87,13 @@ const styles: any = (theme: any) => ({overflowY: AppConfig.isFirefox ? 'auto' : 'overlay',overflowX: 'hidden',flexGrow: 1,- // padding: 10,+ padding: 7,height: '100%'},tags: {padding: '5px 5px 2px 2px',margin: 6,clear: 'both',- // border: '1px dashed rgba(0,0,0,0.75)',boxShadow: '0 1px 1px 0 rgba(0,0,0,0.16),0 1px 1px 0 rgba(239,239,239,0.12)'},editTagsButton: {@@ -178,7 +173,6 @@ marked.setOptions({gfm: true,tables: true,breaks: false,- sanitize: true,smartLists: true,smartypants: false,xhtml: true@@ -187,42 +181,39 @@ marked.setOptions({interface Props {classes: any;theme: any;- // openedEntry: OpenedEntry;- entryPath: string;- perspective: string;- // entryURL: string;- // shouldReload: boolean | null;- // shouldCopyFile: boolean;- // editTagForEntry: () => void;+ openedEntry: OpenedEntry;renameFile: (path: string, nextPath: string) => void;renameDirectory: (path: string, nextPath: string) => void;- // normalizeShouldCopyFile: () => void;showNotification: (message: string) => void;- updateOpenedFile: (- entryPath: string,- fsEntryMeta: FileSystemEntryMeta,- isFile: boolean- ) => void;- // reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;+ updateOpenedFile: (entryPath: string, fsEntryMeta: any) => void;updateThumbnailUrl: (path: string, thumbUrl: string) => void;addTags: (paths: Array<string>, tags: Array<Tag>) => void;removeTags: (paths: Array<string>, tags: Array<Tag>) => void;removeAllTags: (paths: Array<string>) => void;- // resetState: (stateName: string) => void;isReadOnlyMode: boolean;- // setPropertiesEditMode: (editMode: boolean) => void;currentDirectoryPath: string | null;+ tagDelimiter: string;}const EntryProperties = (props: Props) => {- const fileName = useRef<HTMLInputElement>(null);- const fileDescription = useRef<HTMLInputElement>(null);+ // const EntryProperties = React.memo((props: Props) => {+ const fileNameRef = useRef<HTMLInputElement>(null);+ const fileDescriptionRef = useRef<HTMLInputElement>(null);const MB_ATTR ='<b>Leaflet</b> | Map data © <b>https://openstreetmap.org/copyright</b> contributors, <b>CC-BY-SA</b>, Imagery © <b>Mapbox</b>';- let newName = '';+ const fileName = extractFileName(+ props.openedEntry.path,+ PlatformIO.getDirSeparator()+ );++ const currentEntry = enhanceOpenedEntry(+ props.openedEntry,+ props.tagDelimiter+ );+// const tagMenuAnchorEl = null;- // const [name, setName] = useState<string>('');+ // const [thumbPath, setThumbPath] = useState<string>(undefined);// const [originalName, setOriginalName] = useState<string>('');// const [description, setDescription] = useState<string>('');// const [size, setSize] = useState<number>(0);@@ -230,12 +221,12 @@ const EntryProperties = (props: Props) => {// const [path, setPath] = useState<string>('');// const [ldtm, setLdtm] = useState<string>('');// const [tags, setTags] = useState<Array<Tag>>([]);- const [currentEntry, setCurrentEntry] = useState<FileSystemEntry>(undefined);+ // const [currentEntry, setCurrentEntry] = useState<FileSystemEntry>(undefined);// const [tagMenuAnchorEl, setTagMenuAnchorEl] = useState<boolean | null>(null);// const [tagMenuOpened, setTagMenuOpened] = useState<boolean | null>(false);// const [selectedTag, setSelectedTag] = useState<Tag>(null); // TODO enable selected Tag menu- const [isEditName, setEditName] = useState<boolean>(false);- const [isEditDescription, setEditDescription] = useState<boolean>(false);+ const [editName, setEditName] = useState<string>(undefined);+ const [editDescription, setEditDescription] = useState<string>(undefined);const [isMoveCopyFilesDialogOpened, setMoveCopyFilesDialogOpened] = useState<boolean>(false);@@ -244,137 +235,71 @@ const EntryProperties = (props: Props) => {setFileThumbChooseDialogOpened] = useState<boolean>(false);const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);- // const [thumbPath, setThumbPath] = useState<string>('');useEffect(() => {- if (props.entryPath) {- loadEntryProperties(props.entryPath);- }- }, [props.entryPath]);-- /* useEffect(() => { // Rethink and move this Dialog in EntryContainer- if (props.shouldCopyFile) {- setMoveCopyFilesDialogOpened(true);- }- }, [props.shouldCopyFile]); */-- /* componentDidMount() {- this.loadEntryProperties(this.props.entryPath);- }-- componentWillReceiveProps(nextProps: Props) {if (- (nextProps.entryPath && nextProps.shouldReload) ||- (nextProps.entryPath && this.state.path !== nextProps.entryPath)- /!* (nextProps.openedFiles.length > 0 &&- nextProps.openedFiles[0].shouldReload) *!/ // TODO rethink this and not reload all Properties at general !!+ editDescription === currentEntry.description &&+ fileDescriptionRef.current) {- // eslint-disable-next-line react/destructuring-assignment- // this.props.resetState('EntryPropertiesKey'); TODO rethink this- this.loadEntryProperties(nextProps.entryPath);- }-- if (nextProps.shouldCopyFile) {- this.setState({ isMoveCopyFilesDialogOpened: true });+ fileDescriptionRef.current.focus();+ fileDescriptionRef.current.setSelectionRange(+ fileDescriptionRef.current.value.length,+ fileDescriptionRef.current.value.length+ );}- } */+ }, [editDescription]);- const loadEntryProperties = (entryPath: string) => {- getAllPropertiesPromise(entryPath)- .then((entryProps: FileSystemEntry) => {- setCurrentEntry(entryProps);- /* this.setState({- isEditName: false,- name: entryProps.name,- path: entryProps.path,- size: entryProps.size,- tags: entryProps.tags,- // @ts-ignore- ldtm: entryProps.lmdt- ? new Date(entryProps.lmdt)- .toISOString()- .substring(0, 19)- .split('T')- .join(' ')- : '',- color: entryProps.color,- isFile: entryProps.isFile,- description: entryProps.description ? entryProps.description : ''- }); */- return true;- })- .catch(error =>- console.warn(- 'Error getting properties for entry: ' + entryPath + ' - ' + error- )+ useEffect(() => {+ if (editName === fileName && fileNameRef.current) {+ fileNameRef.current.focus();+ fileNameRef.current.setSelectionRange(+ fileNameRef.current.value.length,+ fileNameRef.current.value.length);- };+ }+ }, [editName]);const renameEntry = () => {- if (isEditName) {+ if (editName !== undefined) {const { renameFile, renameDirectory } = props;const path = extractContainingDirectoryPath(currentEntry.path,PlatformIO.getDirSeparator());- const nextPath = path + PlatformIO.getDirSeparator() + newName;+ const nextPath = path + PlatformIO.getDirSeparator() + editName;if (currentEntry.isFile) {renameFile(currentEntry.path, nextPath);} else {- renameDirectory(currentEntry.path, newName);+ renameDirectory(currentEntry.path, editName);}- newName = '';- setEditName(false);+ // newName = '';+ setEditName(undefined);}};const toggleEditNameField = () => {if (props.isReadOnlyMode) {- setEditName(false);+ setEditName(undefined);return;}- if (isEditName) {- setEditName(false);+ if (editName !== undefined) {+ setEditName(undefined);/* this.setState({isEditName: false,name: this.state.originalName}); */} else {- setEditName(true);- newName = currentEntry.name;- /* this.setState(- {- isEditName: true,- originalName: this.state.name- },- () => {- fileName.focus();- // this.props.setPropertiesEditMode(true);- const { originalName } = this.state;- if (originalName) {- const indexOfBracket = originalName.indexOf(- AppConfig.beginTagContainer- );- const indexOfDot = originalName.indexOf('.');- let endRange = originalName.length;- if (indexOfBracket > 0) {- endRange = indexOfBracket;- } else if (indexOfDot > 0) {- endRange = indexOfDot;- }- fileName.setSelectionRange(0, endRange);- }- }- ); */+ setEditName(fileName);+ // newName = fileName; // currentEntry.name;}};const toggleEditDescriptionField = () => {if (props.isReadOnlyMode) {- setEditDescription(false);+ setEditDescription(undefined);return;}if (!Pro) {@@ -385,49 +310,30 @@ const EntryProperties = (props: Props) => {props.showNotification(i18n.t('Saving description not supported'));return;}- if (isEditDescription) {- Pro.MetaOperations.saveDescription(- currentEntry.path,- currentEntry.description- )+ if (editDescription !== undefined) {+ Pro.MetaOperations.saveDescription(currentEntry.path, editDescription).then(entryMeta => {- setEditDescription(false);- props.updateOpenedFile(- currentEntry.path,- entryMeta,- currentEntry.isFile- );+ setEditDescription(undefined);+ props.updateOpenedFile(currentEntry.path, {+ ...entryMeta,+ changed: true+ });return true;}).catch(error => {console.warn('Error saving description ' + error);- setEditDescription(false);+ setEditDescription(undefined);props.showNotification(i18n.t('Error saving description'));});+ } else if (currentEntry.description) {+ setEditDescription(currentEntry.description);} else {- setEditDescription(true);- /* this.setState(- {- isEditDescription: true- },- () => {- // this.props.setPropertiesEditMode(true);- if (fileDescription) { //TODO- fileDescription.focus();- }- }- ); */+ setEditDescription('');}};const toggleMoveCopyFilesDialog = () => {setMoveCopyFilesDialogOpened(!isMoveCopyFilesDialogOpened);- /* this.setState(- ({ isMoveCopyFilesDialogOpened }) => ({- isMoveCopyFilesDialogOpened: !isMoveCopyFilesDialogOpened- }),- () => this.props.normalizeShouldCopyFile()- ); */};const toggleThumbFilesDialog = () => {@@ -435,20 +341,24 @@ const EntryProperties = (props: Props) => {props.showNotification(i18n.t('core:needProVersion'));return true;}- setFileThumbChooseDialogOpened(!isFileThumbChooseDialogOpened);- /* this.setState(({ isFileThumbChooseDialogOpened }) => ({- isFileThumbChooseDialogOpened: !isFileThumbChooseDialogOpened- })); */+ if (+ !currentEntry.editMode &&+ editName === undefined &&+ editDescription === undefined+ ) {+ setFileThumbChooseDialogOpened(!isFileThumbChooseDialogOpened);+ }};const setThumb = (filePath, thumbFilePath) => {if (filePath !== undefined) {return replaceThumbnailURLPromise(filePath, thumbFilePath).then(objUrl => {- setCurrentEntry({+ // setThumbPath(objUrl.tmbPath);+ /* setCurrentEntry({...currentEntry,thumbPath: objUrl.tmbPath- });+ }); */props.updateThumbnailUrl(currentEntry.path, objUrl.tmbPath);return true;})@@ -460,10 +370,11 @@ const EntryProperties = (props: Props) => {// reset Thumbnailreturn getThumbnailURLPromise(currentEntry.path).then(objUrl => {- setCurrentEntry({+ // setThumbPath(objUrl.tmbPath);+ /* setCurrentEntry({...currentEntry,thumbPath: objUrl.tmbPath- });+ }); */props.updateThumbnailUrl(currentEntry.path, objUrl.tmbPath);return true;})@@ -492,11 +403,10 @@ const EntryProperties = (props: Props) => {Pro.MetaOperations.saveColor(currentEntry.path, color).then(entryMeta => {// if (props.entryPath === props.currentDirectoryPath) {- props.updateOpenedFile(- currentEntry.path,- entryMeta,- currentEntry.isFile- );+ props.updateOpenedFile(currentEntry.path, {+ ...entryMeta,+ changed: true+ });/* } else {setCurrentEntry({ ...currentEntry, color });} */@@ -527,7 +437,8 @@ const EntryProperties = (props: Props) => {const { value, name } = target;if (name === 'name') {- newName = value;+ setEditName(value);+ // newName = value;/* setCurrentEntry({...currentEntry,name: value@@ -541,58 +452,55 @@ const EntryProperties = (props: Props) => {const { value, name } = target;if (name === 'description') {- setCurrentEntry({+ setEditDescription(value);+ // newDescription = value;+ /* setCurrentEntry({...currentEntry,description: value- });+ }); */// this.setState({ description: value });}};- const handleChange = (name: string, value: any, action: string) => {+ const handleChange = (name: string, value: Array<Tag>, action: string) => {if (action === 'remove-value') {if (!value) {// no tags left in the select elementprops.removeAllTags([currentEntry.path]); // TODO return promise- setCurrentEntry({- ...currentEntry,- tags: []- });- // this.setState({ tags: [] });+ props.updateOpenedFile(currentEntry.path, { tags: [], changed: true });} else {- const tagsToRemove = [];- const newTags = currentEntry.tags.map(tag => {- if (value.findIndex(obj => obj.title === tag.title) === -1) {- tagsToRemove.push(tag);- return undefined;- }- return tag;- });+ /* const newTags = currentEntry.tags.filter(+ tag => value.findIndex(obj => obj.title === tag.title) === -1+ ); */- props.removeTags([currentEntry.path], tagsToRemove);- setCurrentEntry({- ...currentEntry,- tags: newTags.filter(tag => tag !== undefined)- });+ props.removeTags([currentEntry.path], value);+ /* props.updateOpenedFile(+ currentEntry.path,+ { tags: newTags },+ currentEntry.isFile+ ); */}} else if (action === 'clear') {props.removeAllTags([currentEntry.path]);- setCurrentEntry({- ...currentEntry,- tags: []- });+ /* props.updateOpenedFile(+ currentEntry.path,+ { tags: [] },+ currentEntry.isFile+ ); */} else {// create-option or select-optionvalue.map(tag => {if (+ currentEntry.tags === undefined ||currentEntry.tags.findIndex(obj => obj.title === tag.title) === -1) {props.addTags([currentEntry.path], [tag]);- setCurrentEntry({- ...currentEntry,- tags: [...currentEntry.tags, tag]- });- // this.setState({ tags: [...tags, tag] });++ /* props.updateOpenedFile(+ currentEntry.path,+ { tags: [...(currentEntry.tags ? currentEntry.tags : []), tag] },+ currentEntry.isFile+ ); */}return true;});@@ -605,19 +513,17 @@ const EntryProperties = (props: Props) => {return <div />;}- let { thumbPath } = currentEntry;- if (!thumbPath) {- if (currentEntry.isFile) {- thumbPath = getThumbFileLocationForFile(- currentEntry.path,- PlatformIO.getDirSeparator()- );- } else {- thumbPath = getThumbFileLocationForDirectory(- currentEntry.path,- PlatformIO.getDirSeparator()- );- }+ let thumbPath; // { thumbPath } = currentEntry;+ if (currentEntry.isFile) {+ thumbPath = getThumbFileLocationForFile(+ currentEntry.path,+ PlatformIO.getDirSeparator()+ );+ } else {+ thumbPath = getThumbFileLocationForDirectory(+ currentEntry.path,+ PlatformIO.getDirSeparator()+ );}const thumbPathUrl = thumbPath? 'url("' + thumbPath + '?' + new Date().getTime() + '")'@@ -635,19 +541,13 @@ const EntryProperties = (props: Props) => {: '';const changePerspective = (event: any) => {- // console.log(perspective);const perspective = event.target.value;savePerspective(currentEntry.path, perspective).then((entryMeta: FileSystemEntryMeta) => {- // if (props.entryPath === props.currentDirectoryPath) {- props.updateOpenedFile(- currentEntry.path,- entryMeta,- currentEntry.isFile- );- /* } else {- setCurrentEntry({ ...currentEntry, perspective });- } */+ props.updateOpenedFile(currentEntry.path, {+ ...entryMeta,+ changed: true+ });return true;}).catch(error => {@@ -659,8 +559,8 @@ const EntryProperties = (props: Props) => {let perspectiveDefault;if (currentEntry.perspective) {perspectiveDefault = currentEntry.perspective;- } else if (props.perspective) {- perspectiveDefault = props.perspective;+ } else if (currentEntry.perspective) {+ perspectiveDefault = currentEntry.perspective; // props.perspective;} else {perspectiveDefault = 'unspecified'; // perspectives.DEFAULT;}@@ -714,12 +614,14 @@ const EntryProperties = (props: Props) => {});function getGeoLocation(tags: Array<Tag>) {- for (let i = 0; i < tags.length; i += 1) {- if (isPlusCode(tags[i].title)) {- const coord = OpenLocationCode.decode(tags[i].title);- const lat = Number(coord.latitudeCenter.toFixed(7));- const lng = Number(coord.longitudeCenter.toFixed(7));- return { lat, lng };+ if (tags) {+ for (let i = 0; i < tags.length; i += 1) {+ if (isPlusCode(tags[i].title)) {+ const coord = OpenLocationCode.decode(tags[i].title);+ const lat = Number(coord.latitudeCenter.toFixed(7));+ const lng = Number(coord.longitudeCenter.toFixed(7));+ return { lat, lng };+ }}}return undefined;@@ -741,52 +643,59 @@ const EntryProperties = (props: Props) => {{i18n.t('core:editTagMasterName')}</Typography></div>- {!isReadOnlyMode && (- <div className={classes.gridItem} style={{ textAlign: 'right' }}>- {isEditName ? (- <div>+ {!isReadOnlyMode &&+ !currentEntry.editMode &&+ editDescription === undefined && (+ <div+ className={classes.gridItem}+ style={{ textAlign: 'right' }}+ >+ {editName !== undefined ? (+ <div>+ <Button+ color="primary"+ className={classes.button}+ onClick={toggleEditNameField}+ >+ {i18n.t('core:cancel')}+ </Button>+ <Button+ color="primary"+ className={classes.button}+ onClick={renameEntry}+ >+ {i18n.t('core:confirmSaveButton')}+ </Button>+ </div>+ ) : (<Buttoncolor="primary"className={classes.button}onClick={toggleEditNameField}>- {i18n.t('core:cancel')}+ {i18n.t('core:rename')}</Button>- <Button- color="primary"- disabled={isEditDescription}- className={classes.button}- onClick={renameEntry}- >- {i18n.t('core:confirmSaveButton')}- </Button>- </div>- ) : (- <Button- color="primary"- disabled={isEditDescription}- className={classes.button}- onClick={toggleEditNameField}- >- {i18n.t('core:rename')}- </Button>- )}- </div>- )}+ )}+ </div>+ )}</div><FormControl fullWidth={true} className={classes.formControl}><TextFieldInputProps={{- readOnly: !isEditName+ readOnly: editName === undefined}}margin="dense"name="name"fullWidth={true}data-tid="fileNameProperties"- defaultValue={currentEntry.name}- inputRef={fileName}+ defaultValue={fileName} // currentEntry.name}+ inputRef={fileNameRef}onClick={() => {- if (!isEditName) {+ if (+ !currentEntry.editMode &&+ editName === undefined &&+ editDescription === undefined+ ) {toggleEditNameField();}}}@@ -816,9 +725,16 @@ const EntryProperties = (props: Props) => {<TagDropContainer entryPath={currentEntry.path}><TagsSelectplaceholderText={i18n.t('core:dropHere')}- isReadOnlyMode={isReadOnlyMode}+ isReadOnlyMode={+ isReadOnlyMode ||+ currentEntry.editMode ||+ editDescription !== undefined ||+ editName !== undefined+ }tags={currentEntry.tags}+ tagMode="default"handleChange={handleChange}+ selectedEntryPath={currentEntry.path}/></TagDropContainer></div>@@ -828,21 +744,14 @@ const EntryProperties = (props: Props) => {<Grid item xs={12}><Maptap={true}- style={{ height: '200px', width: '100%' }}+ style={{ height: '200px', width: '100%', margin: 3 }}animate={false}doubleClickZoom={true}keyboard={false}dragging={true}- // onDblclick={this.updatePosition}center={geoLocation}zoom={13}scrollWheelZoom={false}- // position={this.state.position}- // onClick={updatePosition}- // onViewportChanged={this.onViewportChanged}- // onLocationfound={this.handleLocationFound}- // viewport={this.state.viewport}- // bounds={this.state.bounds}zoomControl={true}attributionControl={false}>@@ -880,35 +789,39 @@ const EntryProperties = (props: Props) => {{i18n.t('core:filePropertiesDescription')}</Typography></div>- {!isReadOnlyMode && (- <div className={classes.gridItem} style={{ textAlign: 'right' }}>- {isEditDescription && (+ {!isReadOnlyMode &&+ !currentEntry.editMode &&+ editName === undefined && (+ <div+ className={classes.gridItem}+ style={{ textAlign: 'right' }}+ >+ {editDescription !== undefined && (+ <Button+ color="primary"+ className={classes.button}+ onClick={() => setEditDescription(undefined)}+ >+ {i18n.t('core:cancel')}+ </Button>+ )}<Buttoncolor="primary"className={classes.button}onClick={toggleEditDescriptionField}>- {i18n.t('core:cancel')}+ {editDescription !== undefined+ ? i18n.t('core:confirmSaveButton')+ : i18n.t('core:edit')}</Button>- )}- <Button- color="primary"- disabled={isEditName}- className={classes.button}- onClick={toggleEditDescriptionField}- >- {isEditDescription- ? i18n.t('core:confirmSaveButton')- : i18n.t('core:edit')}- </Button>- </div>- )}+ </div>+ )}</div><FormControl fullWidth={true} className={classes.formControl}>- {isEditDescription ? (+ {editDescription !== undefined ? (<TextFieldmultiline- inputRef={fileDescription}+ inputRef={fileDescriptionRef}style={{padding: 10,borderRadius: 5,@@ -918,7 +831,7 @@ const EntryProperties = (props: Props) => {placeholder=""name="description"className={styles.textField}- value={currentEntry.description}+ defaultValue={currentEntry.description}fullWidth={true}onChange={handleDescriptionChange}/>@@ -946,7 +859,7 @@ const EntryProperties = (props: Props) => {: i18n.t('core:addDescription')}}onClick={() => {- if (!isEditDescription) {+ if (!currentEntry.editMode && editName === undefined) {toggleEditDescriptionField();}}}@@ -970,18 +883,6 @@ const EntryProperties = (props: Props) => {<br /><strong>{ldtm}</strong></Typography>- {/* <FormControl fullWidth={true} className={classes.formControl}>- <TextField- InputProps={{- readOnly: true- }}- margin="dense"- name="ldtm"- fullWidth={true}- data-tid="fileLdtmProperties"- value={ldtm}- />- </FormControl> */}</div>{currentEntry.isFile ? (@@ -995,22 +896,6 @@ const EntryProperties = (props: Props) => {<br /><strong>{formatFileSize(currentEntry.size)}</strong></Typography>- {/* <FormControl- fullWidth={true}- className={classes.formControl}- title={size + ' bytes'}- >- <TextField- margin="dense"- name="size"- InputProps={{- readOnly: true- }}- fullWidth={true}- data-tid="fileSizeProperties"- value={formatFileSize(size)}- />- </FormControl> */}</div>) : (<div className={classes.gridItem} style={{ width: '50%' }}>@@ -1081,16 +966,19 @@ const EntryProperties = (props: Props) => {{i18n.t('core:filePath')}</Typography></div>- {currentEntry.isFile && !isReadOnlyMode && (- <Button- color="primary"- disabled={isEditDescription || isEditName}- className={classes.button}- onClick={toggleMoveCopyFilesDialog}- >- {i18n.t('core:move')}- </Button>- )}+ {currentEntry.isFile &&+ !isReadOnlyMode &&+ !currentEntry.editMode &&+ editName === undefined &&+ editDescription === undefined && (+ <Button+ color="primary"+ className={classes.button}+ onClick={toggleMoveCopyFilesDialog}+ >+ {i18n.t('core:move')}+ </Button>+ )}</div><FormControl fullWidth={true} className={classes.formControl}><TextField@@ -1165,15 +1053,18 @@ const EntryProperties = (props: Props) => {{i18n.t('core:thumbnail')}</Typography></div>- {!isReadOnlyMode && (- <Button- color="primary"- className={classes.button}- onClick={toggleThumbFilesDialog}- >- {i18n.t('core:changeThumbnail')}- </Button>- )}+ {!isReadOnlyMode &&+ !currentEntry.editMode &&+ editName === undefined &&+ editDescription === undefined && (+ <Button+ color="primary"+ className={classes.button}+ onClick={toggleThumbFilesDialog}+ >+ {i18n.t('core:changeThumbnail')}+ </Button>+ )}</div><div className={classes.fluidGrid}><div className={classes.gridItem}>diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex 28a931bc3..3f5a7eaba 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -51,7 +51,11 @@ import PlatformIO from '../services/platform-io';import LoadingLazy from '../components/LoadingLazy';import { Pro } from '../pro';import { savePerspective } from '-/utils/metaoperations';-import { FileSystemEntryMeta } from '-/services/utils-io';+import {+ enhanceOpenedEntry,+ FileSystemEntry,+ FileSystemEntryMeta+} from '-/services/utils-io';const GridPerspective = React.lazy(() =>import(@@ -189,6 +193,7 @@ const styles: any = (theme: any) => ({interface Props {classes: any;+ settings: any;theme: any;windowHeight: number;windowWidth: number;@@ -205,7 +210,7 @@ interface Props {renameFile: () => void;openDirectory: () => void;showInFileManager: () => void;- openFile: (path: string) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;deleteDirectory: (path: string) => void;reflectCreateEntry: (path: string, isFile: boolean) => void;loadDirectoryContent: (path: string) => void;@@ -246,9 +251,12 @@ const FolderContainer = (props: Props) => {if (openedFile.perspective) {props.setCurrentDirectoryPerspective(openedFile.perspective);}- } else {- // TODO check if file is loaded- props.updateCurrentDirEntry(openedFile.path, openedFile);+ } else if (openedFile.changed) {+ const currentEntry = enhanceOpenedEntry(+ openedFile,+ props.settings.tagDelimiter+ );+ props.updateCurrentDirEntry(openedFile.path, currentEntry);}}}, [props.openedFiles]);@@ -338,6 +346,7 @@ const FolderContainer = (props: Props) => {return (<GalleryPerspectiveAsyncdirectoryContent={props.directoryContent}+ openFsEntry={props.openFsEntry}currentDirectoryPath={props.currentDirectoryPath}windowWidth={props.windowWidth}switchPerspective={switchPerspective}@@ -381,7 +390,7 @@ const FolderContainer = (props: Props) => {<KanBanPerspectiveAsyncdirectoryContent={props.directoryContent}loadDirectoryContent={props.loadDirectoryContent}- openFile={props.openFile}+ openFsEntry={props.openFsEntry}loadParentDirectoryContent={props.loadParentDirectoryContent}deleteFile={props.deleteFile}renameFile={props.renameFile}@@ -404,7 +413,7 @@ const FolderContainer = (props: Props) => {<GridPerspectiveAsyncdirectoryContent={props.directoryContent}loadDirectoryContent={props.loadDirectoryContent}- openFile={props.openFile}+ openFsEntry={props.openFsEntry}loadParentDirectoryContent={props.loadParentDirectoryContent}deleteFile={props.deleteFile}renameFile={props.renameFile}@@ -535,7 +544,7 @@ const FolderContainer = (props: Props) => {loadDirectoryContent={props.loadDirectoryContent}openDirectory={props.openDirectory}reflectCreateEntry={props.reflectCreateEntry}- openFile={props.openFile}+ openFsEntry={props.openFsEntry}toggleCreateFileDialog={props.toggleCreateFileDialog}deleteDirectory={props.deleteDirectory}switchPerspective={switchPerspective}@@ -559,6 +568,7 @@ const FolderContainer = (props: Props) => {function mapStateToProps(state) {return {+ settings: state.settings,lastSelectedEntry: getLastSelectedEntry(state),perspectives: getPerspectives(state),directoryContent: getDirectoryContent(state),@@ -586,7 +596,7 @@ function mapActionCreatorsToProps(dispatch) {getPrevFile: AppActions.getPrevFile,openDirectory: AppActions.openDirectory,showInFileManager: AppActions.showInFileManager,- openFile: AppActions.openFile,+ openFsEntry: AppActions.openFsEntry,deleteDirectory: AppActions.deleteDirectory,reflectCreateEntry: AppActions.reflectCreateEntry,loadDirectoryContent: AppActions.loadDirectoryContent,diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsxindex 450af4a6d..8a91a8fb1 100644--- a/app/components/LocationManager.tsx+++ b/app/components/LocationManager.tsx@@ -73,6 +73,7 @@ import DragItemTypes from './DragItemTypes';import IOActions from '../reducers/io-actions';import DirectoryTreeView from '-/components/DirectoryTreeView';import LoadingLazy from '-/components/LoadingLazy';+import { FileSystemEntry } from '-/services/utils-io';const isLocationsReadOnly = window.ExtLocationsReadOnly;@@ -105,7 +106,7 @@ interface Props {currentLocationId: string;isReadOnlyMode: boolean;hideDrawer: () => void;- openFile: (path: string) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;openURLExternally: (path: string) => void;loadDirectoryContent: (path: string) => void;openLocation: (location: Location) => void;@@ -793,7 +794,7 @@ class LocationManager extends React.Component<Props, State> {directoryPath={this.state.selectedDirectoryPath}loadDirectoryContent={this.props.loadDirectoryContent}openDirectory={this.props.openDirectory}- openFile={this.props.openFile}+ openFsEntry={this.props.openFsEntry}reflectCreateEntry={this.props.reflectCreateEntry}deleteDirectory={this.props.deleteDirectory}classes={this.props.classes}@@ -829,7 +830,7 @@ function mapDispatchToProps(dispatch) {openDirectory: AppActions.openDirectory,showInFileManager: AppActions.showInFileManager,openFileNatively: AppActions.openFileNatively,- openFile: AppActions.openFile,+ openFsEntry: AppActions.openFsEntry,showNotification: AppActions.showNotification,moveFiles: IOActions.moveFiles,uploadFiles: IOActions.uploadFiles,diff --git a/app/components/Search.tsx b/app/components/Search.tsxindex 9f092430f..f40b57b4b 100644--- a/app/components/Search.tsx+++ b/app/components/Search.tsx@@ -567,6 +567,7 @@ class Search extends React.Component<Props, State> {tags={this.state.tagsAND}handleChange={this.handleTagFieldChange}tagSearchType="tagsAND"+ tagMode="remove"/></FormControl><FormControl className={classes.formControl} disabled={indexing}>@@ -576,6 +577,7 @@ class Search extends React.Component<Props, State> {label={i18n.t('core:atLeastOneOfTheseTags')}handleChange={this.handleTagFieldChange}tagSearchType="tagsOR"+ tagMode="remove"/></FormControl><FormControl className={classes.formControl} disabled={indexing}>@@ -585,6 +587,7 @@ class Search extends React.Component<Props, State> {label={i18n.t('core:noneOfTheseTags')}handleChange={this.handleTagFieldChange}tagSearchType="tagsNOT"+ tagMode="remove"/></FormControl><FormControldiff --git a/app/components/TagContainer.tsx b/app/components/TagContainer.tsxindex 86ddae77d..af54e9953 100644--- a/app/components/TagContainer.tsx+++ b/app/components/TagContainer.tsx@@ -24,14 +24,15 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';import PlaceIcon from '@material-ui/icons/Place';import DateIcon from '@material-ui/icons/DateRange';import RemoveTagIcon from '@material-ui/icons/Close';-import { TagGroup, Tag, getAllTags } from '../reducers/taglibrary';-import { getTagColor, getTagTextColor } from '../reducers/settings';-import { isPlusCode } from '../utils/misc';-import { isDateTimeTag } from '../utils/dates';+import { getAllTags, Tag, TagGroup } from '-/reducers/taglibrary';+import { getTagColor, getTagTextColor } from '-/reducers/settings';+import { isPlusCode } from '-/utils/misc';+import { isDateTimeTag } from '-/utils/dates';import { FileSystemEntry } from '-/services/utils-io';interface Props {tag: Tag;+ isReadOnlyMode?: boolean;allTags?: Array<Tag>;key?: string;defaultTextColor?: string;@@ -42,7 +43,7 @@ interface Props {tag: Tag,tagGroup: TagGroup | string) => void; // TODO refactor- handleRemoveTag?: (event: Object, tag: Tag) => void;+ handleRemoveTag?: (event: Object, tags: Array<Tag>) => void;isDragging?: boolean;tagMode?: 'default' | 'display' | 'remove';entryPath?: string;@@ -69,11 +70,9 @@ const TagContainer = React.memo((props: Props) => {addTags,tagMode} = props;-let textColor = tag.textcolor || defaultTextColor;let backgroundColor = tag.color || defaultBackgroundColor;- const titleOrig = tag.title;- let title = titleOrig;+ let { title } = tag;// Check if tag is plus codelet isGeoTag = false;@@ -104,6 +103,35 @@ const TagContainer = React.memo((props: Props) => {if (title && title.length > 0) {tid += title.replace(/ /g, '_');}++ function getActionMenu() {+ if (props.isReadOnlyMode) {+ return <div style={{ width: 10 }} />;+ }+ return tagMode === 'remove' ? (+ deleteIcon || (+ <RemoveTagIcon+ data-tid={'tagRemoveButton_' + title.replace(/ /g, '_')}+ style={{+ color: tag.textcolor,+ fontSize: 20+ }}+ onClick={event => handleRemoveTag(event, [tag])}+ />+ )+ ) : (+ <MoreVertIcon+ data-tid={'tagMoreButton_' + title.replace(/ /g, '_')}+ style={{+ color: tag.textcolor,+ marginLeft: -5,+ marginRight: -5,+ top: 0+ }}+ />+ );+ }+return (<divrole="presentation"@@ -180,28 +208,7 @@ const TagContainer = React.memo((props: Props) => {)}{!isGeoTag && title}</span>- {tagMode === 'remove' ? (- deleteIcon || (- <RemoveTagIcon- data-tid={'tagRemoveButton_' + title.replace(/ /g, '_')}- style={{- color: tag.textcolor,- fontSize: 20- }}- onClick={event => handleRemoveTag(event, tag)}- />- )- ) : (- <MoreVertIcon- data-tid={'tagMoreButton_' + title.replace(/ /g, '_')}- style={{- color: tag.textcolor,- marginLeft: -5,- marginRight: -5,- top: 0- }}- />- )}+ {getActionMenu()}</Button></div>);diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsxindex 6b2347d73..8221da111 100644--- a/app/components/TagLibrary.tsx+++ b/app/components/TagLibrary.tsx@@ -435,7 +435,18 @@ function mapStateToProps(state) {function mapDispatchToProps(dispatch) {return bindActionCreators({- ...TagLibraryActions, // TODO connect only the really needed+ toggleTagGroup: TagLibraryActions.toggleTagGroup,+ removeTagGroup: TagLibraryActions.removeTagGroup,+ moveTagGroupUp: TagLibraryActions.moveTagGroupUp,+ moveTagGroupDown: TagLibraryActions.moveTagGroupDown,+ sortTagGroup: TagLibraryActions.sortTagGroup,+ importTagGroups: TagLibraryActions.importTagGroups,+ exportTagGroups: TagLibraryActions.exportTagGroups,+ createTagGroup: TagLibraryActions.createTagGroup,+ editTag: TagLibraryActions.editTag,+ moveTag: TagLibraryActions.moveTag,+ editTagGroup: TagLibraryActions.editTagGroup,+ deleteTag: TagLibraryActions.deleteTag,addTags: TaggingActions.addTags,collectTagsFromLocation: TaggingActions.collectTagsFromLocation,openURLExternally: AppActions.openURLExternallydiff --git a/app/components/TagsSelect.tsx b/app/components/TagsSelect.tsxindex 4032e8777..17edd4699 100644--- a/app/components/TagsSelect.tsx+++ b/app/components/TagsSelect.tsx@@ -16,15 +16,18 @@**/-import React from 'react';+import React, { useCallback, useState } from 'react';import uuidv1 from 'uuid';import { connect } from 'react-redux';import { withStyles } from '@material-ui/core/styles';import TextField from '@material-ui/core/TextField';import Autocomplete from '@material-ui/lab/Autocomplete';-import { Tag, getAllTags } from '../reducers/taglibrary';-import { getTagColor, getTagTextColor } from '../reducers/settings';+import { bindActionCreators } from 'redux';+import { Tag, getAllTags } from '-/reducers/taglibrary';+import { getTagColor, getTagTextColor } from '-/reducers/settings';import TagContainer from './TagContainer';+import EntryTagMenu from '-/components/menus/EntryTagMenu';+import TaggingActions from '-/reducers/tagging-actions';const styles: any = (theme: any) => ({root: {@@ -73,11 +76,20 @@ interface Props {defaultTextColor?: string;handleChange?: (param1: any, param2: any, param3?: any) => void;allTags?: Array<Tag>;+ tagMode?: 'default' | 'display' | 'remove';isReadOnlyMode?: boolean;placeholderText?: string;+ selectedEntryPath?: string;+ // removeTags: (paths: Array<string>, tags: Array<Tag>) => void;}const TagsSelect = (props: Props) => {+ const [tagMenuAnchorEl, setTagMenuAnchorEl] = useState<null | HTMLElement>(+ null+ );++ const [selectedTag, setSelectedTag] = useState(undefined);+function handleTagChange(event: Object,selectedTags: Array<Tag>,@@ -123,18 +135,48 @@ const TagsSelect = (props: Props) => {const {classes,allTags,- tags,defaultBackgroundColor,defaultTextColor,placeholderText = '',- label+ label,+ tagMode,+ selectedEntryPath} = props;+ const tags = props.tags ? props.tags : [];++ const handleTagMenu = useCallback(+ (event: React.ChangeEvent<HTMLInputElement>, tag) => {+ setTagMenuAnchorEl(event.currentTarget);+ setSelectedTag(tag);+ },+ [tags]+ );++ const handleRemoveTag = useCallback(+ (event, cTag: Array<Tag>) => {+ /* const reducedTags = [...tags];+ for (let i = 0; i < reducedTags.length; i += 1) {+ if (reducedTags[i].title === cTag.title) {+ reducedTags.splice(i, 1);+ }+ } */+ if (cTag.length > 0) {+ handleTagChange(event, cTag, 'remove-value');+ }+ },+ [tags]+ );++ const handleCloseTagMenu = () => {+ setTagMenuAnchorEl(null);+ };+return (<div className={classes.root}><Autocompletemultiple- options={allTags}+ options={!props.isReadOnlyMode ? allTags : []}getOptionLabel={option => option.title}freeSoloautoSelect@@ -145,18 +187,12 @@ const TagsSelect = (props: Props) => {renderTags={(value: Tag[]) =>value.map((tag: Tag) => (<TagContainer- key={uuidv1()}+ key={selectedEntryPath + tag.title}+ isReadOnlyMode={props.isReadOnlyMode}tag={tag}- tagMode="remove"- handleRemoveTag={(event, cTag) => {- const reducedTags = [...tags];- for (let i = 0; i < reducedTags.length; i += 1) {- if (reducedTags[i].title === cTag.title) {- reducedTags.splice(i, 1);- }- }- handleTagChange(event, reducedTags, 'remove-value');- }}+ tagMode={tagMode}+ handleTagMenu={handleTagMenu}+ handleRemoveTag={handleRemoveTag}/>))}@@ -172,6 +208,17 @@ const TagsSelect = (props: Props) => {/>)}/>+ {selectedEntryPath && (+ <EntryTagMenu+ anchorEl={tagMenuAnchorEl}+ open={Boolean(tagMenuAnchorEl)}+ onClose={handleCloseTagMenu}+ selectedTag={selectedTag}+ currentEntryPath={selectedEntryPath}+ removeTags={handleRemoveTag}+ isReadOnlyMode={props.isReadOnlyMode}+ />+ )}</div>);};@@ -182,6 +229,15 @@ const mapStateToProps = state => ({defaultTextColor: getTagTextColor(state)});+/* function mapDispatchToProps(dispatch) {+ return bindActionCreators(+ {+ removeTags: TaggingActions.removeTags+ },+ dispatch+ );+} */+export default connect(mapStateToProps)(withStyles(styles, { withTheme: true })(TagsSelect));diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsxindex 5960639b9..5f00a188a 100644--- a/app/components/dialogs/AddRemoveTagsDialog.tsx+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx@@ -139,6 +139,7 @@ class AddRemoveTagsDialog extends React.Component<Props, State> {placeholderText={i18n.t('core:selectTags')}tags={newlyAddedTags}handleChange={this.handleChange}+ tagMode="remove"/><List dense style={{ width: 550 }}>{selectedEntries.length > 0 &&diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsxindex 20a9526d3..e77b38e0c 100644--- a/app/components/menus/DirectoryMenu.tsx+++ b/app/components/menus/DirectoryMenu.tsx@@ -35,7 +35,7 @@ import DefaultPerspectiveIcon from '@material-ui/icons/GridOn';import GalleryPerspectiveIcon from '@material-ui/icons/Camera';import MapiquePerspectiveIcon from '@material-ui/icons/Map';// import TreeVizPerspectiveIcon from '@material-ui/icons/AccountTree';-import KanBanPerspectiveIcon from '@material-ui/icons/Dashboard';+// import KanBanPerspectiveIcon from '@material-ui/icons/Dashboard';import NewFileIcon from '@material-ui/icons/InsertDriveFile';import NewFolderIcon from '@material-ui/icons/CreateNewFolder';import RenameFolderIcon from '@material-ui/icons/FormatTextdirectionLToR';@@ -59,6 +59,7 @@ import { actions as AppActions, perspectives } from '-/reducers/app';import IOActions from '-/reducers/io-actions';import { Tag } from '-/reducers/taglibrary';import TaggingActions from '-/reducers/tagging-actions';+import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';interface Props {open: boolean;@@ -68,7 +69,7 @@ interface Props {directoryPath: string;loadDirectoryContent: (path: string) => void;openDirectory: (path: string) => void;- openFile: (path: string, isFile: boolean) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;deleteDirectory: (path: string) => void;reflectCreateEntry?: (path: string, isFile: boolean) => void;toggleCreateFileDialog?: () => void;@@ -125,7 +126,19 @@ const DirectoryMenu = (props: Props) => {function showProperties() {props.onClose();- props.openFile(props.directoryPath, false);+ getAllPropertiesPromise(props.directoryPath)+ .then((fsEntry: FileSystemEntry) => {+ props.openFsEntry(fsEntry);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' ++ props.directoryPath ++ ' - ' ++ error+ )+ );}// function initContentExtraction() {diff --git a/app/components/menus/FileMenu.tsx b/app/components/menus/FileMenu.tsxindex bc3b5bb08..38e88387e 100644--- a/app/components/menus/FileMenu.tsx+++ b/app/components/menus/FileMenu.tsx@@ -32,6 +32,7 @@ import DeleteForever from '@material-ui/icons/DeleteForever';import i18n from '-/services/i18n';import AppConfig from '-/config';import PlatformIO from '-/services/platform-io';+import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';interface Props {anchorEl: Element;@@ -41,7 +42,7 @@ interface Props {openRenameFileDialog: () => void;openMoveCopyFilesDialog: () => void;openAddRemoveTagsDialog: () => void;- openFile: (path: string, isFile: boolean) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;openFileNatively: (path: string) => void;showInFileManager: (path: string) => void;selectedFilePath?: string;@@ -86,7 +87,19 @@ const FileMenu = (props: Props) => {function openFile() {props.onClose();if (props.selectedFilePath) {- props.openFile(props.selectedFilePath, true);+ getAllPropertiesPromise(props.selectedFilePath)+ .then((fsEntry: FileSystemEntry) => {+ props.openFsEntry(fsEntry);+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' ++ props.selectedFilePath ++ ' - ' ++ error+ )+ );}}diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsxindex 09897dda2..1d0e89fa7 100644--- a/app/components/menus/TagMenu.tsx+++ b/app/components/menus/TagMenu.tsx@@ -28,7 +28,7 @@ import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';import ConfirmDialog from '../dialogs/ConfirmDialog';import EditTagDialog from '../dialogs/EditTagDialog';-import { Tag, TagGroup } from '-/reducers/taglibrary';+import { Tag, TagGroup, Uuid } from '-/reducers/taglibrary';import { actions as LocationIndexActions } from '-/reducers/location-index';import i18n from '-/services/i18n';import { SearchQuery } from '-/services/search';@@ -44,9 +44,9 @@ interface Props {onClose: () => void;selectedTag?: Tag;selectedTagGroupEntry?: TagGroup;- deleteTag: (uuid: string, tagGroupUuid: string) => void;searchLocationIndex: (searchQuery: SearchQuery) => void;- editTag: () => void;+ editTag: (tag: Tag, parentTagGroupUuid: Uuid, origTitle: string) => void;+ deleteTag: (tagTitle: string, parentTagGroupUuid: Uuid) => void;openSearchPanel: () => void;maxSearchResults: number;}diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex 647a959a0..b0c89a05c 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -91,6 +91,7 @@ import { CustomDragLayer } from '-/components/CustomDragLayer';import IOActions from '-/reducers/io-actions';import FileUploadDialog from '-/components/dialogs/FileUploadDialog';import ProgressDialog from '-/components/dialogs/ProgressDialog';+import { FileSystemEntry } from '-/services/utils-io';const initialSplitSize = 44;const drawerWidth = 300;@@ -184,7 +185,7 @@ interface Props {toggleAboutDialog: () => void; // needed by electron-menustoggleOnboardingDialog: () => void; // needed by electron-menussetLastSelectedEntry: (path: string) => void; // needed by electron-menus- // openFile: (path: string) => void; // needed by electron-menus+ openFsEntry: (fsEntry: FileSystemEntry) => void; // needed by electron-menusopenFileNatively: (url: string) => void; // needed by electron-menusopenURLExternally: (url: string) => void;getNextFile: () => void; // needed by electron-menus@@ -1003,7 +1004,7 @@ function mapDispatchToProps(dispatch) {toggleOnboardingDialog: AppActions.toggleOnboardingDialog,setLastSelectedEntry: AppActions.setLastSelectedEntry,setGeneratingThumbnails: AppActions.setGeneratingThumbnails,- openFile: AppActions.openFile,+ openFsEntry: AppActions.openFsEntry,openFileNatively: AppActions.openFileNatively,openURLExternally: AppActions.openURLExternally,setEntryFullWidth: AppActions.setEntryFullWidth,diff --git a/app/containers/Root.tsx b/app/containers/Root.tsxindex ddcf6aba2..e89b222e3 100644--- a/app/containers/Root.tsx+++ b/app/containers/Root.tsx@@ -29,10 +29,11 @@ import {isGlobalKeyBindingEnabled,isFirstRun} from '../reducers/settings';-import { getDefaultLocationId } from '../reducers/locations';+import { getDefaultLocationId } from '-/reducers/locations';import PlatformIO from '../services/platform-io';// import MainPage from './MainPage';-import { getURLParameter } from '../utils/misc';+import { getURLParameter } from '-/utils/misc';+import { FileSystemEntry, getAllPropertiesPromise } from '-/services/utils-io';type RootType = {store: {};@@ -68,7 +69,17 @@ function onBeforeLift(store) {if (openParam && openParam.length > 1) {// dispatch toggle full widthsetTimeout(() => {- store.dispatch(AppActions.openFile(decodeURIComponent(openParam)));+ getAllPropertiesPromise(decodeURIComponent(openParam))+ .then((fsEntry: FileSystemEntry) => {+ store.dispatch(AppActions.openFsEntry(fsEntry));+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + openParam + ' - ' + error+ )+ );+ // store.dispatch(AppActions.openFile(decodeURIComponent(openParam)));store.dispatch(AppActions.setEntryFullWidth(true));}, 1000);}diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsxindex c596656ec..4157e3780 100644--- a/app/perspectives/grid-perspective/components/CellContent.tsx+++ b/app/perspectives/grid-perspective/components/CellContent.tsx@@ -25,8 +25,8 @@ import Typography from '@material-ui/core/Typography';import IconButton from '@material-ui/core/IconButton';import Paper from '@material-ui/core/Paper';import FolderIcon from '@material-ui/icons/FolderOpen';-import SelectedIcon from '@material-ui/icons/CheckCircle';-import UnSelectedIcon from '@material-ui/icons/RadioButtonUnchecked';+// import SelectedIcon from '@material-ui/icons/CheckCircle';+// import UnSelectedIcon from '@material-ui/icons/RadioButtonUnchecked';import TagIcon from '@material-ui/icons/LocalOfferOutlined';import { formatFileSize, formatDateTime } from '-/utils/misc';import { extractTitle } from '-/utils/paths';@@ -49,7 +49,7 @@ interface Props {supportedFileTypes: Array<Object>;thumbnailMode: any;addTags: () => void;- openFile: (path: string, isFile: boolean) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;selectedEntries: Array<FileSystemEntry>;isReadOnlyMode: boolean;showTags: boolean;@@ -78,7 +78,7 @@ const CellContent = (props: Props) => {handleGridCellDblClick,handleGridCellClick,showTags,- openFile+ openFsEntry} = props;const fsEntryBackgroundColor = fsEntry.color ? fsEntry.color : 'transparent';const entryTitle = extractTitle(@@ -106,10 +106,7 @@ const CellContent = (props: Props) => {tagTitles = tagTitles.substring(0, tagTitles.length - 2);const tagPlaceholder =tagTitles.length > 0 ? (- <IconButton- title={tagTitles}- onClick={() => openFile(fsEntry.path, fsEntry.isFile)}- >+ <IconButton title={tagTitles} onClick={() => openFsEntry(fsEntry)}><TagIcon /></IconButton>) : null;diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsxindex e4850c2f2..49a21e5bb 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -75,7 +75,7 @@ interface Props {selectedEntries: Array<any>;supportedFileTypes: Array<any>;isReadOnlyMode: boolean;- openFile: (path: string, isFile: boolean) => void;+ openFsEntry: (fsEntry: FileSystemEntry) => void;getNextFile: () => any;getPrevFile: () => any;deleteFile: (path: string) => void;@@ -361,7 +361,7 @@ class GridPerspective extends React.Component<Props, State> {setLastSelectedEntry(fsEntry.path);if (fsEntry.isFile) {if (this.state.singleClickAction === 'openInternal') {- this.props.openFile(fsEntry.path, fsEntry.isFile);+ this.props.openFsEntry(fsEntry);} else if (this.state.singleClickAction === 'openExternal') {this.props.openFileNatively(fsEntry.path);}@@ -470,7 +470,7 @@ class GridPerspective extends React.Component<Props, State> {openLocation = (fsEntry: FileSystemEntry) => {if (fsEntry.isFile) {this.props.setSelectedEntries([fsEntry]);- this.props.openFile(fsEntry.path, true);+ this.props.openFsEntry(fsEntry);} else {console.log('Handle Grid cell db click, selected path : ', fsEntry.path);this.props.loadDirectoryContent(fsEntry.path);@@ -634,7 +634,7 @@ class GridPerspective extends React.Component<Props, State> {selectedEntries,addTags,supportedFileTypes,- openFile+ openFsEntry} = this.props;if (!fsEntry.isFile && !showDirectories) {return;@@ -671,7 +671,7 @@ class GridPerspective extends React.Component<Props, State> {handleTagMenu={this.handleTagMenu}layoutType={layoutType}showTags={this.state.showTags}- openFile={openFile}+ openFsEntry={openFsEntry}handleGridContextMenu={this.handleGridContextMenu}handleGridCellDblClick={this.handleGridCellDblClick}handleGridCellClick={this.handleGridCellClick}@@ -760,11 +760,11 @@ class GridPerspective extends React.Component<Props, State> {e.preventDefault();const { lastSelectedEntryPath } = this.props;if (lastSelectedEntryPath) {- const isLastSelectedEntryFile = this.props.directoryContent.some(+ const lastSelectedEntryFile = this.props.directoryContent.find(fsEntry => fsEntry.isFile && fsEntry.path === lastSelectedEntryPath);- if (isLastSelectedEntryFile) {- this.props.openFile(lastSelectedEntryPath, true);+ if (lastSelectedEntryFile) {+ this.props.openFsEntry(lastSelectedEntryFile);} else {this.props.loadDirectoryContent(lastSelectedEntryPath);}@@ -915,7 +915,7 @@ class GridPerspective extends React.Component<Props, State> {openRenameFileDialog={this.openFileRenameDialog}openMoveCopyFilesDialog={this.openMoveCopyFilesDialog}openAddRemoveTagsDialog={this.openAddRemoveTagsDialog}- openFile={this.props.openFile}+ openFsEntry={this.props.openFsEntry}openFileNatively={this.props.openFileNatively}showInFileManager={this.props.showInFileManager}isReadOnlyMode={this.props.isReadOnlyMode}@@ -928,7 +928,7 @@ class GridPerspective extends React.Component<Props, State> {directoryPath={this.state.selectedEntryPath}loadDirectoryContent={this.props.loadDirectoryContent}openDirectory={this.props.openDirectory}- openFile={this.props.openFile}+ openFsEntry={this.props.openFsEntry}deleteDirectory={this.props.deleteDirectory}isReadOnlyMode={this.props.isReadOnlyMode}perspectiveMode={true}diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 391a60b9a..a9a4f0954 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -26,7 +26,9 @@ import {loadMetaDataPromise,renameFilesPromise,enhanceDirectoryContent,- FileSystemEntryMeta+ FileSystemEntryMeta,+ FileSystemEntry,+ getAllPropertiesPromise} from '-/services/utils-io';import {extractFileExtension,@@ -117,6 +119,8 @@ export const NotificationTypes = {export type OpenedEntry = {path: string;url?: string;+ size: number;+ lmdt: number;viewingExtensionPath: string;viewingExtensionId: string;editingExtensionPath?: string;@@ -127,6 +131,11 @@ export type OpenedEntry = {perspective?: string;editMode?: boolean;changed?: boolean;+ /**+ * if its true iframe will be reloaded+ * if its false && editMode==true and changed==true => show reload dialog+ * default: undefined+ */shouldReload?: boolean;focused?: boolean; // TODO make it mandatory once support for multiple files is addedtags?: Array<Tag>;@@ -502,8 +511,8 @@ export default (state: any = initialState, action: any) => {}return {...entry,- path: action.newPath, // TODO handle change extension case- shouldReload: true+ path: action.newPath // TODO handle change extension case+ // shouldReload: true};})};@@ -542,13 +551,22 @@ export default (state: any = initialState, action: any) => {return entry;}if (action.entry.tags && action.entry.tags.length > 0) {+ /* const tags = [...entry.tags]; // .filter(tag => tag.type === 'plain')];+ action.entry.tags.map(tag => {+ if (!entry.tags.some(oldTag => oldTag.title === tag.title)) {+ tags.push(tag);+ }+ return true;+ }); */+return {...entry,- ...action.entry,- tags: [+ ...action.entry+ // tags+ /* tags: [...entry.tags.filter(tag => tag.type === 'plain'),...action.entry.tags- ]+ ] */};}return {@@ -582,6 +600,7 @@ export default (state: any = initialState, action: any) => {};}case types.CLOSE_ALL_FILES: {+ // eslint-disable-next-line no-restricted-globalswindow.history.pushState('', 'TagSpaces', location.pathname);return {...state,@@ -1041,7 +1060,19 @@ export const actions = {true));- dispatch(actions.openFile(filePath));+ getAllPropertiesPromise(filePath)+ .then((fsEntry: FileSystemEntry) => {+ dispatch(actions.openFsEntry(fsEntry)); // TODO return fsEntry from saveFilePromise and simplify+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' ++ filePath ++ ' - ' ++ error+ )+ );// TODO select file // dispatch(actions.setLastSelectedEntry(filePath));return true;})@@ -1087,7 +1118,16 @@ export const actions = {PlatformIO.saveFilePromise(filePath, fileContent, true).then(() => {dispatch(actions.reflectCreateEntry(filePath, true));- dispatch(actions.openFile(filePath, true, true));+ getAllPropertiesPromise(filePath)+ .then((fsEntry: FileSystemEntry) => {+ dispatch(actions.openFsEntry(fsEntry)); // TODO return fsEntry from saveFilePromise and simplify+ return true;+ })+ .catch(error =>+ console.warn(+ 'Error getting properties for entry: ' + filePath + ' - ' + error+ )+ );dispatch(actions.setLastSelectedEntry(filePath));dispatch(actions.showNotification(@@ -1238,33 +1278,128 @@ export const actions = {}),updateOpenedFile: (entryPath: string,- fsEntryMeta: FileSystemEntryMeta,- isFile: boolean = true+ fsEntryMeta: any // FileSystemEntryMeta,+ // isFile: boolean = true) => (dispatch: (actions: Object) => void, getState: () => any) => {+ PlatformIO.getPropertiesPromise(entryPath)+ .then(entryProps => {+ if (entryProps) {+ const { supportedFileTypes } = getState().settings;+ const { openedFiles } = getState().app;+ let entryForOpening: OpenedEntry;+ if (openedFiles && openedFiles.length > 0) {+ entryForOpening = openedFiles.find(obj => obj.path === entryPath);+ }+ if (!entryForOpening) {+ entryForOpening = findExtensionsForEntry(+ supportedFileTypes,+ entryPath,+ entryProps.isFile+ );+ }++ if (fsEntryMeta.changed !== undefined) {+ entryForOpening.changed = fsEntryMeta.changed;+ } /* else {+ entryForOpening.changed = true;+ } */+ if (fsEntryMeta.editMode !== undefined) {+ entryForOpening.editMode = fsEntryMeta.editMode;+ }+ if (fsEntryMeta.shouldReload !== undefined) {+ entryForOpening.shouldReload = fsEntryMeta.shouldReload;+ }+ if (fsEntryMeta.color) {+ entryForOpening.color = fsEntryMeta.color;+ }+ if (fsEntryMeta.description) {+ entryForOpening.description = fsEntryMeta.description;+ }+ if (fsEntryMeta.perspective) {+ entryForOpening.perspective = fsEntryMeta.perspective;+ }+ if (fsEntryMeta.tags) {+ entryForOpening.tags = fsEntryMeta.tags;+ }+ dispatch(actions.addToEntryContainer(entryForOpening));+ }+ return true;+ })+ .catch(err => {+ console.error('updateOpenedFile ' + entryPath + ' not exist ' + err);+ });+ },+ openFsEntry: (fsEntry: FileSystemEntry) => (+ dispatch: (actions: Object) => void,+ getState: () => any+ ) => {+ let entryForOpening: OpenedEntry;+ const { openedFiles } = getState().app;+ /**+ * check for editMode in order to show save changes dialog (shouldReload: false)+ */+ if (openedFiles.length > 0) {+ const openFile = openedFiles[0];+ if (openFile.editMode && openFile.changed) {+ entryForOpening = { ...openFile, shouldReload: false };+ dispatch(actions.addToEntryContainer(entryForOpening));+ return false;+ }+ }+const { supportedFileTypes } = getState().settings;- const entryForOpening: OpenedEntry = findExtensionsForEntry(+ // TODO decide to copy all props from {...fsEntry} into openedEntry+ entryForOpening = findExtensionsForEntry(supportedFileTypes,- entryPath,- isFile+ fsEntry.path,+ fsEntry.isFile);- if (fsEntryMeta.color) {- entryForOpening.color = fsEntryMeta.color;+ if (fsEntry.url) {+ entryForOpening.url = fsEntry.url;+ }+ if (fsEntry.perspective) {+ entryForOpening.perspective = fsEntry.perspective;}- if (fsEntryMeta.description) {- entryForOpening.description = fsEntryMeta.description;+ if (fsEntry.description) {+ entryForOpening.description = fsEntry.description;}- if (fsEntryMeta.perspective) {- entryForOpening.perspective = fsEntryMeta.perspective;+ if (fsEntry.tags) {+ entryForOpening.tags = fsEntry.tags;}+ if (fsEntry.lmdt) {+ entryForOpening.lmdt = fsEntry.lmdt;+ }+ if (fsEntry.size) {+ entryForOpening.size = fsEntry.size;+ }+ const localePar = getURLParameter(fsEntry.path);+ let startPar = '?open=' + encodeURIComponent(fsEntry.path);+ if (localePar && localePar.length > 1) {+ startPar += '&locale=' + localePar;+ }+ // eslint-disable-next-line no-restricted-globals+ window.history.pushState('', 'TagSpaces', location.pathname + startPar);+dispatch(actions.addToEntryContainer(entryForOpening));},- openFile: (+ /* openFile: (entryPath: string,isFile: boolean = true,editMode: boolean = false) => (dispatch: (actions: Object) => void, getState: () => any) => {+ let entryForOpening: OpenedEntry;+ const { openedFiles } = getState().app;+ // check for editMode+ if (openedFiles.length > 0) {+ const openFile = openedFiles[0];+ if (openFile.editMode && openFile.changed) {+ entryForOpening = { ...openFile, shouldReload: false };+ dispatch(actions.addToEntryContainer(entryForOpening));+ return false;+ }+ }const { supportedFileTypes } = getState().settings;- const entryForOpening: OpenedEntry = findExtensionsForEntry(+ entryForOpening = findExtensionsForEntry(supportedFileTypes,entryPath,isFile@@ -1280,6 +1415,12 @@ export const actions = {if (currentEntry.perspective) {entryForOpening.perspective = currentEntry.perspective;}+ if (currentEntry.description) {+ entryForOpening.description = currentEntry.description;+ }+ if (currentEntry.tags) {+ entryForOpening.tags = currentEntry.tags;+ }}if (editMode &&@@ -1293,10 +1434,11 @@ export const actions = {if (localePar && localePar.length > 1) {startPar += '&locale=' + localePar;}+ // eslint-disable-next-line no-restricted-globalswindow.history.pushState('', 'TagSpaces', location.pathname + startPar);dispatch(actions.addToEntryContainer(entryForOpening));- },+ }, */toggleEntryFullWidth: () => ({type: types.TOGGLE_ENTRY_FULLWIDTH}),@@ -1501,7 +1643,7 @@ export const actions = {) =>PlatformIO.renameFilePromise(filePath, newFilePath).then(() => {- // console.log('File renamed ' + filePath + ' to ' + newFilePath);+ console.info('File renamed ' + filePath + ' to ' + newFilePath);dispatch(actions.showNotification(i18n.t('core:renamingSuccessfully'),@@ -1509,6 +1651,7 @@ export const actions = {true));+ dispatch(actions.reflectRenameEntry(filePath, newFilePath));// Update sidecar file and thumbrenameFilesPromise([[@@ -1527,15 +1670,23 @@ export const actions = {]]).then(() => {- console.log(- 'Renaming meta file and thumb successful for ' + filePath+ console.info(+ 'Renaming meta file and thumb successful from ' ++ filePath ++ ' to:' ++ newFilePath);- dispatch(actions.reflectRenameEntry(filePath, newFilePath));return true;}).catch(err => {- dispatch(actions.reflectRenameEntry(filePath, newFilePath));- console.warn('Renaming meta file and thumb failed with ' + err);+ console.warn(+ 'Renaming meta file and thumb failed from ' ++ filePath ++ ' to:' ++ newFilePath ++ ' with ' ++ err+ );});return true;})@@ -1681,7 +1832,9 @@ function findExtensionsForEntry(viewingExtensionPath,viewingExtensionId: '',isFile,- changed: false+ changed: false,+ lmdt: 0,+ size: 0};supportedFileTypes.map(fileType => {if (fileType.viewer && fileType.type.toLowerCase() === fileExtension) {diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.tsindex d7f13e893..93fb9553d 100644--- a/app/reducers/tagging-actions.ts+++ b/app/reducers/tagging-actions.ts@@ -149,6 +149,7 @@ const actions = {} catch (error) {console.log('No sidecar found ' + error);}+if (!entryProperties.isFile || settings.persistTagsInSidecarFile) {// Handling adding tags in sidecarif (fsEntryMeta) {@@ -169,8 +170,14 @@ const actions = {};saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {- dispatch(+ /* dispatch(AppActions.reflectUpdateSidecarTags(path, newTags, updateIndex)+ ); */+ dispatch(+ AppActions.updateOpenedFile(path, {+ tags: newTags,+ changed: true+ }));return true;})@@ -190,8 +197,11 @@ const actions = {saveMetaDataPromise(path, newFsEntryMeta).then(() => {dispatch(- AppActions.reflectUpdateSidecarTags(path, tags, updateIndex)+ AppActions.updateOpenedFile(path, { tags, changed: true }));+ /* dispatch(+ AppActions.reflectUpdateSidecarTags(path, tags, updateIndex)+ ); */return true;}).catch(error => {@@ -371,8 +381,14 @@ const actions = {saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {dispatch(- AppActions.reflectUpdateSidecarTags(path, fsEntryMeta.tags)+ AppActions.updateOpenedFile(path, {+ tags: fsEntryMeta.tags,+ changed: true+ }));+ /* dispatch(+ AppActions.reflectUpdateSidecarTags(path, fsEntryMeta.tags)+ ); */return true;}).catch(err => {@@ -399,8 +415,14 @@ const actions = {saveMetaDataPromise(path, fsEntryMeta).then(() => {dispatch(- AppActions.reflectUpdateSidecarTags(path, fsEntryMeta.tags)+ AppActions.updateOpenedFile(path, {+ tags: fsEntryMeta.tags,+ changed: true+ }));+ /* dispatch(+ AppActions.reflectUpdateSidecarTags(path, fsEntryMeta.tags)+ ); */return true;}).catch(err => {@@ -483,7 +505,13 @@ const actions = {};saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {- dispatch(AppActions.reflectUpdateSidecarTags(path, newTags));+ // dispatch(AppActions.reflectUpdateSidecarTags(path, newTags));+ dispatch(+ AppActions.updateOpenedFile(path, {+ tags: newTags,+ changed: true+ })+ );removeTagsFromFilename();return true;})@@ -561,7 +589,10 @@ const actions = {};saveMetaDataPromise(path, updatedFsEntryMeta).then(() => {- dispatch(AppActions.reflectUpdateSidecarTags(path, []));+ // dispatch(AppActions.reflectUpdateSidecarTags(path, []));+ dispatch(+ AppActions.updateOpenedFile(path, { tags: [], changed: true })+ );removeAllTagsFromFilename();return true;})diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 34132ff42..82af8660c 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -28,11 +28,12 @@ import {getMetaFileLocationForFile,getMetaFileLocationForDir,extractContainingDirectoryPath-} from '../utils/paths';+} from '-/utils/paths';// import { formatDateTime4Tag } from '../utils/misc';import versionMeta from '../version.json';-import { Tag } from '../reducers/taglibrary';+import { Tag } from '-/reducers/taglibrary';import { getThumbnailURLPromise } from '-/services/thumbsgenerator';+import { OpenedEntry } from '-/reducers/app';export interface FileSystemEntry {uuid?: string;@@ -177,6 +178,33 @@ export function enhanceEntry(entry: any): FileSystemEntry {return enhancedEntry;}+export function enhanceOpenedEntry(+ entry: OpenedEntry,+ tagDelimiter+): OpenedEntry {+ const fineNameTags = extractTagsAsObjects(+ entry.path,+ tagDelimiter,+ PlatformIO.getDirSeparator()+ );+ if (fineNameTags.length > 0) {+ if (entry.tags && entry.tags.length > 0) {+ const uniqueTags = entry.tags.filter(+ tag => fineNameTags.findIndex(obj => obj.title === tag.title) === -1+ );+ return {+ ...entry,+ tags: [...uniqueTags, ...fineNameTags]+ };+ }+ return {+ ...entry,+ tags: fineNameTags+ };+ }+ return entry;+}+export function createDirectoryIndex(directoryPath: string,extractText: boolean = false@@ -556,60 +584,67 @@ export async function saveMetaDataPromise(metaData: any): Promise<any> {const entryProperties = await PlatformIO.getPropertiesPromise(path);- let metaFilePath;- let newFsEntryMeta;-- if (entryProperties.isFile) {- metaFilePath = getMetaFileLocationForFile(- path,- PlatformIO.getDirSeparator()- );- // check and create meta folder if not exist- await PlatformIO.createDirectoryPromise(- extractContainingDirectoryPath(metaFilePath, PlatformIO.getDirSeparator())- );+ if (entryProperties) {+ let metaFilePath;+ let newFsEntryMeta;+ if (entryProperties.isFile) {+ metaFilePath = getMetaFileLocationForFile(+ path,+ PlatformIO.getDirSeparator()+ );+ // check and create meta folder if not exist+ await PlatformIO.createDirectoryPromise(+ extractContainingDirectoryPath(+ metaFilePath,+ PlatformIO.getDirSeparator()+ )+ );++ newFsEntryMeta = {+ ...metaData,+ appName: versionMeta.name,+ appVersionUpdated: versionMeta.version,+ lastUpdated: new Date().toJSON()+ };+ } else {+ // check and create meta folder if not exist+ // todo not need to check if folder exist first createDirectoryPromise() recursively will skip creation of existing folders https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback+ const metaDirectoryPath = getMetaDirectoryPath(+ path,+ PlatformIO.getDirSeparator()+ );+ const metaDirectoryProperties = await PlatformIO.getPropertiesPromise(+ metaDirectoryPath+ );+ if (!metaDirectoryProperties) {+ await PlatformIO.createDirectoryPromise(metaDirectoryPath);+ }- newFsEntryMeta = {- ...metaData,- appName: versionMeta.name,- appVersionUpdated: versionMeta.version,- lastUpdated: new Date().toJSON()- };- } else {- // check and create meta folder if not exist- // todo not need to check if folder exist first createDirectoryPromise() recursively will skip creation of existing folders https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback- const metaDirectoryPath = getMetaDirectoryPath(- path,- PlatformIO.getDirSeparator()- );- const metaDirectoryProperties = await PlatformIO.getPropertiesPromise(- metaDirectoryPath- );- if (!metaDirectoryProperties) {- await PlatformIO.createDirectoryPromise(metaDirectoryPath);- }+ let dirId;+ if (metaData && metaData.id && metaData.id.length > 1) {+ dirId = metaData.id;+ } else {+ dirId = uuidv1();+ }- let dirId;- if (metaData && metaData.id && metaData.id.length > 1) {- dirId = metaData.id;- } else {- dirId = uuidv1();+ metaFilePath = getMetaFileLocationForDir(+ path,+ PlatformIO.getDirSeparator()+ );+ newFsEntryMeta = {+ ...metaData,+ id: dirId,+ appName: versionMeta.name,+ appVersionUpdated: versionMeta.version,+ lastUpdated: new Date().toJSON()+ };}-- metaFilePath = getMetaFileLocationForDir(- path,- PlatformIO.getDirSeparator()- );- newFsEntryMeta = {- ...metaData,- id: dirId,- appName: versionMeta.name,- appVersionUpdated: versionMeta.version,- lastUpdated: new Date().toJSON()- };+ const content = JSON.stringify(newFsEntryMeta);+ return PlatformIO.saveTextFilePromise(metaFilePath, content, true);}- const content = JSON.stringify(newFsEntryMeta);- return PlatformIO.saveTextFilePromise(metaFilePath, content, true);+ return new Promise((resolve, reject) =>+ reject(new Error('file not found' + path))+ );}export function findColorForFileEntry(