Describe the bug
Some functions are not available when lists are open in a new tab or window. Things like removing books are disabled.
Exact Steps to Reproduce
Steps to reproduce the behavior:
- Open a List in a new tab
- Go back to the Library tab and switch lists
- Go to the previous list in the new tab
- The Remove entry in the context menu is grayed out.
Version/Commit (check the about page, next to the version, for the string between brackets):
Additional context
When UpdateBookList is called
|
private void UpdateBookList() |
|
{ |
|
updateTimer.Stop(); |
|
using (new WaitCursor()) |
|
{ |
|
if (tvQueries.SelectedNode != null) |
|
{ |
|
BookList = tvQueries.SelectedNode.Tag as IComicBookListProvider; |
|
} |
|
} |
|
} |
It sets the BookList, but when the list differ, it disconnects the ServiceRequest from the old one.
|
protected set |
|
{ |
|
if (bookList != value) |
|
{ |
|
IComicBookListProvider comicBookListProvider = bookList; |
|
bookList = value; |
|
if (bookList != null) |
|
{ |
|
bookList.ServiceRequest += bookList_ServiceRequest; |
|
} |
|
OnBookListChanged(); |
|
if (comicBookListProvider != null) |
|
{ |
|
comicBookListProvider.ServiceRequest -= bookList_ServiceRequest; |
|
} |
|
history.AddAtCursor(bookList); |
|
} |
|
} |
So things that use QueryService might not work. When the QueryService is called it execute the OnServiceRequest. But since it is disconnected it won't trigger.
|
public virtual T QueryService<T>() where T : class |
|
{ |
|
ServiceRequestEventArgs serviceRequestEventArgs = new ServiceRequestEventArgs(typeof(T), this as T); |
|
OnServiceRequest(serviceRequestEventArgs); |
|
return serviceRequestEventArgs.Service as T; |
|
} |
|
|
|
protected virtual void OnServiceRequest(ServiceRequestEventArgs e) |
|
{ |
|
if (this.ServiceRequest != null) |
|
{ |
|
this.ServiceRequest(this, e); |
|
} |
|
} |
|
if (e.Service == null && e.ServiceType == typeof(IRemoveBooks)) |
|
{ |
|
e.Service = new RemoveBookHandler(this, Library, senderList); |
|
} |
But it seems to be a problem specifically with IRemoveBooks. Usually when BookList.QueryService<IRemoveBooks>() is called, if the caller (in this case a ComicIdListItem or ComicSmartListItem or any type of lists) doesn't implement IRemoveBooks then the Service becomes null, thus no allowing it to work with CanRemoveBooks or RemoveBooks.
|
public void RemoveBooks(IEnumerable<ComicBook> books) |
|
{ |
|
IRemoveBooks removeBooks = BookList.QueryService<IRemoveBooks>(); |
|
if (removeBooks != null) |
|
{ |
|
ItemView.BeginUpdate(); |
|
try |
|
{ |
|
removeBooks.RemoveBooks(books, Control.ModifierKeys != Keys.Control); |
|
} |
|
finally |
|
{ |
|
ItemView.EndUpdate(); |
|
} |
|
} |
|
} |
|
|
|
private bool CanRemoveBooks() |
|
{ |
|
if (itemView.InplaceEditItem == null && ComicEditMode.CanDeleteComics() && BookList != null) |
|
{ |
|
return BookList.QueryService<IRemoveBooks>() != null; |
|
} |
|
return false; |
|
} |
Describe the bug
Some functions are not available when lists are open in a new tab or window. Things like removing books are disabled.
Exact Steps to Reproduce
Steps to reproduce the behavior:
Version/Commit (check the about page, next to the version, for the string between brackets):
Additional context
When
UpdateBookListis calledComicRackCE/ComicRack/Views/ComicListLibraryBrowser.cs
Lines 728 to 738 in 4258007
It sets the
BookList, but when the list differ, it disconnects theServiceRequestfrom the old one.ComicRackCE/ComicRack/Views/ComicListBrowser.cs
Lines 25 to 42 in 4258007
So things that use
QueryServicemight not work. When theQueryServiceis called it execute theOnServiceRequest. But since it is disconnected it won't trigger.ComicRackCE/cYo.Common/ComponentModel/LiteComponent.cs
Lines 11 to 24 in 4258007
ComicRackCE/ComicRack/Views/ComicListLibraryBrowser.cs
Lines 355 to 358 in 4258007
But it seems to be a problem specifically with
IRemoveBooks. Usually whenBookList.QueryService<IRemoveBooks>()is called, if the caller (in this case aComicIdListItemorComicSmartListItemor any type of lists) doesn't implementIRemoveBooksthen theServicebecomes null, thus no allowing it to work withCanRemoveBooksorRemoveBooks.ComicRackCE/ComicRack/Views/ComicBrowserControl.cs
Lines 2757 to 2781 in 4258007