Skip to content

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

update Thumb in EntryContainer && fixes

Stanimir Marinovf0d0720195e0
diff --git a/app/components/EntryContainer.js b/app/components/EntryContainer.js
index 1939dc515..7b00721be 100644
--- a/app/components/EntryContainer.js
+++ b/app/components/EntryContainer.js
@@ -177,6 +177,7 @@ type Props = {
isReadOnlyMode: boolean,
setEntryPropertiesSplitSize: (size: number) => 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>
@@ -1132,6 +1133,7 @@ class EntryContainer extends React.Component<Props, State> {
removeTags={this.props.removeTags}
removeAllTags={this.props.removeAllTags}
reflectUpdateSidecarMeta={this.props.reflectUpdateSidecarMeta}
+ updateThumbnailUrl={this.props.updateThumbnailUrl}
showNotification={this.props.showNotification}
isReadOnlyMode={this.props.isReadOnlyMode}
/>
@@ -1194,6 +1196,7 @@ function mapActionCreatorsToProps(dispatch) {
removeAllTags: TaggingActions.removeAllTags,
editTagForEntry: TaggingActions.editTagForEntry,
reflectUpdateSidecarMeta: AppActions.reflectUpdateSidecarMeta,
+ updateThumbnailUrl: AppActions.updateThumbnailUrl,
setLastSelectedEntry: AppActions.setLastSelectedEntry,
setSelectedEntries: AppActions.setSelectedEntries,
}, dispatch);
diff --git a/app/components/EntryProperties.js b/app/components/EntryProperties.js
index 12f18d240..05a69f87f 100644
--- a/app/components/EntryProperties.js
+++ b/app/components/EntryProperties.js
@@ -42,7 +42,7 @@ import AppConfig from '../config';
import { Pro } from '../pro';
import TagsSelect from './TagsSelect';
import TransparentBackground from './TransparentBackground';
-import { replaceThumbnailURLPromise } from '../services/thumbsgenerator';
+import { replaceThumbnailURLPromise, getThumbnailURLPromise } from '../services/thumbsgenerator';
// import { actions as AppActions } from '../reducers/app';
const FileThumbChooseDialog = Pro && Pro.UI ? Pro.UI.FileThumbChooseDialog : false;
@@ -166,6 +166,7 @@ type Props = {
normalizeShouldCopyFile: () => void,
showNotification: () => void,
reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void,
+ updateThumbnailUrl: (path: string, thumbUrl: string) => void,
addTags: () => void,
removeTags: () => void,
removeAllTags: () => void,
@@ -394,13 +395,25 @@ class EntryProperties extends Component<Props, State> {
};
setThumb = (filePath, thumbFilePath) => {
- replaceThumbnailURLPromise(filePath, thumbFilePath).then((objUrl) => {
- this.setState({ thumbPath: objUrl.tmbPath });
- return true;
- }).catch(err => {
- console.warn('Error replaceThumbnailURLPromise ' + err);
- this.props.showNotification('Error replace Thumbnail');
- });
+ if (filePath !== undefined) {
+ replaceThumbnailURLPromise(filePath, thumbFilePath).then((objUrl) => {
+ this.setState({ thumbPath: objUrl.tmbPath });
+ this.props.updateThumbnailUrl(this.props.entryPath, objUrl.tmbPath);
+ return true;
+ }).catch(err => {
+ console.warn('Error replaceThumbnailURLPromise ' + err);
+ this.props.showNotification('Error replace Thumbnail');
+ });
+ } else { // reset Thumbnail
+ getThumbnailURLPromise(this.props.entryPath).then((objUrl) => {
+ this.setState({ thumbPath: objUrl.tmbPath });
+ this.props.updateThumbnailUrl(this.props.entryPath, objUrl.tmbPath);
+ return true;
+ }).catch(err => {
+ console.warn('Error getThumbnailURLPromise ' + err);
+ this.props.showNotification('Error reset Thumbnail');
+ });
+ }
};
saveEditDescription = () => {
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 097a9f45b..2cfaa2a26 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -412,5 +412,6 @@
"tagProperties": "Tag Properties",
"startContentExtraction": "Extract Content",
"thumbChooseFileTitle": "Thumb File Choose",
+ "clearThumbnail": "Clear Thumb",
"-": "-"
}
diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.js
index 93963110e..3752b163b 100644
--- a/app/perspectives/grid-perspective/src/index.js
+++ b/app/perspectives/grid-perspective/src/index.js
@@ -671,7 +671,7 @@ class GridPerspective extends React.Component<Props, State> {
supportedFileTypes
);
let thumbPathUrl = fsEntry.thumbPath
- ? 'url("' + fsEntry.thumbPath + '")'
+ ? 'url("' + fsEntry.thumbPath + '?' + new Date().getTime() + '")'
: '';
if (AppConfig.isWin) {
thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');