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

Commit 5c556c2

Browse files
committed
Further code clean up
1 parent 1c06320 commit 5c556c2

File tree

14 files changed

+102
-20
lines changed

14 files changed

+102
-20
lines changed

src/API/Discord.API/Models/Enums/Messages/ComponentType.cs

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

3-
using System;
4-
using System.Collections.Generic;
5-
using System.Text;
6-
73
namespace Discord.API.Models.Enums.Messages
84
{
95
public enum ComponentType

src/API/Discord.API/Models/Enums/Messages/MessageFlags.cs

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

3-
using System;
4-
using System.Collections.Generic;
5-
using System.Text;
6-
73
namespace Discord.API.Models.Enums.Messages
84
{
95
public enum MessageFlags

src/Quarrel.Client/Models/Messages/Embeds/Attachment.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Quarrel.Client.Models.Messages.Embeds
77
{
8+
/// <summary>
9+
/// An attachment in a message.
10+
/// </summary>
811
public class Attachment : SnowflakeItem
912
{
1013
internal Attachment(JsonAttachment jsonAttachment, QuarrelClient context) :
@@ -18,16 +21,34 @@ internal Attachment(JsonAttachment jsonAttachment, QuarrelClient context) :
1821
Width = jsonAttachment.Width;
1922
}
2023

24+
/// <summary>
25+
/// Gets the name of the attached file.
26+
/// </summary>
2127
public string Filename { get; }
2228

29+
/// <summary>
30+
/// Gets the size of the attached file.
31+
/// </summary>
2332
public ulong Size { get; }
2433

34+
/// <summary>
35+
/// Gets the url of the attached file.
36+
/// </summary>
2537
public string Url { get; }
2638

39+
/// <summary>
40+
/// Gets the proxy url of the attached file.
41+
/// </summary>
2742
public string ProxyUrl { get; }
2843

44+
/// <summary>
45+
/// Gets the height of the attached file if the file is an image or video.
46+
/// </summary>
2947
public int? Height { get; }
3048

49+
/// <summary>
50+
/// Gets the width of the attached file if the file is an image or video.
51+
/// </summary>
3152
public int? Width { get; }
3253
}
3354
}

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

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

33
using Microsoft.Toolkit.Mvvm.Messaging;
4+
using Quarrel.Bindables.Abstract;
45
using Quarrel.Bindables.Channels.Interfaces;
56
using Quarrel.Client.Models.Channels.Abstract;
67
using Quarrel.Client.Models.Channels.Interfaces;
@@ -36,6 +37,14 @@ internal BindablePrivateChannel(
3637
/// <inheritdoc/>
3738
public IMessageChannel MessageChannel => (IMessageChannel)Channel;
3839

40+
/// <summary>
41+
/// Creates a new instance of a <see cref="BindablePrivateChannel"/> based on the type.
42+
/// </summary>
43+
/// <param name="messenger">The <see cref="IMessenger"/> to pass to the <see cref="BindableItem"/>.</param>
44+
/// <param name="discordService">The <see cref="IDiscordService"/> to pass to the <see cref="BindableItem"/>.</param>
45+
/// <param name="localizationService">The <see cref="ILocalizationService"/> to pass to the <see cref="BindableItem"/>.</param>
46+
/// <param name="dispatcherService">The <see cref="IDispatcherService"/> to pass to the <see cref="BindableItem"/>.</param>
47+
/// <param name="channel">The channel to wrap.</param>
3948
public static BindablePrivateChannel? Create(
4049
IMessenger messenger,
4150
IDiscordService discordService,

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ internal BindableMessage(
100100
/// <inheritdoc/>
101101
public ulong ChannelId => Message.ChannelId;
102102

103+
/// <summary>
104+
/// Gets the wrapped <see cref="Client.Models.Messages.Message"/>.
105+
/// </summary>
103106
public Message Message
104107
{
105108
get => _message;
@@ -110,27 +113,43 @@ public Message Message
110113
}
111114
}
112115

113-
public string Content => Message.Content;
114-
116+
/// <summary>
117+
/// Gets whether or not the message has been deleted.
118+
/// </summary>
115119
public bool IsDeleted
116120
{
117121
get => _isDeleted;
118-
set => SetProperty(ref _isDeleted, value);
122+
private set => SetProperty(ref _isDeleted, value);
119123
}
120124

125+
/// <summary>
126+
/// Gets the <see cref="IBindableMessageChannel"/> that the message belongs to.
127+
/// </summary>
121128
public IBindableMessageChannel Channel { get; }
122129

123130
/// <summary>
124131
/// Gets the author of the message as a bindable user.
125132
/// </summary>
126133
public BindableUser? Author { get; }
127134

135+
/// <summary>
136+
/// Gets the author of the message as a bindable guild memeber.
137+
/// </summary>
128138
public BindableGuildMember? AuthorMember { get; }
129139

140+
/// <summary>
141+
/// Gets a dictionary of bindable users relavent to
142+
/// </summary>
130143
public Dictionary<ulong, BindableUser?> Users { get; }
131144

145+
/// <summary>
146+
/// Gets the message attachments.
147+
/// </summary>
132148
public BindableAttachment[] Attachments { get; }
133149

150+
/// <summary>
151+
/// Gets whether or not the message is a continuation.
152+
/// </summary>
134153
public bool IsContinuation => !(
135154
_previousMessage == null ||
136155
_message.Type is MessageType.ApplicationCommand or MessageType.ContextMenuCommand ||
@@ -145,19 +164,31 @@ _message.Type is MessageType.ApplicationCommand or MessageType.ContextMenuComman
145164
_message.WebhookId != null && _previousMessage.Author?.Username != _message.Author?.Username ||
146165
_message.Timestamp.ToUnixTimeMilliseconds() - _previousMessage.Timestamp.ToUnixTimeMilliseconds() > 7 * 60 * 1000)));
147166

167+
/// <summary>
168+
/// Gets whether or not the user can delete the message.
169+
/// </summary>
148170
// TODO: Properly handle deletable condition
149171
public bool CanDelete => Message.IsOwn;
150172

173+
/// <summary>
174+
/// Gets a command that copies the message id to the clipboard.
175+
/// </summary>
151176
public RelayCommand CopyIdCommand { get; }
152177

178+
/// <summary>
179+
/// Gets a command that copies the message link to the clipboard.
180+
/// </summary>
153181
public RelayCommand CopyLinkCommand { get; }
154182

183+
/// <summary>
184+
/// Gets a command that deletes the message.
185+
/// </summary>
155186
public RelayCommand DeleteCommand { get; }
156187

188+
/// <inheritdoc/>
157189
protected virtual void AckUpdate()
158190
{
159191
OnPropertyChanged(nameof(Message));
160-
OnPropertyChanged(nameof(Content));
161192
}
162193
}
163194
}

src/Quarrel.ViewModels/Bindables/Messages/Embeds/BindableAttachment.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Quarrel.Bindables.Messages.Embeds
1010
{
11+
/// <summary>
12+
/// A wrapper of a <see cref="Client.Models.Messages.Embeds.Attachment"/> that can be bound to the UI.
13+
/// </summary>
1114
public class BindableAttachment : BindableItem
1215
{
1316
private Attachment _attachment;
@@ -19,13 +22,16 @@ internal BindableAttachment(
1922
Attachment attachment) :
2023
base(messenger, discordService, dispatcherService)
2124
{
22-
Attachment = attachment;
25+
_attachment = attachment;
2326
}
2427

28+
/// <summary>
29+
/// Gets the wrapped <see cref="Client.Models.Messages.Embeds.Attachment"/>.
30+
/// </summary>
2531
public Attachment Attachment
2632
{
2733
get => _attachment;
28-
set => SetProperty(ref _attachment, value);
34+
private set => SetProperty(ref _attachment, value);
2935
}
3036
}
3137
}

src/Quarrel.ViewModels/Bindables/Users/BindableGuildMember.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Quarrel.Bindables.Users
1010
{
11+
/// <summary>
12+
/// A wrapper of a <see cref="Client.Models.Users.GuildMember"/> that can be bound to the UI.
13+
/// </summary>
1114
public class BindableGuildMember : BindableItem
1215
{
1316
private GuildMember _guildMember;
@@ -25,6 +28,9 @@ internal BindableGuildMember(
2528
_guildMember = guildMember;
2629
}
2730

31+
/// <summary>
32+
/// Gets the wrapped <see cref="Client.Models.Users.GuildMember"/>.
33+
/// </summary>
2834
public GuildMember GuildMember
2935
{
3036
get => _guildMember;

src/Quarrel.ViewModels/Services/Discord/IDiscordService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ public interface IDiscordService
5959
/// <param name="beforeId">The if of the last message to load messages before, or null.</param>
6060
/// <returns>An array of <see cref="BindableMessage"/>s from the channel.</returns>
6161
Task<Message[]> GetChannelMessagesAsync(IBindableMessageChannel channel, ulong? beforeId = null);
62-
62+
6363
/// <summary>
6464
/// Gets the channels in a guild.
6565
/// </summary>
6666
/// <param name="guild">The guild to get the channels for.</param>
6767
/// <param name="selectedChannel">The selected channel as an <see cref="IBindableSelectableChannel"/>.</param>
68-
/// <returns>An array of <see cref="IBindableChannel"/>s from the guild.</returns>
68+
/// <returns>An array of <see cref="BindableGuildChannel"/>s from the guild.</returns>
6969
BindableGuildChannel?[] GetGuildChannels(BindableGuild guild, out IBindableSelectableChannel? selectedChannel);
7070

7171
/// <summary>
7272
/// Gets the user's direct message channels.
7373
/// </summary>
7474
/// <param name="home">The <see cref="BindableHomeItem"/>.</param>
7575
/// <param name="selectedChannel">The selected channel as an <see cref="IBindableSelectableChannel"/>.</param>
76-
/// <returns>An array of <see cref="IBindableChannel"/>s.</returns>
76+
/// <returns>An array of <see cref="BindablePrivateChannel"/>s.</returns>
7777
BindablePrivateChannel?[] GetPrivateChannels(BindableHomeItem home, out IBindableSelectableChannel? selectedChannel);
7878

7979
BindableGuildMember? GetGuildMember(ulong userId, ulong guildId);

src/Quarrel.ViewModels/Services/Localization/ILocalizationService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public interface ILocalizationService
2929
/// </summary>
3030
string CommaList(params string[] args);
3131

32+
/// <summary>
33+
/// Gets or sets the app's language override.
34+
/// </summary>
3235
public string LanguageOverride { get; set; }
3336

3437
/// <summary>

src/Quarrel.ViewModels/ViewModels/Panels/CommandBarViewModel.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace Quarrel.ViewModels.Panels
1111
{
12+
/// <summary>
13+
/// The view model for the command bar.
14+
/// </summary>
1215
public class CommandBarViewModel : ObservableRecipient
1316
{
1417
private readonly IAnalyticsService _analyticsService;
@@ -17,6 +20,9 @@ public class CommandBarViewModel : ObservableRecipient
1720

1821
private IBindableSelectableChannel? _selectedChannel;
1922

23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="CommandBarViewModel"/> class.
25+
/// </summary>
2026
public CommandBarViewModel(IAnalyticsService analyticsService, IMessenger messenger, IDiscordService discordService)
2127
{
2228
_analyticsService = analyticsService;
@@ -26,10 +32,13 @@ public CommandBarViewModel(IAnalyticsService analyticsService, IMessenger messen
2632
_messenger.Register<NavigateToChannelMessage<IBindableSelectableChannel>>(this, (_, m) => SelectedChannel = m.Channel);
2733
}
2834

35+
/// <summary>
36+
/// Gets the selected channel.
37+
/// </summary>
2938
public IBindableSelectableChannel? SelectedChannel
3039
{
3140
get => _selectedChannel;
32-
set => SetProperty(ref _selectedChannel, value);
41+
private set => SetProperty(ref _selectedChannel, value);
3342
}
3443
}
3544
}

0 commit comments

Comments
 (0)