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

Commit b970277

Browse files
authored
Merge pull request #607 from UWPCommunity/rewrite/main
Alpha update
2 parents 628ec76 + a2ee0b3 commit b970277

File tree

13 files changed

+126
-16
lines changed

13 files changed

+126
-16
lines changed

azure-pipelines-package-alpha.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,3 @@ steps:
142142
git push origin HEAD:refs/heads/master
143143
displayName: Push to QuarrelInstaller repo
144144
workingDirectory: $(installerDirectory)
145-
146-
- task: PublishBuildArtifacts@1
147-
displayName: 'Publish Artifact: drop'
148-
inputs:
149-
PathtoPublish: '$(build.artifactStagingDirectory)'

src/Libs/Quarrel.Markdown/Parsing/Parser.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Text;
67
using System.Text.RegularExpressions;
78

@@ -92,8 +93,18 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool inQuote
9293
}
9394
else if (url.Match(text) is { Success: true } urlMatch && inlineState)
9495
{
95-
inline = new Url(urlMatch.Groups[1].Value);
96-
text = text.Substring(urlMatch.Length);
96+
string urlContent = urlMatch.Groups[1].Value;
97+
for (int i = urlContent.Length - 1; i >= 0; i--)
98+
{
99+
if (urlContent[i] != ')')
100+
{
101+
int count = urlContent.Count(c => c == '(');
102+
urlContent = urlContent.Substring(0, Math.Min(i + count + 1, urlContent.Length));
103+
break;
104+
}
105+
}
106+
inline = new Url(urlContent);
107+
text = text.Substring(urlContent.Length);
97108
}
98109
else if (strong.Match(text) is { Success: true } strongMatch && inlineState)
99110
{

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ private void RenderMarkdown(IList<ASTRoot> tree)
281281
}
282282
break;
283283
case Url url:
284-
inlineCollection.Add(new Hyperlink() { NavigateUri = new Uri(url.Content), Inlines = { new Run() { Text = url.Content } } });
284+
inlineCollection.Add(new Hyperlink()
285+
{
286+
NavigateUri = Uri.TryCreate(url.Content, UriKind.RelativeOrAbsolute, out Uri uri) ? uri : null,
287+
Inlines = { new Run() { Text = url.Content } }
288+
});
285289
break;
286290
case IEmojiAST emoji:
287291
{

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Quarrel.Bindables.Messages
2020
public class BindableMessage : SelectableItem
2121
{
2222
private Message _message;
23+
private bool _isDeleted;
2324

2425
/// <summary>
2526
/// Initializes a new instance of the <see cref="BindableMessage"/> class.
@@ -68,6 +69,14 @@ internal BindableMessage(
6869
Message = e.Message;
6970
}
7071
});
72+
73+
_messenger.Register<MessageDeletedMessage>(this, (_, e) =>
74+
{
75+
if (Id == e.MessageId)
76+
{
77+
_dispatcherService.RunOnUIThread(() => IsDeleted = true);
78+
}
79+
});
7180
}
7281

7382
/// <inheritdoc/>
@@ -85,6 +94,12 @@ public Message Message
8594

8695
public string Content => Message.Content;
8796

97+
public bool IsDeleted
98+
{
99+
get => _isDeleted;
100+
set => SetProperty(ref _isDeleted, value);
101+
}
102+
88103
/// <summary>
89104
/// Gets the author of the message as a bindable user.
90105
/// </summary>

src/Quarrel.ViewModels/Messages/Discord/Messages/MessageCreatedMessage.cs

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

3-
using Quarrel.Bindables.Messages;
43
using Quarrel.Client.Models.Messages;
54

65
namespace Quarrel.Messages.Discord.Messages
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Quarrel © 2022
2+
3+
namespace Quarrel.Messages.Discord.Messages
4+
{
5+
public class MessageDeletedMessage
6+
{
7+
public MessageDeletedMessage(ulong channelId, ulong messageId)
8+
{
9+
ChannelId = channelId;
10+
MessageId = messageId;
11+
}
12+
13+
public ulong ChannelId { get; }
14+
15+
public ulong MessageId { get; }
16+
}
17+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Quarrel © 2022
22

33
using Microsoft.Toolkit.Mvvm.Messaging;
4-
using Quarrel.Bindables.Messages;
54
using Quarrel.Client.Models.Channels.Abstract;
65
using Quarrel.Client.Models.Messages;
76
using Quarrel.Messages.Discord.Channels;
@@ -15,6 +14,7 @@ public void RegisterChannelEvents()
1514
{
1615
_quarrelClient.MessageCreated += OnMessageCreate;
1716
_quarrelClient.MessageUpdated += OnMessageUpdated;
17+
_quarrelClient.MessageDeleted += OnMessageDeleted;
1818
_quarrelClient.ChannelUpdated += OnChannelUpdated;
1919
}
2020

@@ -28,6 +28,11 @@ private void OnMessageUpdated(object sender, Message e)
2828
_messenger.Send(new MessageUpdatedMessage(e));
2929
}
3030

31+
private void OnMessageDeleted(object sender, MessageDeleted e)
32+
{
33+
_messenger.Send(new MessageDeletedMessage(e.ChannelId, e.MessageId));
34+
}
35+
3136
private void OnChannelUpdated(object sender, Channel e)
3237
{
3338
_messenger.Send(new ChannelUpdatedMessage(e));

src/Quarrel/Controls/Panels/Channels/ChannelPanel.xaml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
xmlns:bindablechannel="using:Quarrel.Bindables.Channels.Abstract"
8+
xmlns:convert="using:Quarrel.Converters.Common.Visible"
89
xmlns:bindablechannels="using:Quarrel.Bindables.Channels"
910
xmlns:cselectors="using:Quarrel.Selectors.Channels"
1011
xmlns:wuxdata="using:Windows.UI.Xaml.Data"
@@ -49,12 +50,44 @@
4950
<GroupStyle HidesIfEmpty="False">
5051
<GroupStyle.HeaderTemplate>
5152
<DataTemplate x:DataType="bindablechannels:BindableChannelGroup">
52-
<ContentControl Content="{x:Bind Key}"
53-
ContentTemplate="{StaticResource CategoryZoomInChannelTemplate}"/>
53+
<StackPanel Visibility="{x:Bind convert:VisibleWhenNotNullConverter.Convert(Key)}">
54+
<ContentControl Content="{x:Bind Key}"
55+
ContentTemplate="{StaticResource CategoryZoomInChannelTemplate}"/>
56+
<Rectangle Stroke="{ThemeResource SystemControlForegroundBaseLowBrush}"
57+
StrokeThickness="0.5"
58+
Height="1"
59+
VerticalAlignment="Bottom"
60+
HorizontalAlignment="Stretch"
61+
Margin="12,8,12,0"/>
62+
</StackPanel>
5463
</DataTemplate>
5564
</GroupStyle.HeaderTemplate>
65+
<GroupStyle.HeaderContainerStyle>
66+
<Style TargetType="ListViewHeaderItem">
67+
<Setter Property="MinHeight" Value="0"/>
68+
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
69+
<Setter Property="Template">
70+
<Setter.Value>
71+
<ControlTemplate TargetType="ListViewHeaderItem">
72+
<ContentPresenter x:Name="ContentPresenter"
73+
Margin="{TemplateBinding Padding}"
74+
Content="{TemplateBinding Content}"
75+
ContentTemplate="{TemplateBinding ContentTemplate}"
76+
ContentTransitions="{TemplateBinding ContentTransitions}"
77+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
78+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
79+
</ControlTemplate>
80+
</Setter.Value>
81+
</Setter>
82+
</Style>
83+
</GroupStyle.HeaderContainerStyle>
5684
</GroupStyle>
5785
</ListView.GroupStyle>
86+
<ListView.ItemsPanel>
87+
<ItemsPanelTemplate>
88+
<ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
89+
</ItemsPanelTemplate>
90+
</ListView.ItemsPanel>
5891
<ListView.Footer>
5992
<Grid Height="{x:Bind BottomMargin, Mode=OneWay}"/>
6093
</ListView.Footer>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Quarrel © 2022
2+
3+
using Windows.UI.Xaml;
4+
5+
namespace Quarrel.Converters.Common.Visible
6+
{
7+
public class VisibleWhenNullConverter
8+
{
9+
public static Visibility Convert(object? item)
10+
{
11+
return item is null ? Visibility.Visible : Visibility.Collapsed;
12+
}
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Quarrel © 2022
2+
3+
namespace Quarrel.Converters.Discord.Messages
4+
{
5+
public class IsDeletedToOpacityConverter
6+
{
7+
public static double Convert(bool isDeleted)
8+
{
9+
if (isDeleted) return 0.5;
10+
return 1;
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)