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

Commit 1202cd9

Browse files
committed
Added more comments
1 parent 5c556c2 commit 1202cd9

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

src/Quarrel.Client/QuarrelClient.Methods.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@ public partial class QuarrelClient
2626
return CurrentUser;
2727
}
2828

29+
/// <summary>
30+
/// Gets a user by id.
31+
/// </summary>
32+
/// <param name="id">The id of the user to get.</param>
2933
public User? GetUser(ulong id)
3034
{
3135
_userMap.TryGetValue(id, out var user);
3236
return user;
3337
}
3438

39+
/// <summary>
40+
/// Gets the client settings.
41+
/// </summary>
3542
public Settings? GetSettings()
3643
{
3744
return _settings;
@@ -166,6 +173,11 @@ public IPrivateChannel[] GetPrivateChannels()
166173
return privateChannels;
167174
}
168175

176+
/// <summary>
177+
/// Sends a message.
178+
/// </summary>
179+
/// <param name="channelId">The channel to send the message in.</param>
180+
/// <param name="content">The content of the message.</param>
169181
public async Task SendMessage(ulong channelId, string content)
170182
{
171183
Guard.IsNotNull(_channelService, nameof(_channelService));
@@ -174,12 +186,21 @@ public async Task SendMessage(ulong channelId, string content)
174186
await MakeRefitRequest(() => _channelService.CreateMessage(channelId, message));
175187
}
176188

189+
/// <summary>
190+
/// Deletes a message.
191+
/// </summary>
192+
/// <param name="channelId">The id of channel the message belongs to.</param>
193+
/// <param name="messageId">The id of the message to delete.</param>
177194
public async Task DeleteMessage(ulong channelId, ulong messageId)
178195
{
179196
Guard.IsNotNull(_channelService, nameof(_channelService));
180197
await MakeRefitRequest(() => _channelService.DeleteMessage(channelId, messageId));
181198
}
182199

200+
/// <summary>
201+
/// Updates the user's online status.
202+
/// </summary>
203+
/// <param name="status">The new online status to set.</param>
183204
public async Task UpdateStatus(UserStatus status)
184205
{
185206
Guard.IsNotNull(_gateway, nameof(_gateway));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Quarrel.Services.Discord
1010
{
1111
public partial class DiscordService
1212
{
13-
public void RegisterChannelEvents()
13+
private void RegisterChannelEvents()
1414
{
1515
_quarrelClient.MessageCreated += OnMessageCreate;
1616
_quarrelClient.MessageUpdated += OnMessageUpdated;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,24 @@ public interface IDiscordService
7878

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

81+
/// <summary>
82+
/// Sends a message.
83+
/// </summary>
84+
/// <param name="channelId">The id of the channel to send the message in.</param>
85+
/// <param name="content">The content of the message.</param>
8186
Task SendMessage(ulong channelId, string content);
8287

88+
/// <summary>
89+
/// Deletes a message.
90+
/// </summary>
91+
/// <param name="channelId">The id of the channel the message is in.</param>
92+
/// <param name="messageId">The id of the message to delete.</param>
8393
Task DeleteMessage(ulong channelId, ulong messageId);
8494

95+
/// <summary>
96+
/// Updates the user's online status.
97+
/// </summary>
98+
/// <param name="status">The new online status to set.</param>
8599
Task SetStatus(UserStatus status);
86100
}
87101
}

src/Quarrel.ViewModels/ViewModels/Panels/MessageBoxViewModel.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010

1111
namespace Quarrel.ViewModels.Panels
1212
{
13+
/// <summary>
14+
/// The view model for the message box.
15+
/// </summary>
1316
public class MessageBoxViewModel : ObservableRecipient
1417
{
1518
private readonly IMessenger _messenger;
1619
private readonly IDiscordService _discordService;
1720
private readonly IDispatcherService _dispatcherService;
1821

1922
private ulong? _channelId;
20-
private string _draftText;
23+
private string? _draftText;
2124

25+
/// <summary>
26+
/// Initializes a new instance of the <see cref="MessageBoxViewModel"/> class.
27+
/// </summary>
2228
public MessageBoxViewModel(IMessenger messenger, IDiscordService discordService, IDispatcherService dispatcherService)
2329
{
2430
_messenger = messenger;
@@ -33,25 +39,34 @@ public MessageBoxViewModel(IMessenger messenger, IDiscordService discordService,
3339
});
3440
}
3541

42+
/// <summary>
43+
/// Gets a command that sends the drafted message.
44+
/// </summary>
3645
public RelayCommand SendMessageCommand { get; }
3746

38-
public string DraftText
47+
/// <summary>
48+
/// Gets or sets the drafted text in the message box.
49+
/// </summary>
50+
public string? DraftText
3951
{
4052
get => _draftText;
4153
set => SetProperty(ref _draftText, value);
4254
}
4355

56+
/// <summary>
57+
/// Gets the current channel id.
58+
/// </summary>
4459
public ulong? ChannelId
4560
{
4661
get => _channelId;
47-
set => SetProperty(ref _channelId, value);
62+
private set => SetProperty(ref _channelId, value);
4863
}
4964

50-
public void SendMessage()
65+
private void SendMessage()
5166
{
52-
if (ChannelId.HasValue)
67+
if (ChannelId.HasValue && !string.IsNullOrEmpty(DraftText))
5368
{
54-
_discordService.SendMessage(ChannelId.Value, DraftText);
69+
_discordService.SendMessage(ChannelId.Value, DraftText!);
5570
DraftText = string.Empty;
5671
}
5772
}

0 commit comments

Comments
 (0)