Browse Source

Dont do cache lookups when the cache parameter for DownloadMessages is false.

tags/docs-0.9
RogueException 9 years ago
parent
commit
bfdfc5623e
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      src/Discord.Net/DiscordClient.Messages.cs

+ 9
- 8
src/Discord.Net/DiscordClient.Messages.cs View File

@@ -223,6 +223,8 @@ namespace Discord
if (count < 0) throw new ArgumentNullException(nameof(count));
CheckReady();

bool trackActivity = Config.TrackActivity;

if (count == 0) return new Message[0];
if (channel != null && channel.Type == ChannelType.Text)
{
@@ -233,21 +235,20 @@ namespace Discord
{
Message msg = null;
if (cache)
msg = _messages.GetOrAdd(x.Id, x.ChannelId, x.Author.Id);
else
{
msg = _messages[x.Id] ?? new Message(this, x.Id, x.ChannelId, x.Author.Id);
msg.Update(x); //TODO: Look into updating when cache is true, but only if we actually generated a new message.
}
if (Config.TrackActivity)
{
if (!channel.IsPrivate)
msg = _messages.GetOrAdd(x.Id, x.ChannelId, x.Author.Id);
if (trackActivity)
{
var user = msg.User;
if (user != null)
user.UpdateActivity(msg.EditedTimestamp ?? msg.Timestamp);
}
}
else
{
msg = /*_messages[x.Id] ??*/ new Message(this, x.Id, x.ChannelId, x.Author.Id);
msg.Update(x);
}
return msg;
})
.ToArray();


Loading…
Cancel
Save