Bug 1404909 - Improve view batching when dropping/pasting to tags, use the actual bookmarks count, not the count of transactions. draft
authorMark Banner <standard8@mozilla.com>
Wed, 08 Nov 2017 15:32:51 +0000
changeset 707540 3ddf974934b53b418adb01a70b18cb4996764d80
parent 707503 b4cef8d1dff06a1ec2b9bb17211c0c3c7f5b76fa
child 707541 d1d3c68ebf4aec26a2e42e5876ef9b97c85c5a74
push id92148
push userbmo:standard8@mozilla.com
push dateTue, 05 Dec 2017 14:01:13 +0000
bugs1404909
milestone59.0a1
Bug 1404909 - Improve view batching when dropping/pasting to tags, use the actual bookmarks count, not the count of transactions. 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.
  *