TagSpaces is an offline, open source, document manager with tagging support
thumb replace and fixes
Stanimir Marinovc29623cc2f3d
diff --git a/app/components/EntryProperties.js b/app/components/EntryProperties.jsindex 0203b117f..b1ac97c0d 100644--- a/app/components/EntryProperties.js+++ b/app/components/EntryProperties.js@@ -41,6 +41,7 @@ import AppConfig from '../config';import { Pro } from '../pro';import TagsSelect from './TagsSelect';import TransparentBackground from './TransparentBackground';+import { replaceThumbnailURLPromise } from '../services/thumbsgenerator';const styles = theme => ({entryProperties: {@@ -387,6 +388,15 @@ 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);+ });+ };+saveEditDescription = () => {this.setState({ isEditDescription: false });};@@ -418,7 +428,7 @@ class EntryProperties extends Component<Props, State> {this.props.showNotification(i18n.t('Error saving color for folder'));});});- }+ };handleTagMenu = (event: Object, tag, tagGroup) => {this.setState({@@ -485,12 +495,13 @@ class EntryProperties extends Component<Props, State> {isMoveCopyFilesDialogOpened,isFileThumbChooseDialogOpened} = this.state;+ let { thumbPath } = this.state;if (!path || path === '') {return <div />;}- const thumbPath = getThumbFileLocationForFile(path);- let thumbPathUrl = thumbPath ? 'url("' + thumbPath + '")' : '';+ if (thumbPath === undefined) thumbPath = getThumbFileLocationForFile(path);+ let thumbPathUrl = thumbPath ? 'url("' + thumbPath + '?' + new Date().getTime() + '")' : '';if (AppConfig.isWin) {thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');}@@ -822,6 +833,7 @@ class EntryProperties extends Component<Props, State> {open={isFileThumbChooseDialogOpened}onClose={this.toggleThumbFilesDialog}selectedFile={thumbPath}+ setThumb={this.setThumb}/></div>);diff --git a/app/components/dialogs/FileThumbChooseDialog.js b/app/components/dialogs/FileThumbChooseDialog.jsindex 7b409567c..0573d8fb4 100644--- a/app/components/dialogs/FileThumbChooseDialog.js+++ b/app/components/dialogs/FileThumbChooseDialog.js@@ -44,6 +44,7 @@ type Props = {classes: Object,open: boolean,onClose: () => void,+ setThumb: () => void,selectedFile: string};@@ -68,7 +69,7 @@ const FileThumbChooseDialog = (props: Props) => {function handleSetThumb() {if (!disableConfirmButton) {- // props.setThumb(props.selectedFile, targetPath);+ props.setThumb(targetPath, props.selectedFile);setInputError(false);setDisableConfirmButton(true);setTargetPath('');diff --git a/app/services/thumbsgenerator.js b/app/services/thumbsgenerator.jsindex 202b9ba75..5740e8ddb 100644--- a/app/services/thumbsgenerator.js+++ b/app/services/thumbsgenerator.js@@ -139,6 +139,21 @@ export function getThumbnailURLPromise(filePath) {});}+export function replaceThumbnailURLPromise(filePath, thumbFilePath) {+ return new Promise((resolve) => {+ PlatformIO.getPropertiesPromise(filePath).then((origStats) => {+ createThumbnailPromise(filePath, origStats.size, thumbFilePath).then((tmbPath) => resolve({ filePath, tmbPath })).catch((err) => {+ console.warn('Thumb generation failed ' + err);+ resolve({ filePath, tmbPath: thumbFilePath });+ });+ return true;+ }).catch(err => {+ console.warn('Error getting file properties ' + err);+ resolve({ filePath });+ });+ });+}+export function createThumbnailPromise(filePath: string,fileSize: number,