TagSpaces is an offline, open source, document manager with tagging support
fix: color of file changed indication dot
Ilian Sapundshiev7520c8fbcc5b
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex feebba43c..081c97888 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -441,52 +441,54 @@ function EntryContainer(props: Props) {// if (!this.state.currentEntry.isFile) {// textFilePath += '/index.html';// }- props.switchLocationType(openedFile.locationId).then((currentLocationId) => {- 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(currentLocationId => {+ 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 props.switchCurrentLocationType(currentLocationId);- })- .catch(err => {- console.warn('Error loading text content ' + err);- return props.switchCurrentLocationType(currentLocationId);- });- });+ 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(currentLocationId);+ })+ .catch(err => {+ console.warn('Error loading text content ' + err);+ return props.switchCurrentLocationType(currentLocationId);+ });+ });break;case 'contentChangedInEditor': {if (!fileChanged.current) {@@ -556,7 +558,7 @@ function EntryContainer(props: Props) {};const saveFile = (textContent: string) => {- props.switchLocationType(openedFile.locationId).then((currentLocationId) => {+ props.switchLocationType(openedFile.locationId).then(currentLocationId => {PlatformIO.saveTextFilePromise(openedFile.path, textContent, true).then(result => {// isChanged = false;@@ -596,7 +598,7 @@ function EntryContainer(props: Props) {};const editFile = () => {- props.switchLocationType(openedFile.locationId).then((currentLocationId) => {+ props.switchLocationType(openedFile.locationId).then(currentLocationId => {updateOpenedFile(openedFile.path, {...openedFile,editMode: true,@@ -1135,7 +1137,14 @@ function EntryContainer(props: Props) {<>{fileChanged.current ? (<Tooltip title="File changed">- <span>{' ' + String.fromCharCode(0x25cf)}</span>+ <span+ style={{+ color: theme.palette.text.primary,+ margin: 3+ }}+ >+ {String.fromCharCode(0x25cf)}+ </span></Tooltip>) : (''@@ -1438,7 +1447,7 @@ function mapStateToProps(state) {keyBindings: getKeyBindingObject(state),isDesktopMode: isDesktopMode(state),tileServer: getMapTileServer(state),- language: getCurrentLanguage(state),+ language: getCurrentLanguage(state)// currentLocationId: getCurrentLocationId(state)};}diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 98ebdf296..e5fed75cc 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -272,29 +272,31 @@ function EntryProperties(props: Props) {);const nextPath = path + PlatformIO.getDirSeparator() + editName;- props.switchLocationType(props.openedEntry.locationId).then((currentLocationId) => {- if (currentEntry.isFile) {- renameFile(currentEntry.path, nextPath)- .then(() => {- props.switchCurrentLocationType(currentLocationId);- return true;- })- .catch(() => {- props.switchCurrentLocationType(currentLocationId);- fileNameRef.current.value = entryName;- });- } else {- renameDirectory(currentEntry.path, editName)- .then(() => {- props.switchCurrentLocationType(currentLocationId);- return true;- })- .catch(() => {- props.switchCurrentLocationType(currentLocationId);- fileNameRef.current.value = entryName;- });- }- });+ props+ .switchLocationType(props.openedEntry.locationId)+ .then(currentLocationId => {+ if (currentEntry.isFile) {+ renameFile(currentEntry.path, nextPath)+ .then(() => {+ props.switchCurrentLocationType(currentLocationId);+ return true;+ })+ .catch(() => {+ props.switchCurrentLocationType(currentLocationId);+ fileNameRef.current.value = entryName;+ });+ } else {+ renameDirectory(currentEntry.path, editName)+ .then(() => {+ props.switchCurrentLocationType(currentLocationId);+ return true;+ })+ .catch(() => {+ props.switchCurrentLocationType(currentLocationId);+ fileNameRef.current.value = entryName;+ });+ }+ });setEditName(undefined);}@@ -330,24 +332,26 @@ function EntryProperties(props: Props) {return;}if (editDescription.current !== undefined) {- props.switchLocationType(props.openedEntry.locationId).then((currentLocationId) => {- Pro.MetaOperations.saveDescription(- currentEntry.path,- editDescription.current- )- .then(entryMeta => {- editDescription.current = undefined;- props.updateOpenedFile(currentEntry.path, entryMeta);- props.switchCurrentLocationType(currentLocationId);- return true;- })- .catch(error => {- console.warn('Error saving description ' + error);- editDescription.current = undefined;- props.switchCurrentLocationType(currentLocationId);- props.showNotification(i18n.t('Error saving description'));- });- });+ props+ .switchLocationType(props.openedEntry.locationId)+ .then(currentLocationId => {+ Pro.MetaOperations.saveDescription(+ currentEntry.path,+ editDescription.current+ )+ .then(entryMeta => {+ editDescription.current = undefined;+ props.updateOpenedFile(currentEntry.path, entryMeta);+ props.switchCurrentLocationType(currentLocationId);+ return true;+ })+ .catch(error => {+ console.warn('Error saving description ' + error);+ editDescription.current = undefined;+ props.switchCurrentLocationType(currentLocationId);+ props.showNotification(i18n.t('Error saving description'));+ });+ });} else if (currentEntry.description) {editDescription.current = currentEntry.description;} else {@@ -389,33 +393,35 @@ function EntryProperties(props: Props) {const setThumb = (filePath, thumbFilePath) => {if (filePath !== undefined) {- return props.switchLocationType(props.openedEntry.locationId).then((currentLocationId) => {- if (- PlatformIO.haveObjectStoreSupport() ||- PlatformIO.haveWebDavSupport()- ) {- const thumbUrl = PlatformIO.getURLforPath(thumbFilePath);- props.updateThumbnailUrl(currentEntry.path, thumbUrl);- return true;- }- /*return replaceThumbnailURLPromise(filePath, thumbFilePath)+ return props+ .switchLocationType(props.openedEntry.locationId)+ .then(currentLocationId => {+ if (+ PlatformIO.haveObjectStoreSupport() ||+ PlatformIO.haveWebDavSupport()+ ) {+ const thumbUrl = PlatformIO.getURLforPath(thumbFilePath);+ props.updateThumbnailUrl(currentEntry.path, thumbUrl);+ return true;+ }+ /*return replaceThumbnailURLPromise(filePath, thumbFilePath).then(objUrl => {*/- props.updateThumbnailUrl(- currentEntry.path,- thumbFilePath- // objUrl.tmbPath- /*(props.lastThumbnailImageChange+ props.updateThumbnailUrl(+ currentEntry.path,+ thumbFilePath+ // objUrl.tmbPath+ /*(props.lastThumbnailImageChange? '?' + props.lastThumbnailImageChange: '')*/- );- return props.switchCurrentLocationType(currentLocationId);- /*})+ );+ return props.switchCurrentLocationType(currentLocationId);+ /*}).catch(err => {props.switchCurrentLocationType();console.warn('Error replaceThumbnailURLPromise ' + err);props.showNotification('Error replacing thumbnail');});*/- });+ });} else {// reset Thumbnailreturn getThumbnailURLPromise(currentEntry.path)@@ -450,23 +456,25 @@ function EntryProperties(props: Props) {// eslint-disable-next-line no-param-reassigncolor = 'transparent';}- props.switchLocationType(props.openedEntry.locationId).then((currentLocationId) => {- Pro.MetaOperations.saveColor(currentEntry.path, color)- .then(entryMeta => {- // if (props.entryPath === props.currentDirectoryPath) {- props.updateOpenedFile(currentEntry.path, entryMeta);- props.switchCurrentLocationType(currentLocationId);- /* } else {+ props+ .switchLocationType(props.openedEntry.locationId)+ .then(currentLocationId => {+ Pro.MetaOperations.saveColor(currentEntry.path, color)+ .then(entryMeta => {+ // if (props.entryPath === props.currentDirectoryPath) {+ props.updateOpenedFile(currentEntry.path, entryMeta);+ props.switchCurrentLocationType(currentLocationId);+ /* } else {setCurrentEntry({ ...currentEntry, color });} */- return true;- })- .catch(error => {- props.switchCurrentLocationType(currentLocationId);- console.warn('Error saving color for folder ' + error);- props.showNotification(i18n.t('Error saving color for folder'));- });- });+ return true;+ })+ .catch(error => {+ props.switchCurrentLocationType(currentLocationId);+ console.warn('Error saving color for folder ' + error);+ props.showNotification(i18n.t('Error saving color for folder'));+ });+ });};const handleFileNameChange = (event: ChangeEvent<HTMLInputElement>) => {@@ -499,40 +507,44 @@ function EntryProperties(props: Props) {};*/const handleChange = (name: string, value: Array<TS.Tag>, action: string) => {- props.switchLocationType(props.openedEntry.locationId).then((currentLocationId) => {- 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+ .switchLocationType(props.openedEntry.locationId)+ .then(currentLocationId => {+ 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(currentLocationId);+ });+ });+ } else {+ props.removeTags([currentEntry.path], value).then(() => {props.switchCurrentLocationType(currentLocationId);});+ }+ } else if (action === 'clear') {+ props.removeAllTags([currentEntry.path]).then(() => {+ props.switchCurrentLocationType(currentLocationId);});} else {- props.removeTags([currentEntry.path], value).then(() => {+ // 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(currentLocationId);});}- } else if (action === 'clear') {- props.removeAllTags([currentEntry.path]).then(() => {- props.switchCurrentLocationType(currentLocationId);- });- } else {- // 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(currentLocationId);- });- }- });+ });};const { classes, isReadOnlyMode, theme, sharingLink } = props;