Steps to replicate the issue (include links if applicable):
What happens?:
If currentReadingListSize[ listId ] === 0 then in updateListCount it is incorrectly returning -1 (as if the list is undefined).
Then we never get an accurate count of the updated list size when a user saves their first page to the reading list,
/**
* Updates the mw-list-page-count data attribute with the reading list page count
*
* @param {string} listId
* @param {boolean} isSaved
* @return {number} -1 if the reading list size is not known
*/
function updateListCount( listId, isSaved ) {
if ( !currentReadingListSize[ listId ] ) {
return -1;
} else {
currentReadingListSize[ listId ] += ( isSaved ? 1 : -1 );
return currentReadingListSize[ listId ];
}
}
function updateBookmarkStatus( isSaved, listId, entryId ) {
const listPageCount = updateListCount( listId, isSaved );What should have happened instead?:
The currentReadingListSize should be 0 and then incremented to 1 when a user saves their first page to their reading list.
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
Other information (browser name/version, screenshots, etc.):
