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