Rework object type checking in items list
a532cfb475
added `isCollection()`, `isSearch()`, and `isItem()` methods to data objects to handle collections and searches in the trash, with `isItem()` checking whether `._ObjectType` was `Item`. That left out feed items (`._ObjectType` == `FeedItem`), and whenc384fef867
made `getSelectedItems()` return only items, it used `isItem()`, so feed items were excluded, which broke feed-item toggling between read and unread [1] and possibly some other things. The simple fix would be to make `isItem` match feed items as well (which could potentially fix other bugs related to feed items), but there was actually no need to add new methods (which can get confused with `CollectionTreeRow` methods) when we can just check the object type with `obj instanceof Zotero.Item`, which gets the benefit of inheritance and matches `Zotero.FeedItem` instances as well. [1] https://forums.zotero.org/discussion/115571/cannot-change-the-status-of-title-in-subscribtion
This commit is contained in:
parent
20e9f20580
commit
6942506eba
8 changed files with 72 additions and 48 deletions
|
@ -1215,6 +1215,34 @@ describe("Item pane", function () {
|
|||
|
||||
describe("Feed buttons", function() {
|
||||
describe("Mark as Read/Unread", function() {
|
||||
it("should change an item from unread to read", async function () {
|
||||
var feed = await createFeed();
|
||||
await select(win, feed);
|
||||
|
||||
var item = await createDataObject('feedItem', { libraryID: feed.libraryID });
|
||||
|
||||
// Skip timed mark-as-read
|
||||
var stub = sinon.stub(win.ZoteroPane, 'startItemReadTimeout');
|
||||
await select(win, item);
|
||||
|
||||
// Click "Mark as Read"
|
||||
var promise = waitForItemEvent('modify');
|
||||
var button = ZoteroPane.itemPane.getCurrentPane().querySelector('.feed-item-toggleRead-button');
|
||||
assert.equal(button.label, Zotero.getString('pane.item.markAsRead'));
|
||||
assert.isFalse(item.isRead);
|
||||
button.click();
|
||||
var ids = await promise;
|
||||
|
||||
assert.sameMembers(ids, [item.id]);
|
||||
assert.isTrue(item.isRead);
|
||||
// Button is re-created
|
||||
button = ZoteroPane.itemPane.getCurrentPane().querySelector('.feed-item-toggleRead-button');
|
||||
assert.equal(button.label, Zotero.getString('pane.item.markAsUnread'));
|
||||
|
||||
stub.restore();
|
||||
});
|
||||
|
||||
|
||||
it("should update label when state of an item changes", function* () {
|
||||
let feed = yield createFeed();
|
||||
yield selectLibrary(win, feed.libraryID);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue