diff --git a/Blacklight/Views/MainWindow.axaml b/Blacklight/Views/MainWindow.axaml index f835523f6d0e5f40263231284711536d5353b088..6b12f563ea5e99e9079331d649fa3f6b27dfb341 100644 --- a/Blacklight/Views/MainWindow.axaml +++ b/Blacklight/Views/MainWindow.axaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:login="clr-namespace:Blacklight.Views.Login" xmlns:util="clr-namespace:Blacklight.Util" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" d:DesignWidth="1100" d:DesignHeight="700" x:Class="Blacklight.Views.MainWindow" x:DataType="vm:MainWindowViewModel" Icon="/Assets/avalonia-logo.ico" diff --git a/Lightquark.NET/ClientMethods/Message.cs b/Lightquark.NET/ClientMethods/Message.cs index ef3fd7c30d6c1eed8bc26a429e5f279ae6fb12c2..c35945b513af75d6063a1a6ec8d7b353390c361a 100644 --- a/Lightquark.NET/ClientMethods/Message.cs +++ b/Lightquark.NET/ClientMethods/Message.cs @@ -79,47 +79,43 @@ public partial class Client foreach (var msg in res.Response.Messages) { var replyAttribute = msg.SpecialAttributes.FirstOrDefault(a => a["type"]?.ToString() == "reply"); - if (replyAttribute != null) + if (replyAttribute == null) continue; + if (!ObjectId.TryParse(replyAttribute["replyTo"]?.ToString(), out var replyToId)) continue; + var replyToMsg = res.Response.Messages.FirstOrDefault(m => m.Id == replyToId); + if (replyToMsg == null) { - if (ObjectId.TryParse(replyAttribute["replyTo"]?.ToString(), out var replyToId)) + replyToMsg = Messages[channelId].FirstOrDefault(m => m.Id == replyToId); + if (replyToMsg == null) { - var replyToMsg = res.Response.Messages.FirstOrDefault(m => m.Id == replyToId); - if (replyToMsg == null) + var replyRes = await CallRpc<GetMessageResponse>("GET", $"{Version}/channel/{channelId}/messages/{replyToId}"); + if (replyRes.Request.Success) { - replyToMsg = Messages[channelId].FirstOrDefault(m => m.Id == replyToId); - if (replyToMsg == null) - { - var replyRes = await CallRpc<GetMessageResponse>("GET", $"{Version}/channel/{channelId}/messages/{replyToId}"); - if (replyRes.Request.Success) - { - Log.Information("Reply message found via API"); - replyToMsg = replyRes.Response.Data; - } - else - { - Log.Error("Couldn't fetch reply message {ReplyMsgId} due to {Reason}", replyToId, replyRes.Response.Message); - replyToMsg = new Message - { - Id = replyToId, - Author = CurrentUser, - Content = "Message couldn't be loaded", - Status = MessageStatus.Fail - }; - } - } - else - { - Log.Information("Reply message found in cache"); - } + Log.Information("Reply message found via API"); + replyToMsg = replyRes.Response.Data; } else { - Log.Information("Reply message found in fetched messages"); + Log.Error("Couldn't fetch reply message {ReplyMsgId} due to {Reason}", replyToId, replyRes.Response.Message); + replyToMsg = new Message + { + Id = replyToId, + Author = CurrentUser, + Content = "Message couldn't be loaded", + Status = MessageStatus.Fail + }; } - - msg.ReplyToMessage = replyToMsg; + } + else + { + Log.Information("Reply message found in cache"); } } + else + { + Log.Information("Reply message found in fetched messages"); + } + + msg.ReplyToMessage = replyToMsg; } return res.Response.Messages;