fix total user count in syncshell (distinct by UIDs)
This commit is contained in:
		| @@ -8,16 +8,16 @@ namespace MareSynchronos.UI.Components; | |||||||
|  |  | ||||||
| public abstract class DrawFolderBase : IDrawFolder | public abstract class DrawFolderBase : IDrawFolder | ||||||
| { | { | ||||||
|     protected readonly IEnumerable<DrawUserPair> _drawPairs; |     public IEnumerable<DrawUserPair> DrawPairs { get; private set; } | ||||||
|     protected readonly string _id; |     protected readonly string _id; | ||||||
|     protected readonly TagHandler _tagHandler; |     protected readonly TagHandler _tagHandler; | ||||||
|     private float _menuWidth = -1; |     private float _menuWidth = -1; | ||||||
|     public int OnlinePairs => _drawPairs.Count(u => u.Pair.IsOnline); |     public int OnlinePairs => DrawPairs.Count(u => u.Pair.IsOnline); | ||||||
|     public int TotalPairs { get; } |     public int TotalPairs { get; } | ||||||
|     protected DrawFolderBase(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, int totalPairs) |     protected DrawFolderBase(string id, IEnumerable<DrawUserPair> drawPairs, TagHandler tagHandler, int totalPairs) | ||||||
|     { |     { | ||||||
|         _id = id; |         _id = id; | ||||||
|         _drawPairs = drawPairs; |         DrawPairs = drawPairs; | ||||||
|         _tagHandler = tagHandler; |         _tagHandler = tagHandler; | ||||||
|         TotalPairs = totalPairs; |         TotalPairs = totalPairs; | ||||||
|     } |     } | ||||||
| @@ -27,7 +27,7 @@ public abstract class DrawFolderBase : IDrawFolder | |||||||
|  |  | ||||||
|     public void Draw() |     public void Draw() | ||||||
|     { |     { | ||||||
|         if (!RenderIfEmpty && !_drawPairs.Any()) return; |         if (!RenderIfEmpty && !DrawPairs.Any()) return; | ||||||
|  |  | ||||||
|         using var id = ImRaii.PushId("folder_" + _id); |         using var id = ImRaii.PushId("folder_" + _id); | ||||||
|  |  | ||||||
| @@ -57,9 +57,9 @@ public abstract class DrawFolderBase : IDrawFolder | |||||||
|         if (_tagHandler.IsTagOpen(_id)) |         if (_tagHandler.IsTagOpen(_id)) | ||||||
|         { |         { | ||||||
|             using var indent = ImRaii.PushIndent(20f); |             using var indent = ImRaii.PushIndent(20f); | ||||||
|             if (_drawPairs.Any()) |             if (DrawPairs.Any()) | ||||||
|             { |             { | ||||||
|                 foreach (var item in _drawPairs) |                 foreach (var item in DrawPairs) | ||||||
|                 { |                 { | ||||||
|                     item.DrawPairedClient(); |                     item.DrawPairedClient(); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ public class DrawFolderGroup : DrawFolderBase | |||||||
|         if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true)) |         if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true)) | ||||||
|         { |         { | ||||||
|             ImGui.CloseCurrentPopup(); |             ImGui.CloseCurrentPopup(); | ||||||
|             ImGui.SetClipboardText(UiSharedService.GetNotes(_drawPairs.Select(k => k.Pair).ToList())); |             ImGui.SetClipboardText(UiSharedService.GetNotes(DrawPairs.Select(k => k.Pair).ToList())); | ||||||
|         } |         } | ||||||
|         UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> Privacy -> Import Notes from Clipboard"); |         UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> Privacy -> Import Notes from Clipboard"); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ public class DrawFolderTag : DrawFolderBase | |||||||
|         TagHandler.CustomAllTag => false, |         TagHandler.CustomAllTag => false, | ||||||
|         TagHandler.CustomOfflineSyncshellTag => false, |         TagHandler.CustomOfflineSyncshellTag => false, | ||||||
|         _ => true, |         _ => true, | ||||||
|     } && _drawPairs.Any(); |     } && DrawPairs.Any(); | ||||||
|  |  | ||||||
|     private bool RenderCount => _id switch |     private bool RenderCount => _id switch | ||||||
|     { |     { | ||||||
| @@ -135,7 +135,7 @@ public class DrawFolderTag : DrawFolderBase | |||||||
|     { |     { | ||||||
|         if (!RenderPause) return currentRightSideX; |         if (!RenderPause) return currentRightSideX; | ||||||
|  |  | ||||||
|         var allArePaused = _drawPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused()); |         var allArePaused = DrawPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused()); | ||||||
|         var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; |         var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; | ||||||
|         var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X; |         var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X; | ||||||
|  |  | ||||||
| @@ -145,11 +145,11 @@ public class DrawFolderTag : DrawFolderBase | |||||||
|         { |         { | ||||||
|             if (allArePaused) |             if (allArePaused) | ||||||
|             { |             { | ||||||
|                 ResumeAllPairs(_drawPairs); |                 ResumeAllPairs(DrawPairs); | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 PauseRemainingPairs(_drawPairs); |                 PauseRemainingPairs(DrawPairs); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         if (allArePaused) |         if (allArePaused) | ||||||
|   | |||||||
| @@ -9,7 +9,8 @@ public class DrawGroupedGroupFolder : IDrawFolder | |||||||
| { | { | ||||||
|     private readonly IEnumerable<IDrawFolder> _groups; |     private readonly IEnumerable<IDrawFolder> _groups; | ||||||
|     private readonly TagHandler _tagHandler; |     private readonly TagHandler _tagHandler; | ||||||
|     public int OnlinePairs => _groups.Sum(g => g.OnlinePairs); |     public IEnumerable<DrawUserPair> DrawPairs => throw new NotSupportedException(); | ||||||
|  |     public int OnlinePairs => _groups.SelectMany(g => g.DrawPairs).Where(g => g.Pair.IsOnline).DistinctBy(g => g.UID).Count(); | ||||||
|     public int TotalPairs => _groups.Sum(g => g.TotalPairs); |     public int TotalPairs => _groups.Sum(g => g.TotalPairs); | ||||||
|  |  | ||||||
|     public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler) |     public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler) | ||||||
|   | |||||||
| @@ -1,8 +1,11 @@ | |||||||
| namespace MareSynchronos.UI.Components; |  | ||||||
|  | namespace MareSynchronos.UI.Components; | ||||||
|  |  | ||||||
| public interface IDrawFolder | public interface IDrawFolder | ||||||
| { | { | ||||||
|     int TotalPairs { get; } |     int TotalPairs { get; } | ||||||
|     int OnlinePairs { get; } |     int OnlinePairs { get; } | ||||||
|  |     IEnumerable<DrawUserPair> DrawPairs { get; } | ||||||
|  |  | ||||||
|     void Draw(); |     void Draw(); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon