TagSpaces is an offline, open source, document manager with tagging support
fix props reload (#1207)
Stanimir31bdb5d6dd86
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 2719fb156..c8b7fadda 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -773,18 +773,16 @@ class EntryContainer extends React.Component<Props, State> {renderFileToolbar = classes => (<div className={classes.toolbar2}><div className={classes.flexLeft}>- {this.state.currentEntry.isFile && (- <IconButton- title={i18n.t('core:toggleProperties')}- aria-label={i18n.t('core:toggleProperties')}- onClick={this.togglePanel}- data-tid="fileContainerToggleProperties"- >- <DetailsIcon- color={this.state.isPropertiesPanelVisible ? 'primary' : 'action'}- />- </IconButton>- )}+ <IconButton+ title={i18n.t('core:toggleProperties')}+ aria-label={i18n.t('core:toggleProperties')}+ onClick={this.togglePanel}+ data-tid="fileContainerToggleProperties"+ >+ <DetailsIcon+ color={this.state.isPropertiesPanelVisible ? 'primary' : 'action'}+ />+ </IconButton><IconButtontitle={i18n.t('core:switchToFullscreen')}aria-label={i18n.t('core:switchToFullscreen')}@@ -926,16 +924,6 @@ class EntryContainer extends React.Component<Props, State> {renderFolderToolbar = () => (<div className={this.props.classes.toolbar2}><div className={this.props.classes.flexLeft}>- <IconButton- title={i18n.t('core:toggleProperties')}- aria-label={i18n.t('core:toggleProperties')}- onClick={this.togglePanel}- data-tid="fileContainerToggleProperties"- >- <DetailsIcon- color={this.state.isPropertiesPanelVisible ? 'primary' : 'action'}- />- </IconButton>{!(PlatformIO.haveObjectStoreSupport() || AppConfig.isWeb) && (<IconButtontitle={i18n.t('core:openDirectoryExternally')}diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex deb43ad68..0dca43083 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -230,6 +230,8 @@ class EntryProperties extends Component<Props, State> {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 !!) {// eslint-disable-next-line react/destructuring-assignmentthis.props.resetState('EntryPropertiesKey');@@ -518,21 +520,31 @@ class EntryProperties extends Component<Props, State> {if (!value) {// no tags left in the select elementthis.props.removeAllTags([this.state.path]);+ this.setState({ tags: [] });} else {- this.state.tags.map(tag => {+ const { tags } = this.state;+ const tagsToRemove = [];+ const newTags = tags.map(tag => {if (value.findIndex(obj => obj.title === tag.title) === -1) {- this.props.removeTags([this.state.path], [tag]);+ tagsToRemove.push(tag);+ return undefined;}- return true;+ return tag;});++ this.props.removeTags([this.state.path], tagsToRemove);+ this.setState({ tags: newTags.filter(tag => tag !== undefined) });}} else if (action === 'clear') {this.props.removeAllTags([this.state.path]);+ this.setState({ tags: [] });} else {// create-option or select-option+ const { tags } = this.state;value.map(tag => {if (this.state.tags.findIndex(obj => obj.title === tag.title) === -1) {this.props.addTags([this.state.path], [tag]);+ this.setState({ tags: [...tags, tag] });}return true;});