diff options
author | JustOff <Off.Just.Off@gmail.com> | 2018-11-16 21:57:07 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-12-04 20:00:31 +0100 |
commit | 914294e570fffa153d4100273ce9686d8939bc98 (patch) | |
tree | 3cf6743703d6d75b7a6b661a3335ab8b3c9bfcf7 /application/palemoon/components/places/PlacesUIUtils.jsm | |
parent | 831b9d8d9eed8665b2e00dbf137ed10114114d01 (diff) | |
download | UXP-914294e570fffa153d4100273ce9686d8939bc98.tar UXP-914294e570fffa153d4100273ce9686d8939bc98.tar.gz UXP-914294e570fffa153d4100273ce9686d8939bc98.tar.lz UXP-914294e570fffa153d4100273ce9686d8939bc98.tar.xz UXP-914294e570fffa153d4100273ce9686d8939bc98.zip |
[PALEMOON] Align the places component with the updated PlacesUtils API
Diffstat (limited to 'application/palemoon/components/places/PlacesUIUtils.jsm')
-rw-r--r-- | application/palemoon/components/places/PlacesUIUtils.jsm | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/application/palemoon/components/places/PlacesUIUtils.jsm b/application/palemoon/components/places/PlacesUIUtils.jsm index f62535613..05d79241c 100644 --- a/application/palemoon/components/places/PlacesUIUtils.jsm +++ b/application/palemoon/components/places/PlacesUIUtils.jsm @@ -146,14 +146,21 @@ this.PlacesUIUtils = { * annotations are synced from the old one. * @see this._copyableAnnotations for the list of copyable annotations. */ - _getFolderCopyTransaction: - function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex) - { - function getChildItemsTransactions(aChildren) - { + _getFolderCopyTransaction(aData, aContainer, aIndex) { + function getChildItemsTransactions(aRoot) { let transactions = []; let index = aIndex; - aChildren.forEach(function (node, i) { + for (let i = 0; i < aRoot.childCount; ++i) { + let child = aRoot.getChild(i); + // Temporary hacks until we switch to PlacesTransactions.jsm. + let isLivemark = + PlacesUtils.annotations.itemHasAnnotation(child.itemId, + PlacesUtils.LMANNO_FEEDURI); + let [node] = PlacesUtils.unwrapNodes( + PlacesUtils.wrapNode(child, PlacesUtils.TYPE_X_MOZ_PLACE, isLivemark), + PlacesUtils.TYPE_X_MOZ_PLACE + ); + // Make sure that items are given the correct index, this will be // passed by the transaction manager to the backend for the insertion. // Insertion behaves differently for DEFAULT_INDEX (append). @@ -184,19 +191,21 @@ this.PlacesUIUtils = { else { throw new Error("Unexpected item under a bookmarks folder"); } - }); + } return transactions; } - if (aContainer == PlacesUtils.tagsFolderId) { // Copying a tag folder. + if (aContainer == PlacesUtils.tagsFolderId) { // Copying into a tag folder. let transactions = []; - if (aData.children) { - aData.children.forEach(function(aChild) { + if (!aData.livemark && aData.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) { + let {root} = PlacesUtils.getFolderContents(aData.id, false, false); + let urls = PlacesUtils.getURLsForContainerNode(root); + root.containerOpen = false; + for (let { uri } of urls) { transactions.push( - new PlacesTagURITransaction(PlacesUtils._uri(aChild.uri), - [aData.title]) + new PlacesTagURITransaction(NetUtil.newURI(uri), [aData.title]) ); - }); + } } return new PlacesAggregatedTransaction("addTags", transactions); } @@ -205,7 +214,10 @@ this.PlacesUIUtils = { return this._getLivemarkCopyTransaction(aData, aContainer, aIndex); } - let transactions = getChildItemsTransactions(aData.children); + let {root} = PlacesUtils.getFolderContents(aData.id, false, false); + let transactions = getChildItemsTransactions(root); + root.containerOpen = false; + if (aData.dateAdded) { transactions.push( new PlacesEditItemDateAddedTransaction(null, aData.dateAdded) |