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

Commit ca6d354

Browse files
authored
Merge pull request #602 from UWPCommunity/rewrite/main
Removed second solution
2 parents 845c172 + 194e604 commit ca6d354

File tree

10 files changed

+162
-632
lines changed

10 files changed

+162
-632
lines changed

Quarrel.App.sln

Lines changed: 0 additions & 414 deletions
This file was deleted.

Quarrel.sln

Lines changed: 61 additions & 181 deletions
Large diffs are not rendered by default.

azure-pipelines-package-alpha.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pool:
2121
vmImage: 'windows-latest'
2222

2323
variables:
24-
solution: '**/Quarrel.App.sln'
24+
solution: '**/Quarrel.sln'
2525
buildPlatform: 'x86|x64|arm|arm64'
2626
buildConfiguration: 'Alpha'
2727
installerDirectory: './QuarrelInstaller'

src/Libs/Quarrel.Markdown/Quarrel.Markdown.csproj

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
77
<ProjectGuid>{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Quarrel.Markdown</RootNamespace>
1111
<AssemblyName>Quarrel.Markdown</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
13+
<LangVersion>10.0</LangVersion>
14+
<Nullable>enable</Nullable>
1315
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
1416
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
1517
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
@@ -18,48 +20,48 @@
1820
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1921
</PropertyGroup>
2022
<PropertyGroup>
21-
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
23+
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
2224
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
23-
<NoWarn>;2008</NoWarn>
24-
<ErrorReport>prompt</ErrorReport>
25-
<UseVSHostingProcess>false</UseVSHostingProcess>
26-
<Prefer32Bit>true</Prefer32Bit>
25+
<NoWarn>;2008</NoWarn>
26+
<ErrorReport>prompt</ErrorReport>
27+
<UseVSHostingProcess>false</UseVSHostingProcess>
28+
<Prefer32Bit>true</Prefer32Bit>
2729
</PropertyGroup>
2830
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
29-
<DebugSymbols>true</DebugSymbols>
30-
<DefineConstants>DEBUG</DefineConstants>
31-
<DefineConstants>DEV</DefineConstants>
32-
<DebugType>full</DebugType>
31+
<DebugSymbols>true</DebugSymbols>
32+
<DefineConstants>DEBUG</DefineConstants>
33+
<DefineConstants>DEV</DefineConstants>
34+
<DebugType>full</DebugType>
3335
</PropertyGroup>
3436
<PropertyGroup Condition="'$(Configuration)' == 'Alpha'">
35-
<Optimize>true</Optimize>
36-
<DefineConstants>ALPHA</DefineConstants>
37-
<DebugType>pdbonly</DebugType>
38-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
37+
<Optimize>true</Optimize>
38+
<DefineConstants>ALPHA</DefineConstants>
39+
<DebugType>pdbonly</DebugType>
40+
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
3941
</PropertyGroup>
4042
<PropertyGroup Condition="'$(Configuration)' == 'Insider'">
41-
<Optimize>true</Optimize>
42-
<DefineConstants>INSIDER</DefineConstants>
43-
<DebugType>pdbonly</DebugType>
44-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
43+
<Optimize>true</Optimize>
44+
<DefineConstants>INSIDER</DefineConstants>
45+
<DebugType>pdbonly</DebugType>
46+
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
4547
</PropertyGroup>
4648
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
47-
<Optimize>true</Optimize>
48-
<DefineConstants>RELEASE</DefineConstants>
49-
<DebugType>pdbonly</DebugType>
50-
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
49+
<Optimize>true</Optimize>
50+
<DefineConstants>RELEASE</DefineConstants>
51+
<DebugType>pdbonly</DebugType>
52+
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
5153
</PropertyGroup>
5254
<PropertyGroup Condition="'$(Platform)' == 'x86'">
53-
<PlatformTarget>x86</PlatformTarget>
55+
<PlatformTarget>x86</PlatformTarget>
5456
</PropertyGroup>
5557
<PropertyGroup Condition="'$(Platform)' == 'x64'">
56-
<PlatformTarget>x64</PlatformTarget>
58+
<PlatformTarget>x64</PlatformTarget>
5759
</PropertyGroup>
5860
<PropertyGroup Condition="'$(Platform)' == 'ARM'">
59-
<PlatformTarget>ARM</PlatformTarget>
61+
<PlatformTarget>ARM</PlatformTarget>
6062
</PropertyGroup>
6163
<PropertyGroup Condition="'$(Platform)' == 'ARM64'">
62-
<PlatformTarget>ARM64</PlatformTarget>
64+
<PlatformTarget>ARM64</PlatformTarget>
6365
</PropertyGroup>
6466
<PropertyGroup>
6567
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

src/Quarrel.Client/Models/Messages/Message.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class Message : SnowflakeItem, IMessage
1717
internal Message(JsonMessage jsonMessage, QuarrelClient context) :
1818
base(context)
1919
{
20+
Id = jsonMessage.Id;
21+
ChannelId = jsonMessage.ChannelId;
2022
GuildId = jsonMessage.GuildId;
2123
Type = jsonMessage.Type;
2224
IsTextToSpeech = jsonMessage.IsTextToSpeech ?? false;
@@ -26,7 +28,10 @@ internal Message(JsonMessage jsonMessage, QuarrelClient context) :
2628
EditedTimestamp = jsonMessage.EditedTimestamp;
2729
Content = jsonMessage.Content ?? string.Empty;
2830

29-
Author = context.GetOrAddUserInternal(jsonMessage.Author);
31+
if (jsonMessage.Author is not null)
32+
{
33+
Author = context.GetOrAddUserInternal(jsonMessage.Author);
34+
}
3035

3136
if (jsonMessage.UserMentions is not null)
3237
{
@@ -41,7 +46,9 @@ internal Message(JsonMessage jsonMessage, QuarrelClient context) :
4146
}
4247
}
4348

44-
public ulong? GuildId{ get; private set; }
49+
public ulong? ChannelId { get; private set; }
50+
51+
public ulong? GuildId { get; private set; }
4552

4653
/// <inheritdoc/>
4754
public MessageType Type { get; private set; }
@@ -65,7 +72,7 @@ internal Message(JsonMessage jsonMessage, QuarrelClient context) :
6572
public DateTimeOffset? EditedTimestamp { get; private set; }
6673

6774
/// <inheritdoc/>
68-
public User Author { get; private set; }
75+
public User? Author { get; private set; }
6976

7077
/// <inheritdoc/>
7178
public User[] Mentions { get; private set; }

src/Quarrel.ViewModels/Bindables/Channels/Abstract/BindableChannel.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Quarrel.Services.Discord;
1212
using Quarrel.Services.Dispatcher;
1313
using Quarrel.Services.Localization;
14-
using System;
1514

1615
namespace Quarrel.Bindables.Channels.Abstract
1716
{
@@ -73,9 +72,6 @@ private set
7372
/// <inheritdoc/>
7473
public abstract bool IsAccessible { get; }
7574

76-
/// <summary>
77-
/// Invokes property changed for mutable properties when <see cref="Channel.ItemUpdated"/> is invoked.
78-
/// </summary>
7975
protected virtual void AckUpdate()
8076
{
8177
OnPropertyChanged(nameof(Channel));

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

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

3-
using Microsoft.Toolkit.Mvvm.ComponentModel;
43
using Microsoft.Toolkit.Mvvm.Messaging;
54
using Quarrel.Bindables.Abstract;
65
using Quarrel.Bindables.Users;
76
using Quarrel.Client.Models.Messages;
7+
using Quarrel.Messages.Discord;
88
using Quarrel.Services.Discord;
99
using Quarrel.Services.Dispatcher;
1010
using System.Collections.Generic;
@@ -16,7 +16,6 @@ namespace Quarrel.Bindables.Messages
1616
/// </summary>
1717
public partial class BindableMessage : SelectableItem
1818
{
19-
[ObservableProperty]
2019
private Message _message;
2120

2221
/// <summary>
@@ -43,8 +42,31 @@ internal BindableMessage(
4342
{
4443
AuthorMember = _discordService.GetGuildMember(message.Author.Id, message.GuildId.Value);
4544
}
45+
46+
_messenger.Register<MessageUpdatedMessage>(this, (_, e) =>
47+
{
48+
if (Id == e.Message.Id)
49+
{
50+
Message = e.Message;
51+
}
52+
});
53+
}
54+
55+
/// <inheritdoc/>
56+
public ulong Id => Message.Id;
57+
58+
public Message Message
59+
{
60+
get => _message;
61+
set
62+
{
63+
SetProperty(ref _message, value);
64+
AckUpdateRoot();
65+
}
4666
}
4767

68+
public string Content => Message.Content;
69+
4870
/// <summary>
4971
/// Gets the author of the message as a bindable user.
5072
/// </summary>
@@ -53,5 +75,19 @@ internal BindableMessage(
5375
public BindableGuildMember? AuthorMember { get; }
5476

5577
public Dictionary<ulong, BindableUser?> Users { get; }
78+
79+
protected virtual void AckUpdate()
80+
{
81+
OnPropertyChanged(nameof(Message));
82+
OnPropertyChanged(nameof(Content));
83+
}
84+
85+
private void AckUpdateRoot()
86+
{
87+
_dispatcherService.RunOnUIThread(() =>
88+
{
89+
AckUpdate();
90+
});
91+
}
5692
}
5793
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Quarrel © 2022
2+
3+
using Quarrel.Client.Models.Messages;
4+
5+
namespace Quarrel.Messages.Discord
6+
{
7+
public class MessageUpdatedMessage
8+
{
9+
public MessageUpdatedMessage(Message message)
10+
{
11+
Message = message;
12+
}
13+
14+
public Message Message { get; }
15+
}
16+
}

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

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

33
using Microsoft.Toolkit.Mvvm.Messaging;
44
using Quarrel.Client.Models.Channels.Abstract;
5+
using Quarrel.Client.Models.Messages;
56
using Quarrel.Messages.Discord;
67

78
namespace Quarrel.Services.Discord
@@ -10,9 +11,15 @@ public partial class DiscordService
1011
{
1112
public void RegisterChannelEvents()
1213
{
14+
_quarrelClient.MessageUpdated += OnMessageUpdated;
1315
_quarrelClient.ChannelUpdated += OnChannelUpdated;
1416
}
1517

18+
private void OnMessageUpdated(object sender, Message e)
19+
{
20+
_messenger.Send(new MessageUpdatedMessage(e));
21+
}
22+
1623
private void OnChannelUpdated(object sender, Channel e)
1724
{
1825
_messenger.Send(new ChannelUpdatedMessage(e));

src/Quarrel/DataTemplates/MessageTemplates.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
FontSize="11" Opacity=".5" Margin="6,0"/>
3737
</StackPanel>
3838

39-
<markdown:MessageRenderer Text="{x:Bind Message.Content}" Context="{x:Bind}" Grid.Row="1"/>
39+
<markdown:MessageRenderer Text="{x:Bind Content, Mode=OneWay}" Context="{x:Bind}" Grid.Row="1"/>
4040
</Grid>
4141
</Grid>
4242
</DataTemplate>

0 commit comments

Comments
 (0)