Skip to content

Commit

Permalink
Add issue Remember a deselected blog in preview
Browse files Browse the repository at this point in the history
- Sometimes a blog download can run very long and even have not any new media to preview, other blogs are downloaded in parallel, but their preview isn't shown because the long running blog was the first one.
- If another blog/row is chosen in the manager view, the previous/deselected blog is remembered as unwanted. Every time a new blog starts downloading, it's preview is shown although the remembered blog is still downloading.
  • Loading branch information
thomas694 committed Dec 15, 2023
1 parent e5653b2 commit 10a911f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ private void CrawlerServiceActiveItemsCollectionChanged(object sender, NotifyCol
{
if (_crawlerService.ActiveItems.Count > 0)
{
_detailsService.UpdateBlogPreview(_crawlerService.ActiveItems.OrderByDescending(x => x.Blog.LastPreviewShown).Take(1).Select(x => x.Blog).ToArray());
IBlog[] blogs = _crawlerService.ActiveItems.OrderByDescending(x => x.Blog.LastPreviewShown)
.SkipWhile(x => _crawlerService.ActiveItems.Count > 1 && x.Blog == _crawlerService.LastDeselectedPreview).Take(1).Select(x => x.Blog).ToArray();
_detailsService.UpdateBlogPreview(blogs);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Data;
using System.Windows.Input;
using TumblThree.Domain.Models;
using TumblThree.Domain.Models.Blogs;
using TumblThree.Domain.Queue;

namespace TumblThree.Applications.Services
Expand Down Expand Up @@ -53,6 +54,7 @@ public class CrawlerService : Model, ICrawlerService
private Timer _timer;
private string _isTextVis;
private bool _isToolTipActive;
private IBlog _lastDeselectedPreview;

[ImportingConstructor]
public CrawlerService(IShellService shellService)
Expand Down Expand Up @@ -254,6 +256,12 @@ public string NewBlogUrl
set => SetProperty(ref _newBlogUrl, value);
}

public IBlog LastDeselectedPreview
{
get => _lastDeselectedPreview;
set => SetProperty(ref _lastDeselectedPreview, value);
}

public int ActiveCollectionId
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using System.Waf.Foundation;
using System.Windows.Input;
using TumblThree.Domain.Models.Blogs;
using TumblThree.Domain.Queue;

namespace TumblThree.Applications.Services
Expand Down Expand Up @@ -54,6 +55,8 @@ public interface ICrawlerService : INotifyPropertyChanged

string NewBlogUrl { get; set; }

IBlog LastDeselectedPreview { get; set; }

int ActiveCollectionId { get; set; }

IReadOnlyObservableList<QueueListItem> ActiveItems { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void UpdateCollectionsList(bool isInit)

public string NewBlogUrl { get; set; }

public IBlog LastDeselectedPreview { get; set; }

public int ActiveCollectionId { get; set; }

public Guava.RateLimiter.RateLimiter TimeconstraintApi { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ViewModel.SelectionService.RemoveRange(e.RemovedItems.Cast<IBlog>());
ViewModel.SelectionService.AddRange(e.AddedItems.Cast<IBlog>());
if (e.RemovedItems.Count == 1)
{
ViewModel.CrawlerService.LastDeselectedPreview = (IBlog)e.RemovedItems[0];
}
}

private ManagerViewModel ViewModel
Expand Down

0 comments on commit 10a911f

Please sign in to comment.