Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions azure-pipelines-package-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,3 @@ steps:
git push origin HEAD:refs/heads/master
displayName: Push to QuarrelInstaller repo
workingDirectory: $(installerDirectory)

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactStagingDirectory)'
15 changes: 13 additions & 2 deletions src/Libs/Quarrel.Markdown/Parsing/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -92,8 +93,18 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool inQuote
}
else if (url.Match(text) is { Success: true } urlMatch && inlineState)
{
inline = new Url(urlMatch.Groups[1].Value);
text = text.Substring(urlMatch.Length);
string urlContent = urlMatch.Groups[1].Value;
for (int i = urlContent.Length - 1; i >= 0; i--)
{
if (urlContent[i] != ')')
{
int count = urlContent.Count(c => c == '(');
urlContent = urlContent.Substring(0, Math.Min(i + count + 1, urlContent.Length));
break;
}
}
inline = new Url(urlContent);
text = text.Substring(urlContent.Length);
}
else if (strong.Match(text) is { Success: true } strongMatch && inlineState)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Libs/Quarrel.Markdown/Rendering/MessageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ private void RenderMarkdown(IList<ASTRoot> tree)
}
break;
case Url url:
inlineCollection.Add(new Hyperlink() { NavigateUri = new Uri(url.Content), Inlines = { new Run() { Text = url.Content } } });
inlineCollection.Add(new Hyperlink()
{
NavigateUri = Uri.TryCreate(url.Content, UriKind.RelativeOrAbsolute, out Uri uri) ? uri : null,
Inlines = { new Run() { Text = url.Content } }
});
break;
case IEmojiAST emoji:
{
Expand Down
15 changes: 15 additions & 0 deletions src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Quarrel.Bindables.Messages
public class BindableMessage : SelectableItem
{
private Message _message;
private bool _isDeleted;

/// <summary>
/// Initializes a new instance of the <see cref="BindableMessage"/> class.
Expand Down Expand Up @@ -68,6 +69,14 @@ internal BindableMessage(
Message = e.Message;
}
});

_messenger.Register<MessageDeletedMessage>(this, (_, e) =>
{
if (Id == e.MessageId)
{
_dispatcherService.RunOnUIThread(() => IsDeleted = true);
}
});
}

/// <inheritdoc/>
Expand All @@ -85,6 +94,12 @@ public Message Message

public string Content => Message.Content;

public bool IsDeleted
{
get => _isDeleted;
set => SetProperty(ref _isDeleted, value);
}

/// <summary>
/// Gets the author of the message as a bindable user.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Quarrel © 2022

using Quarrel.Bindables.Messages;
using Quarrel.Client.Models.Messages;

namespace Quarrel.Messages.Discord.Messages
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Quarrel © 2022

namespace Quarrel.Messages.Discord.Messages
{
public class MessageDeletedMessage
{
public MessageDeletedMessage(ulong channelId, ulong messageId)
{
ChannelId = channelId;
MessageId = messageId;
}

public ulong ChannelId { get; }

public ulong MessageId { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Quarrel © 2022

using Microsoft.Toolkit.Mvvm.Messaging;
using Quarrel.Bindables.Messages;
using Quarrel.Client.Models.Channels.Abstract;
using Quarrel.Client.Models.Messages;
using Quarrel.Messages.Discord.Channels;
Expand All @@ -15,6 +14,7 @@ public void RegisterChannelEvents()
{
_quarrelClient.MessageCreated += OnMessageCreate;
_quarrelClient.MessageUpdated += OnMessageUpdated;
_quarrelClient.MessageDeleted += OnMessageDeleted;
_quarrelClient.ChannelUpdated += OnChannelUpdated;
}

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

private void OnMessageDeleted(object sender, MessageDeleted e)
{
_messenger.Send(new MessageDeletedMessage(e.ChannelId, e.MessageId));
}

private void OnChannelUpdated(object sender, Channel e)
{
_messenger.Send(new ChannelUpdatedMessage(e));
Expand Down
37 changes: 35 additions & 2 deletions src/Quarrel/Controls/Panels/Channels/ChannelPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bindablechannel="using:Quarrel.Bindables.Channels.Abstract"
xmlns:convert="using:Quarrel.Converters.Common.Visible"
xmlns:bindablechannels="using:Quarrel.Bindables.Channels"
xmlns:cselectors="using:Quarrel.Selectors.Channels"
xmlns:wuxdata="using:Windows.UI.Xaml.Data"
Expand Down Expand Up @@ -49,12 +50,44 @@
<GroupStyle HidesIfEmpty="False">
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="bindablechannels:BindableChannelGroup">
<ContentControl Content="{x:Bind Key}"
ContentTemplate="{StaticResource CategoryZoomInChannelTemplate}"/>
<StackPanel Visibility="{x:Bind convert:VisibleWhenNotNullConverter.Convert(Key)}">
<ContentControl Content="{x:Bind Key}"
ContentTemplate="{StaticResource CategoryZoomInChannelTemplate}"/>
<Rectangle Stroke="{ThemeResource SystemControlForegroundBaseLowBrush}"
StrokeThickness="0.5"
Height="1"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Margin="12,8,12,0"/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.HeaderContainerStyle>
<Style TargetType="ListViewHeaderItem">
<Setter Property="MinHeight" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewHeaderItem">
<ContentPresenter x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.HeaderContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.Footer>
<Grid Height="{x:Bind BottomMargin, Mode=OneWay}"/>
</ListView.Footer>
Expand Down
14 changes: 14 additions & 0 deletions src/Quarrel/Converters/Common/Visible/VisibleWhenNullConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Quarrel © 2022

using Windows.UI.Xaml;

namespace Quarrel.Converters.Common.Visible
{
public class VisibleWhenNullConverter
{
public static Visibility Convert(object? item)
{
return item is null ? Visibility.Visible : Visibility.Collapsed;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Quarrel © 2022

namespace Quarrel.Converters.Discord.Messages
{
public class IsDeletedToOpacityConverter
{
public static double Convert(bool isDeleted)
{
if (isDeleted) return 0.5;
return 1;
}
}
}
8 changes: 5 additions & 3 deletions src/Quarrel/DataTemplates/MessageTemplates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<DataTemplate x:Key="DefaultMessageTemplate" x:DataType="bindablemessages:BindableMessage">
<!--Grid must be wrapped in a user control to enable the VisualStateManager-->
<UserControl>
<Grid x:Name="RootGrid" Padding="2,12,2,4">
<Grid x:Name="RootGrid" Padding="2,12,2,4"
Opacity="{x:Bind mconvert:IsDeletedToOpacityConverter.Convert(IsDeleted), Mode=OneWay}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Default">
Expand Down Expand Up @@ -45,7 +46,7 @@
<ColumnDefinition Width="64"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<!--Image-->
<Border x:Name="ProfileImageContainer" Width="36" Height="36"
CornerRadius="18" VerticalAlignment="Top">
Expand Down Expand Up @@ -84,13 +85,14 @@
</DataTemplate>

<DataTemplate x:Key="InfoMessageTemplate" x:DataType="bindablemessages:BindableMessage">
<Grid Height="48">
<Grid Height="48" Opacity="{x:Bind mconvert:IsDeletedToOpacityConverter.Convert(IsDeleted), Mode=OneWay}">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>

<FontIcon Glyph="{x:Bind mconvert:InfoMessageIconConverter.Convert(Message.Type)}"
Foreground="{x:Bind mconvert:InfoMessageColorConverter.Convert(Message.Type)}"/>

Expand Down
2 changes: 2 additions & 0 deletions src/Quarrel/Quarrel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@
<DependentUpon>UserIcon.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\Common\Text\CaseConverter.cs" />
<Compile Include="Converters\Common\Visible\VisibleWhenNullConverter.cs" />
<Compile Include="Converters\Discord\Channels\MemberCountConverter.cs" />
<Compile Include="Converters\Discord\Messages\InfoMessageColorConverter.cs" />
<Compile Include="Converters\Discord\Messages\InfoMessageContentConverter.cs" />
<Compile Include="Converters\Discord\Messages\InfoMessageIconConverter.cs" />
<Compile Include="Converters\Common\Boolean\EqualityConverter.cs" />
<Compile Include="Converters\Common\Boolean\InverseBoolConverter.cs" />
<Compile Include="Converters\Common\Visible\NotBoolToVisibilityConverter.cs" />
<Compile Include="Converters\Discord\Messages\IsDeletedToOpacityConverter.cs" />
<Compile Include="Converters\Discord\StatusToBrushConverter.cs" />
<Compile Include="Converters\Discord\StatusToColorConverter.cs" />
<Compile Include="Converters\Common\Time\SmartTimeFormatConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Quarrel/SubPages/LoginPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<TextBox x:Uid="Login/TokenTBox" x:Name="TokenTBox"
PlaceholderText="Token" Margin="16"
Text="{x:Bind ViewModel.TokenText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
ui:TextBoxExtensions.Regex="^(?:mfa\.[A-Za-z0-9_-]{20,})|(?:[A-Za-z0-9_-]{23,28}\.A-Z[a-z0-9_-]{6,7}\.[A-Za-z0-9_-]{27})$"
ui:TextBoxExtensions.Regex="^(?:mfa\.[A-Za-z0-9_-]{20,})|(?:[A-Za-z0-9_-]{23,28}\.[A-Za-z0-9_-]{6,7}\.[A-Za-z0-9_-]{27})$"
Style="{StaticResource DiscordTextBox}" VerticalAlignment="Center"/>
</Grid>
<Button x:Uid="Login/LoginBTN" Content="Login" HorizontalAlignment="Stretch" Foreground="{ThemeResource SystemChromeLowColor}"
Expand Down