Skip to content

Commit

Permalink
⚡ Improve loading of downloaded contents
Browse files Browse the repository at this point in the history
  • Loading branch information
pitzzahh committed Dec 8, 2023
1 parent c3368a8 commit 0fb87d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions MediaClippex/MVVM/ViewModel/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ public void GetQueuingVideos()

task.GetAwaiter().OnCompleted(() =>
{
Application.Current.Dispatcher.InvokeAsync(() =>
Application.Current.Dispatcher.InvokeAsync(async () =>
{
QueuingContentCardViewModels.Clear();
var queuingContents = task.Result;
HasQueue = queuingContents.Count > 0;
if (!HasQueue) return;
foreach (var video in queuingContents)
{
await Task.Delay(700);
QueuingContentCardViewModels.Add(new QueuingContentCardViewModel(
_container,
video.Title,
Expand All @@ -193,6 +195,7 @@ public void GetQueuingVideos()
video.Url,
video.SelectedQuality
));
}
});
});
}
Expand All @@ -202,14 +205,16 @@ public void GetDownloadedVideos()
var task = Task.Run(() => _container.Resolve<IUnitOfWork>().VideosRepository.GetAll().Reverse().ToList());
task.GetAwaiter().OnCompleted(() =>
{
Application.Current.Dispatcher.InvokeAsync(() =>
Application.Current.Dispatcher.InvokeAsync(async () =>
{
DownloadedVideoCardViewModels.Clear();
var videos = task.Result;
HasDownloadHistory = videos.Count > 0;
if (!HasDownloadHistory) return;
foreach (var video in videos)
{
await Task.Delay(700);
DownloadedVideoCardViewModels.Add(new DownloadedContentCardViewModel(
_container,
video.Title,
Expand All @@ -219,6 +224,7 @@ public void GetDownloadedVideos()
video.Duration,
video.ThumbnailUrl
));
}
});
});
}
Expand Down

0 comments on commit 0fb87d8

Please sign in to comment.