Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit dfc577d

Browse files
authored
Merge pull request #608 from UWPCommunity/rewrite/main
Alpha Release
2 parents b970277 + 38ead3f commit dfc577d

File tree

19 files changed

+173
-55
lines changed

19 files changed

+173
-55
lines changed

src/API/Discord.API/Rest/IChannelService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ internal interface IChannelService
1111
[Get("/v9/channels/{channelId}/messages?limit={limit}")]
1212
Task<JsonMessage[]> GetChannelMessages([AliasAs("channelId")] ulong channelId, [AliasAs("limit")] int limit = 50);
1313

14+
[Get("/v9/channels/{channelId}/messages?limit={limit}&before={before}")]
15+
Task<JsonMessage[]> GetChannelMessagesBefore([AliasAs("channelId")] ulong channelId, [AliasAs("before")] ulong before, [AliasAs("limit")] int limit = 50);
16+
1417
[Post("/v9/channels/{channelId}/messages")]
1518
Task<JsonMessage> CreateMessage([AliasAs("channelId")] ulong channelId, [Body] JsonMessageUpsert message);
1619
}

src/Libs/Quarrel.Markdown/Rendering/Elements/BlockQuoteElement.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Quarrel © 2022
22

33
using Quarrel.Markdown.Parsing;
4-
using Windows.UI.Xaml.Controls;
5-
using Windows.UI.Xaml.Documents;
64

75
namespace Quarrel.Markdown
86
{

src/Libs/Quarrel.Markdown/Rendering/Elements/InlineCodeElement.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Quarrel © 2022
22

3-
using Quarrel.Markdown.Parsing;
4-
using Windows.UI;
53
using Windows.UI.Xaml;
64
using Windows.UI.Xaml.Controls;
75
using Windows.UI.Xaml.Media;

src/Libs/Quarrel.Markdown/Rendering/Elements/UserMentionElement.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ internal UserMentionElement(UserMention mention, BindableMessage? context) : bas
3131

3232
}
3333

34-
public BindableUser User
34+
public BindableUser? User
3535
{
36-
get => (BindableUser)GetValue(UserProperty);
36+
get => (BindableUser?)GetValue(UserProperty);
3737
set => SetValue(UserProperty, value);
3838
}
3939

src/Libs/Quarrel.Markdown/Rendering/MessageRenderer.Properties.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ public Style? UserMentionStyle
9292
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
9393
{
9494
var messageRenderer = (MessageRenderer)d;
95-
96-
if (messageRenderer.Context is null)
97-
{
98-
// TODO: Allow context free rendering
99-
return;
100-
}
101-
10295
var tree = Parser.ParseAST(messageRenderer.Text, true, false);
10396
var modTree = AdjustTree(tree);
10497
messageRenderer.RenderMarkdown(modTree);

src/Libs/Quarrel.Markdown/Rendering/MessageRenderer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ private void UpdateOverlays()
217217

218218
private void RenderMarkdown(IList<ASTRoot> tree)
219219
{
220-
221220
if (_richBlock != null)
222221
{
223222
_richBlock.SizeChanged -= RichBlock_SizeChanged;

src/Quarrel.Client/QuarrelClient.Methods.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ public partial class QuarrelClient
4141
/// Gets messages in a channel.
4242
/// </summary>
4343
/// <param name="channelId">The channel's id.</param>
44-
public async Task<Message[]> GetMessagesAsync(ulong channelId, ulong? guildId = null)
44+
/// <param name="guildId">The id of the guild the channel belongs to.</param>
45+
/// <param name="beforeId">The message to get the messages from before.</param>
46+
public async Task<Message[]> GetMessagesAsync(ulong channelId, ulong? guildId = null, ulong? beforeId = null)
4547
{
4648
Guard.IsNotNull(_channelService, nameof(_channelService));
4749

48-
JsonMessage[]? jsonMessages = await MakeRefitRequest(() => _channelService.GetChannelMessages(channelId));
50+
Func<Task<JsonMessage[]>> request = () => _channelService.GetChannelMessages(channelId);
51+
if (beforeId.HasValue)
52+
{
53+
request = () => _channelService.GetChannelMessagesBefore(channelId, beforeId.Value);
54+
}
55+
56+
JsonMessage[]? jsonMessages = await MakeRefitRequest(request);
4957
Guard.IsNotNull(jsonMessages, nameof(jsonMessages));
5058

5159
Message[] messages = new Message[jsonMessages.Length];

src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Quarrel.Bindables.Messages.Embeds;
77
using Quarrel.Bindables.Users;
88
using Quarrel.Client.Models.Messages;
9-
using Quarrel.Client.Models.Messages.Embeds;
109
using Quarrel.Messages.Discord.Messages;
1110
using Quarrel.Services.Discord;
1211
using Quarrel.Services.Dispatcher;
@@ -66,7 +65,7 @@ internal BindableMessage(
6665
{
6766
if (Id == e.Message.Id)
6867
{
69-
Message = e.Message;
68+
_dispatcherService.RunOnUIThread(() => Message = e.Message);
7069
}
7170
});
7271

@@ -88,7 +87,7 @@ public Message Message
8887
set
8988
{
9089
SetProperty(ref _message, value);
91-
_dispatcherService.RunOnUIThread(AckUpdate);
90+
AckUpdate();
9291
}
9392
}
9493

src/Quarrel.ViewModels/Extensions/System.Collections.ObjectModel/ObservableRangeCollection.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ public void InsertRange(int index, IEnumerable<T> collection, NotifyCollectionCh
7878
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
7979
if (changedItems.Count > 0)
8080
{
81-
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, index));
81+
for (int i = changedItems.Count-1; i >= 0; i--)
82+
{
83+
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, new List<T>{ changedItems[i] }, index));
84+
}
8285
}
8386
}
8487

src/Quarrel.ViewModels/Services/Discord/DiscordService.Methods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public BindableGuildFolder[] GetMyGuildFolders()
7474
}
7575

7676
/// <inheritdoc/>
77-
public async Task<Message[]> GetChannelMessagesAsync(IBindableMessageChannel channel)
77+
public async Task<Message[]> GetChannelMessagesAsync(IBindableMessageChannel channel, ulong? beforeId = null)
7878
{
79-
var rawMessages = await _quarrelClient.GetMessagesAsync(channel.Id, channel.GuildId);
79+
var rawMessages = await _quarrelClient.GetMessagesAsync(channel.Id, channel.GuildId, beforeId);
8080
Guard.IsNotNull(rawMessages, nameof(rawMessages));
8181
return rawMessages;
8282
}

0 commit comments

Comments
 (0)