Skip to content

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

fix: loading location tags broken in some cases, fixing setting findability in tab general of the settings

Ilian Sapundshiev93c329f02800
diff --git a/src/renderer/components/dialogs/components/SettingsGeneral.tsx b/src/renderer/components/dialogs/components/SettingsGeneral.tsx
index e316a8bd6..735079b55 100644
--- a/src/renderer/components/dialogs/components/SettingsGeneral.tsx
+++ b/src/renderer/components/dialogs/components/SettingsGeneral.tsx
@@ -656,6 +656,10 @@ function SettingsGeneral() {
},
{
label: t('core:fileTaggingSetting'),
+ description:
+ t('core:tagsInFilenameExplanation') +
+ ' ' +
+ t('core:tagsInSidecarFileExplanation'),
jsx: (
<ListItem
title={
@@ -724,6 +728,10 @@ function SettingsGeneral() {
},
!persistTagsInSidecarFile && {
label: t('core:fileNameTagSetting'),
+ description:
+ t('core:fileNameBeginTagPlaceExplanation') +
+ ' ' +
+ t('core:fileNameEndTagPlaceExplanation'),
jsx: (
<ListItem
title={
@@ -1030,6 +1038,7 @@ function SettingsGeneral() {
},
AppConfig.isElectron && {
label: t('core:useTrashCan'),
+ description: t('core:useTrashCanInfo'),
jsx: (
<ListItem>
<ListItemText
@@ -1070,6 +1079,7 @@ function SettingsGeneral() {
},
{
label: t('core:showSymbolicLinks'),
+ description: t('core:showSymbolicLinksInfo'),
jsx: (
<ListItem>
<ListItemText
@@ -1176,6 +1186,7 @@ function SettingsGeneral() {
},
devMode && {
label: t('core:tagDelimiter'),
+ description: t('core:tagDelimiterInfo'),
jsx: (
<ListItem>
<ListItemText
@@ -1217,6 +1228,7 @@ function SettingsGeneral() {
},
{
label: t('core:prefixTagContainer'),
+ description: t('core:prefixTagContainerInfo'),
jsx: (
<ListItem>
<ListItemText
@@ -1264,6 +1276,7 @@ function SettingsGeneral() {
},
{
label: t('core:author'),
+ description: t('core:authorVariableTooltip'),
jsx: (
<ListItem>
<ListItemText
@@ -1311,6 +1324,7 @@ function SettingsGeneral() {
},
{
label: t('core:setRevisionsEnabled'),
+ description: t('core:setRevisionsEnabledHelp'),
jsx: (
<ListItem>
<ListItemText
@@ -1334,7 +1348,8 @@ function SettingsGeneral() {
),
},
{
- label: t('core:settingExternallyConfigured'),
+ label: t('enableTagsFromLocation'),
+ description: t('core:enableTagsFromLocationHelp'),
jsx: (
<ListItem
title={
@@ -1678,6 +1693,7 @@ function SettingsGeneral() {
},
{
label: t('enableDevMode'),
+ description: t('core:devModeTooltip'),
jsx: (
<ListItem>
<ListItemText
@@ -1699,6 +1715,7 @@ function SettingsGeneral() {
},
{
label: t('core:encryptCredentialsAtRest'),
+ description: t('core:encryptCredentialsAtRestTooltip'),
jsx: (
<ListItem
title={
@@ -1801,12 +1818,15 @@ function SettingsGeneral() {
],
);
- // Filter settings by label and description
+ // Filter settings by label and description (the latter mirrors each row's
+ // help tooltip so users can search by the explanatory text too).
const filteredSettings = useMemo(() => {
if (!filterText.trim()) return settingsItems;
const lowerFilter = filterText.toLowerCase();
return settingsItems.filter((item) =>
- item.label.toLowerCase().includes(lowerFilter),
+ (item.label + ' ' + (item.description || ''))
+ .toLowerCase()
+ .includes(lowerFilter),
);
}, [filterText, settingsItems]);
diff --git a/src/renderer/hooks/EditedTagLibraryContextProvider.tsx b/src/renderer/hooks/EditedTagLibraryContextProvider.tsx
index 699094986..df0d08cb5 100644
--- a/src/renderer/hooks/EditedTagLibraryContextProvider.tsx
+++ b/src/renderer/hooks/EditedTagLibraryContextProvider.tsx
@@ -63,9 +63,19 @@ export const EditedTagLibraryContextProvider = ({
const instanceId = useRef<string>(getUuid());
const broadcast = useMemo(() => new BroadcastChannel('tag-library-sync'), []);
+ // Re-run when getTagsFromLocations changes too: it changes identity once the
+ // locations finish loading on startup, which is what lets the location tag
+ // groups merge in on first launch (not only after a second window opened).
useEffect(() => {
refreshTagLibrary();
- }, [saveTagInLocation]);
+ }, [saveTagInLocation, getTagsFromLocations]);
+
+ // The broadcast handler is registered once (the channel is created/closed
+ // once), so route it through a ref to always call the current
+ // refreshTagLibrary — otherwise it would invoke the first-render closure,
+ // which captured the pre-rehydration saveTagInLocation and empty locations.
+ const refreshRef = useRef(refreshTagLibrary);
+ refreshRef.current = refreshTagLibrary;
// Listen for incoming broadcasts
useEffect(() => {
@@ -75,7 +85,7 @@ export const EditedTagLibraryContextProvider = ({
if (action.uuid === instanceId.current) return;
if (action.type === 'tagLibraryChanged') {
- refreshTagLibrary(true);
+ refreshRef.current(true);
}
};
// clean up on unmount
@@ -122,7 +132,10 @@ export const EditedTagLibraryContextProvider = ({
broadcast: broadcast,
setTagGroups,
reflectTagLibraryChanged,
- refreshTagLibrary,
+ // Via the ref so the manual "Refresh tag library" action always runs the
+ // current closure (latest saveTagInLocation / locations), not the one
+ // captured the last time `tagGroups` changed.
+ refreshTagLibrary: (force?: boolean) => refreshRef.current(force),
};
}, [tagGroups]);
diff --git a/src/renderer/hooks/TagGroupsLocationContextProvider.tsx b/src/renderer/hooks/TagGroupsLocationContextProvider.tsx
index bada0ea43..72dd5f779 100644
--- a/src/renderer/hooks/TagGroupsLocationContextProvider.tsx
+++ b/src/renderer/hooks/TagGroupsLocationContextProvider.tsx
@@ -407,7 +407,13 @@ export const TagGroupsLocationContextProvider = ({
loadLocationDataPromise,
getTagsFromLocations,
};
- }, [saveTagInLocation]);
+ // `locations` must be a dependency: getTagsFromLocations closes over it, and
+ // on first launch locations populate (async Redux rehydration) AFTER this
+ // provider first renders. Without it the closure stays bound to the empty
+ // initial array, so location tag groups never load until something else
+ // (e.g. a second window) rebuilds the context. Its identity changes when
+ // CurrentLocationContext reassigns allLocations.current.
+ }, [saveTagInLocation, locations]);
return (
<TagGroupsLocationContext.Provider value={context}>