Fixed deleting of syncshell tags
This commit is contained in:
@@ -347,10 +347,7 @@ public class ServerConfigurationManager
|
||||
_syncshellTagConfig.Save();
|
||||
}
|
||||
|
||||
internal bool ContainsOpenPairTag(string tag)
|
||||
{
|
||||
return CurrentPairTagStorage().OpenPairTags.Contains(tag);
|
||||
}
|
||||
internal bool ContainsOpenPairTag(string tag) => CurrentPairTagStorage().OpenPairTags.Contains(tag);
|
||||
|
||||
internal bool ContainsPairTag(string uid, string tag)
|
||||
{
|
||||
@@ -405,40 +402,19 @@ public class ServerConfigurationManager
|
||||
return null;
|
||||
}
|
||||
|
||||
internal HashSet<string> GetServerAvailablePairTags()
|
||||
{
|
||||
return CurrentPairTagStorage().ServerAvailablePairTags;
|
||||
}
|
||||
internal HashSet<string> GetServerAvailablePairTags() => CurrentPairTagStorage().ServerAvailablePairTags;
|
||||
|
||||
internal HashSet<string> GetServerAvailableSyncshellTags()
|
||||
{
|
||||
return CurrentSyncshellTagStorage().ServerAvailableSyncshellTags;
|
||||
}
|
||||
internal HashSet<string> GetServerAvailableSyncshellTags() => CurrentSyncshellTagStorage().ServerAvailableSyncshellTags;
|
||||
|
||||
internal Dictionary<string, List<string>> GetUidServerPairedUserTags()
|
||||
{
|
||||
return CurrentPairTagStorage().UidServerPairedUserTags;
|
||||
}
|
||||
internal Dictionary<string, List<string>> GetUidServerPairedUserTags() => CurrentPairTagStorage().UidServerPairedUserTags;
|
||||
|
||||
internal HashSet<string> GetUidsForPairTag(string tag)
|
||||
{
|
||||
return CurrentPairTagStorage().UidServerPairedUserTags.Where(p => p.Value.Contains(tag, StringComparer.Ordinal)).Select(p => p.Key).ToHashSet(StringComparer.Ordinal);
|
||||
}
|
||||
internal HashSet<string> GetUidsForPairTag(string tag) => CurrentPairTagStorage().UidServerPairedUserTags.Where(p => p.Value.Contains(tag, StringComparer.Ordinal)).Select(p => p.Key).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
internal HashSet<string> GetNamesForSyncshellTag(string tag)
|
||||
{
|
||||
return CurrentSyncshellTagStorage().SyncshellPairedTags.Where(p => p.Value.Contains(tag, StringComparer.Ordinal)).Select(p => p.Key).ToHashSet(StringComparer.Ordinal);
|
||||
}
|
||||
internal HashSet<string> GetNamesForSyncshellTag(string tag) => CurrentSyncshellTagStorage().SyncshellPairedTags.Where(p => p.Value.Contains(tag, StringComparer.Ordinal)).Select(p => p.Key).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
internal bool HasPairTags(string uid)
|
||||
{
|
||||
return CurrentPairTagStorage().UidServerPairedUserTags.TryGetValue(uid, out var tags) && tags.Count != 0;
|
||||
}
|
||||
internal bool HasPairTags(string uid) => CurrentPairTagStorage().UidServerPairedUserTags.TryGetValue(uid, out var tags) && tags.Count != 0;
|
||||
|
||||
internal bool HasSyncshellTags(string name)
|
||||
{
|
||||
return CurrentSyncshellTagStorage().SyncshellPairedTags.TryGetValue(name, out var tags) && tags.Count != 0;
|
||||
}
|
||||
internal bool HasSyncshellTags(string name) => CurrentSyncshellTagStorage().SyncshellPairedTags.TryGetValue(name, out var tags) && tags.Count != 0;
|
||||
|
||||
internal void RemoveCharacterFromServer(int serverSelectionIndex, Authentication item)
|
||||
{
|
||||
@@ -468,18 +444,29 @@ public class ServerConfigurationManager
|
||||
|
||||
internal void RemoveSyncshellTag(string tag)
|
||||
{
|
||||
RemoveTag(CurrentSyncshellTagStorage().ServerAvailableSyncshellTags, tag);
|
||||
RemoveTag(CurrentSyncshellTagStorage().ServerAvailableSyncshellTags, tag, true);
|
||||
_syncshellTagConfig.Save();
|
||||
_lightlessMediator.Publish(new RefreshUiMessage());
|
||||
}
|
||||
|
||||
internal void RemoveTag(HashSet<string> storage, string tag)
|
||||
internal void RemoveTag(HashSet<string> storage, string tag, bool syncshell = false)
|
||||
{
|
||||
CurrentPairTagStorage().ServerAvailablePairTags.Remove(tag);
|
||||
foreach (var uid in GetUidsForPairTag(tag))
|
||||
storage.Remove(tag);
|
||||
if (syncshell)
|
||||
{
|
||||
RemoveTagForUid(uid, tag, save: false);
|
||||
foreach (var uid in GetNamesForSyncshellTag(tag))
|
||||
{
|
||||
RemoveTagForSyncshell(uid, tag, save: false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var uid in GetUidsForPairTag(tag))
|
||||
{
|
||||
RemoveTagForUid(uid, tag, save: false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal void RemoveTagForUid(string uid, string tagName, bool save = true)
|
||||
@@ -510,15 +497,9 @@ public class ServerConfigurationManager
|
||||
}
|
||||
}
|
||||
|
||||
internal void RenamePairTag(string oldName, string newName)
|
||||
{
|
||||
RenameTag(CurrentPairTagStorage().UidServerPairedUserTags, CurrentPairTagStorage().ServerAvailablePairTags, oldName, newName);
|
||||
}
|
||||
internal void RenamePairTag(string oldName, string newName) => RenameTag(CurrentPairTagStorage().UidServerPairedUserTags, CurrentPairTagStorage().ServerAvailablePairTags, oldName, newName);
|
||||
|
||||
internal void RenameSyncshellTag(string oldName, string newName)
|
||||
{
|
||||
RenameTag(CurrentSyncshellTagStorage().SyncshellPairedTags, CurrentSyncshellTagStorage().ServerAvailableSyncshellTags, oldName, newName);
|
||||
}
|
||||
internal void RenameSyncshellTag(string oldName, string newName) => RenameTag(CurrentSyncshellTagStorage().SyncshellPairedTags, CurrentSyncshellTagStorage().ServerAvailableSyncshellTags, oldName, newName);
|
||||
|
||||
internal void RenameTag(Dictionary<string, List<string>> tags, HashSet<string> storage, string oldName, string newName)
|
||||
{
|
||||
@@ -532,10 +513,7 @@ public class ServerConfigurationManager
|
||||
_lightlessMediator.Publish(new RefreshUiMessage());
|
||||
}
|
||||
|
||||
internal void SaveNotes()
|
||||
{
|
||||
_notesConfig.Save();
|
||||
}
|
||||
internal void SaveNotes() => _notesConfig.Save();
|
||||
|
||||
internal void SetNoteForGid(string gid, string note, bool save = true)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DrawGroupedSyncshellTagFolder : IDrawFolder
|
||||
string _id = $"__folder_{_tag}";
|
||||
using var id = ImRaii.PushId(_id);
|
||||
var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered);
|
||||
using (ImRaii.Child("folder__" + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
using (ImRaii.Child("folder__" + _id, new Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
{
|
||||
ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight()));
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 0f)))
|
||||
@@ -122,9 +122,8 @@ public class DrawGroupedSyncshellTagFolder : IDrawFolder
|
||||
}
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell Group", menuWidth, isInPopup: true) && UiSharedService.CtrlPressed())
|
||||
{
|
||||
_tagHandler.RemovePairTag(_tag);
|
||||
_tagHandler.RemoveSyncshellTag(_tag);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently." + Environment.NewLine +
|
||||
"Note: this will not unpair with users in this Group.");
|
||||
UiSharedService.AttachToolTip("Hold CTRL to remove this Group permanently.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user