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

Commit

Permalink
Fixed IndexOutOfRange error in empty channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Avid29 committed May 5, 2022
1 parent e90133d commit cbf0201
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Quarrel.ViewModels/ViewModels/Panels/MessagesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ private void LoadInitialMessages(IBindableMessageChannel? channel)
// Load messages
var messages = await _discordService.GetChannelMessagesAsync(channel);
BindableMessage[] bindableMessages = new BindableMessage[messages.Length];
bindableMessages[0] = new BindableMessage(_messenger, _discordService, _dispatcherService, messages[messages.Length-1]);
for (int i = 1; i < messages.Length; i++)
if (bindableMessages.Length > 0)
{
bindableMessages[i] = new BindableMessage(_messenger, _discordService, _dispatcherService, messages[messages.Length-1-i], messages[messages.Length-i]);
bindableMessages[0] = new BindableMessage(_messenger, _discordService, _dispatcherService, messages[messages.Length - 1]);
for (int i = 1; i < messages.Length; i++)
{
bindableMessages[i] = new BindableMessage(_messenger, _discordService, _dispatcherService, messages[messages.Length - 1 - i], messages[messages.Length - i]);
}
}

// Add messages to the UI and mark loading as finished
Expand Down

0 comments on commit cbf0201

Please sign in to comment.