mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-04-28 04:02:59 +00:00
- Added **fallback for sync failures** [#407](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/407) - Added **history setting** to remove non-existent series/episodes on refresh [#420](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/420) - Added **movies to history** - Added **queue persistence** - Changed **download item state handling** - Changed **download item removal processing** - Made small changes to **font detection** - Changed **rate limit error handling** - Fixed issue where **files were not always cleaned up** for removed downloads - Fixed **crash when the queue list was modified** - Fixed **changelog parsing** not handling versions like `vX.X.X.X`, which caused changes to be re-added on every restart
48 lines
No EOL
1.4 KiB
C#
48 lines
No EOL
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using CRD.Utils.Structs;
|
|
using CRD.ViewModels;
|
|
|
|
namespace CRD.Utils.QueueManagement;
|
|
|
|
public sealed class DownloadItemModelCollection{
|
|
private readonly ObservableCollection<DownloadItemModel> items = new();
|
|
private readonly Dictionary<CrunchyEpMeta, DownloadItemModel> models = new();
|
|
|
|
public ObservableCollection<DownloadItemModel> Items => items;
|
|
|
|
public DownloadItemModel? Find(CrunchyEpMeta item){
|
|
return models.TryGetValue(item, out var model)
|
|
? model
|
|
: null;
|
|
}
|
|
|
|
public void Remove(CrunchyEpMeta item){
|
|
if (models.Remove(item, out var model)){
|
|
items.Remove(model);
|
|
} else{
|
|
Console.Error.WriteLine("Failed to remove episode from list");
|
|
}
|
|
}
|
|
|
|
public void Clear(){
|
|
models.Clear();
|
|
items.Clear();
|
|
}
|
|
|
|
public void SyncFromQueue(IEnumerable<CrunchyEpMeta> queueItems){
|
|
foreach (var queueItem in queueItems){
|
|
if (models.TryGetValue(queueItem, out var existingModel)){
|
|
existingModel.Refresh();
|
|
continue;
|
|
}
|
|
|
|
var newModel = new DownloadItemModel(queueItem);
|
|
models.Add(queueItem, newModel);
|
|
items.Add(newModel);
|
|
|
|
_ = newModel.LoadImage();
|
|
}
|
|
}
|
|
} |