diff --git a/frontend/src/hooks/metadata-status.js b/frontend/src/hooks/metadata-status.js index 33bab1ec9a..3ad877450e 100644 --- a/frontend/src/hooks/metadata-status.js +++ b/frontend/src/hooks/metadata-status.js @@ -7,7 +7,7 @@ import { MetadataAIOperationsProvider } from './metadata-ai-operation'; // This hook provides content related to seahub interaction, such as whether to enable extended attributes const MetadataStatusContext = React.createContext(null); -export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, children }) => { +export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, updateUsedRepoTags, clearRepoTags, children }) => { const enableMetadataManagement = useMemo(() => { if (repoInfo?.encrypted) return false; return window.app.pageOptions.enableMetadataManagement; @@ -60,6 +60,9 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi if (!enableMetadata) { cancelMetadataURL(); } + if (enableTags) { + updateUsedRepoTags(); + } setEnableTags(enableTags); setTagsLang(tagsLang || 'en'); setDetailsSettings(JSON.parse(detailsSettings)); @@ -93,10 +96,12 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi if (newValue === enableTags && lang === tagsLang) return; if (!newValue) { cancelMetadataURL(true); + clearRepoTags(); } setEnableTags(newValue); + if (newValue) updateUsedRepoTags(); setTagsLang(lang); - }, [enableTags, tagsLang, cancelMetadataURL]); + }, [enableTags, tagsLang, cancelMetadataURL, clearRepoTags, updateUsedRepoTags]); const updateEnableOCR = useCallback((newValue) => { if (newValue === enableOCR) return; diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js index 1b8396c743..3498f72986 100644 --- a/frontend/src/pages/lib-content-view/lib-content-view.js +++ b/frontend/src/pages/lib-content-view/lib-content-view.js @@ -420,6 +420,14 @@ class LibContentView extends React.Component { }); }; + clearRepoTags = () => { + this.setState({ + fileTags: [], + repoTags: [], + usedRepoTags: [], + }); + }; + updateColumnMarkdownData = (filePath) => { let repoID = this.props.repoID; // update state @@ -454,9 +462,6 @@ class LibContentView extends React.Component { // load data loadDirData = (path) => { - // list used FileTags - this.updateUsedRepoTags(); - if (this.state.isTreePanelShown) { this.loadSidePanel(path); } @@ -2315,7 +2320,7 @@ class LibContentView extends React.Component { } const detailDirent = currentDirent || currentNode?.object || null; return ( - +