From 27f276a3fe903c5c4e5493ba22ce4a95d30a3866 Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Thu, 17 Oct 2024 20:25:31 +0400 Subject: [PATCH] isolate tag updates for extclient and nodes --- logic/tags.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/logic/tags.go b/logic/tags.go index 9dd309eeb..cddcb7002 100644 --- a/logic/tags.go +++ b/logic/tags.go @@ -174,26 +174,32 @@ func UpdateTag(req models.UpdateTagReq, newID models.TagID) { node.Tags = make(map[models.TagID]struct{}) } if newID != "" { - node.Tags[newID] = struct{}{} - node.StaticNode.Tags[newID] = struct{}{} - } else { - node.Tags[req.ID] = struct{}{} - node.StaticNode.Tags[req.ID] = struct{}{} - } - if node.IsStatic { - SaveExtClient(&node.StaticNode) + if node.IsStatic { + node.StaticNode.Tags[newID] = struct{}{} + SaveExtClient(&node.StaticNode) + } else { + node.Tags[newID] = struct{}{} + UpsertNode(&node) + } + } else { - UpsertNode(&node) + if node.IsStatic { + node.StaticNode.Tags[req.ID] = struct{}{} + SaveExtClient(&node.StaticNode) + } else { + node.Tags[req.ID] = struct{}{} + UpsertNode(&node) + } } } else { if newID != "" { delete(node.Tags, req.ID) delete(node.StaticNode.Tags, req.ID) - node.StaticNode.Tags[newID] = struct{}{} - node.Tags[newID] = struct{}{} if node.IsStatic { + node.StaticNode.Tags[newID] = struct{}{} SaveExtClient(&node.StaticNode) } else { + node.Tags[newID] = struct{}{} UpsertNode(&node) } }