From bd771377143653f02307d73c906ad8a313acc944 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 18 Aug 2025 01:39:33 +0800 Subject: [PATCH] :bug: Fixes of withStatus --- .../Chat/ChatRoomController.cs | 19 ++++++------------- DysonNetwork.Sphere/Realm/RealmController.cs | 11 ++--------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/DysonNetwork.Sphere/Chat/ChatRoomController.cs b/DysonNetwork.Sphere/Chat/ChatRoomController.cs index 1199a94..5ad58e1 100644 --- a/DysonNetwork.Sphere/Chat/ChatRoomController.cs +++ b/DysonNetwork.Sphere/Chat/ChatRoomController.cs @@ -487,8 +487,7 @@ public class ChatRoomController( public async Task>> ListMembers(Guid roomId, [FromQuery] int take = 20, [FromQuery] int offset = 0, - [FromQuery] bool withStatus = false, - [FromQuery] string? status = null + [FromQuery] bool withStatus = false ) { var currentUser = HttpContext.Items["CurrentUser"] as Account; @@ -519,18 +518,12 @@ public class ChatRoomController( members.Select(m => m.AccountId).ToList() ); - if (!string.IsNullOrEmpty(status)) - { - members = members - .Select(m => - { - m.Status = memberStatuses.TryGetValue(m.AccountId, out var s) ? s : null; - return m; - }) - .ToList(); - } - members = members + .Select(m => + { + m.Status = memberStatuses.TryGetValue(m.AccountId, out var s) ? s : null; + return m; + }) .OrderByDescending(m => m.Status?.IsOnline ?? false) .ToList(); diff --git a/DysonNetwork.Sphere/Realm/RealmController.cs b/DysonNetwork.Sphere/Realm/RealmController.cs index a313152..dd6206f 100644 --- a/DysonNetwork.Sphere/Realm/RealmController.cs +++ b/DysonNetwork.Sphere/Realm/RealmController.cs @@ -216,8 +216,7 @@ public class RealmController( string slug, [FromQuery] int offset = 0, [FromQuery] int take = 20, - [FromQuery] bool withStatus = false, - [FromQuery] string? status = null + [FromQuery] bool withStatus = false ) { var realm = await db.Realms @@ -246,20 +245,14 @@ public class RealmController( members.Select(m => m.AccountId).ToList() ); - if (!string.IsNullOrEmpty(status)) - { members = members .Select(m => { m.Status = memberStatuses.TryGetValue(m.AccountId, out var s) ? s : null; return m; }) + .OrderByDescending(m => m.Status?.IsOnline ?? false) .ToList(); - } - - members = members - .OrderByDescending(m => m.Status?.IsOnline ?? false) - .ToList(); var total = members.Count; Response.Headers.Append("X-Total", total.ToString());