Bug 1425437 - Improve view batching when dropping/pasting to tags, use the actual bookmarks count, not the count of transactions. r?mak draft
authorMark Banner <standard8@mozilla.com>
Wed, 08 Nov 2017 15:32:51 +0000
changeset 712013 f2330b6a252ac7a834765faceaf7876d4c1cfcb7
parent 712012 6d82e132348fbe33cf3eb7c85c485083c50c6bb9
child 743949 8a40bcb29812c3cb04c75cc867b42058a9969530
push id93223
push userbmo:standard8@mozilla.com
push dateFri, 15 Dec 2017 12:58:30 +0000
reviewersmak
bugs1425437
milestone59.0a1
Bug 1425437 - Improve view batching when dropping/pasting to tags, use the actual bookmarks count, not the count of transactions. r?mak MozReview-Commit-ID: B6Bt8bHhh3e
browser/components/places/content/controller.js
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1815,21 +1815,24 @@ function getResultForBatching(viewOrElem
  * @param {Object} insertionPoint The requested point for insertion.
  * @param {Boolean} doCopy Set to true to copy the items, false will move them
  *                         if possible.
  * @return {Array} Returns an empty array when the insertion point is a tag, else
  *                 returns an array of copied or moved guids.
  */
 async function handleTransferItems(items, insertionPoint, doCopy, view) {
   let transactions;
+  let itemsCount;
   if (insertionPoint.isTag) {
     let urls = items.filter(item => "uri" in item).map(item => item.uri);
+    itemsCount = urls.length;
     transactions = [PlacesTransactions.Tag({ urls, tag: insertionPoint.tagName })];
   } else {
     let insertionIndex = await insertionPoint.getIndex();
+    itemsCount = items.length;
     transactions = await getTransactionsForTransferItems(
       items, insertionIndex, insertionPoint.guid, doCopy);
   }
 
   // Check if we actually have something to add, if we don't it probably wasn't
   // valid, or it was moving to the same location, so just ignore it.
   if (!transactions.length) {
     return [];
@@ -1848,20 +1851,19 @@ async function handleTransferItems(items
         let guid = await transaction.transact();
         if (guid) {
           guidsToSelect.push(guid);
         }
       }
     };
   }
 
-  await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
-    transactions.length, async () => {
-      await PlacesTransactions.batch(batchingItem);
-    });
+  await PlacesUIUtils.batchUpdatesForNode(resultForBatching, itemsCount, async () => {
+    await PlacesTransactions.batch(batchingItem);
+  });
 
   return guidsToSelect;
 }
 
 /**
  * Processes a set of transfer items and returns transactions to insert or
  * move them.
  *