Skip redundant bundle-id expansion when marking entire xwiki bundle read

When we mark an entire bundle as read, we don't care if it was opened
before or not - we call the API for the list of sources and their items
and build a list of IDs to mark as read in the remote source.

Then, we make sure that bundleIDs are expanded, added to that list.

Previously, we then sent those IDs to 'markCrossWikiItemsRead'
which marked the item IDs in the remote wikis as read.
markCrossWikiItemsRead is also expanding item bundle
IDs (correctly, because we also use it when we mark individual
xwiki items, and they should be expanded)

However, in cases where we mark individual xwiki items, the
model list is already filled, so markCrossWikiItemsRead trusts
the models to deliver the sub items (and then expand on their
IDs properly)

In the case of marking an entire xwiki bundle as read without
opening it first, however, that operation is not only redundant,
it produces a problem where the models were not yet filled
(because the xwiki bundle wasn't opened) and so we get empty
array of IDs, and the API has nothing to mark as read.

The solution is simple in this case - skip this method for working
with an entire bundle. It's both a redundant operation and the
wrong model to check. Send the information directly to the API
instead.

Bug: T142143
Change-Id: I4ed3bbc5c83290ed5791060b124840b1c3b12a75
This commit is contained in:
Moriel Schottlender 2016-08-04 15:11:54 -07:00 committed by Catrope
parent e5d20f3753
commit df83d1d6dd

View file

@ -666,6 +666,8 @@
return $.Deferred().reject().promise();
}
this.manager.getUnreadCounter().estimateChange( -xwikiModel.getCount() );
return this.api.fetchNotificationGroups( xwikiModel.getSourceNames(), this.manager.getTypeString() )
.then( function ( groupList ) {
var i, listModel, group, groupItems,
@ -685,14 +687,15 @@
// Mark items as read in the API
promises.push(
controller.markCrossWikiItemsRead( idArray, listModel.getName() )
controller.api.markItemsRead( idArray, listModel.getName(), true )
);
}
// Synchronously remove this model from the widget
controller.removeCrossWikiItem();
return mw.echo.api.NetworkHandler.static.waitForAllPromises( promises );
return mw.echo.api.NetworkHandler.static.waitForAllPromises( promises )
.then( controller.refreshUnreadCount.bind( controller ) );
} );
};