Skip to content

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

fix edit tag group

sytolk707162b1b638
diff --git a/src/renderer/components/dialogs/EditTagGroupDialog.tsx b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
index 1621bb4ac..853c14f0e 100644
--- a/src/renderer/components/dialogs/EditTagGroupDialog.tsx
+++ b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
@@ -104,21 +104,30 @@ function EditTagGroupDialog(props: Props) {
const disableConfirmButton = () => inputError;
- const onConfirm = () => {
+ function isLocationChanged() {
+ return (
+ newLocationId !== undefined &&
+ newLocationId !== selectedTagGroupEntry.locationId
+ );
+ }
+
+ const onConfirm = async () => {
if (disableConfirmButton()) {
return;
}
if (selectedTagGroupEntry && selectedTagGroupEntry.children) {
- if (Pro && newLocationId === undefined) {
+ if (
+ Pro &&
+ isLocationChanged() &&
+ selectedTagGroupEntry.locationId !== undefined
+ ) {
// remove old location
- if (selectedTagGroupEntry.locationId) {
- const location: CommonLocation = findLocation(
- selectedTagGroupEntry.locationId,
- );
- if (location) {
- removeLocationTagGroup(location, selectedTagGroupEntry.uuid);
- }
+ const location: CommonLocation = findLocation(
+ selectedTagGroupEntry.locationId,
+ );
+ if (location) {
+ await removeLocationTagGroup(location, selectedTagGroupEntry.uuid);
}
}
updateTagGroup({
@@ -126,7 +135,12 @@ function EditTagGroupDialog(props: Props) {
title,
color,
textcolor,
- locationId: newLocationId,
+ ...(isLocationChanged() && {
+ locationId:
+ newLocationId === defaultTagGroupLocation
+ ? undefined
+ : newLocationId,
+ }),
modified_date: new Date().getTime(),
children: selectedTagGroupEntry.children.map((tag) => ({
...tag,
@@ -185,10 +199,7 @@ function EditTagGroupDialog(props: Props) {
selectedTagGroupEntry.locationId || defaultTagGroupLocation
}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
- const locationId = event.target.value;
- setNewLocationId(
- locationId === defaultTagGroupLocation ? undefined : locationId,
- );
+ setNewLocationId(event.target.value);
}}
>
<MenuItem
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index 8e637044b..624776571 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -772,7 +772,7 @@ export function mergeFsEntryMeta(props: any = {}): TS.FileSystemEntryMeta {
appVersion: versionMeta.version,
description: '',
lastUpdated: new Date().getTime(),
- tags: [],
+ ...(!props.tagGroups && { tags: [] }),
...props,
id: props.id || getUuid(),
};