Skip to content

Commit

Permalink
live downloaded items separation
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-zhur committed Sep 25, 2024
1 parent 12d6bf9 commit b3630d5
Show file tree
Hide file tree
Showing 8 changed files with 1,651 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private async Task Download(Client client, ChatBase chat, Dictionary<int, (strin
{
var liveChat = await videosDatabase.LiveChats.Include(x => x.LiveTopics).ThenInclude(x => x.LiveMediae).Where(x => x.Id == chat.ID).SingleAsync();
var liveMediae = liveChat.LiveTopics.SelectMany(t => t.LiveMediae).Join(topics.SelectMany(x => x.Value.media), x => x.Id, x => x.message.ID, (x, y) => (x, y)).ToList();
var downloadedItems = await videosDatabase.DownloadedItems.Where(x => videosDatabase.LiveMediae.Any(y => y.MediaId == x.LiveMediaId)).ToDictionaryAsync(x => x.LiveMediaId);
var downloadedItems = await videosDatabase.LiveDownloadedItems.Where(x => videosDatabase.LiveMediae.Any(y => y.MediaId == x.LiveMediaMediaId)).ToDictionaryAsync(x => x.LiveMediaMediaId);

var success = 0;
var failed = 0;
Expand Down Expand Up @@ -91,9 +91,9 @@ await File.WriteAllBytesAsync(

using var _ = await _databaseLock.LockAsync();

videosDatabase.DownloadedItems.Add(downloaded = new()
videosDatabase.LiveDownloadedItems.Add(downloaded = new()
{
LiveMediaId = liveMedia.MediaId,
LiveMediaMediaId = liveMedia.MediaId,
FileName = fileName,
});

Expand Down
Loading

0 comments on commit b3630d5

Please sign in to comment.