mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-29 18:47:31 +09:00
[PALEMOON] Align the places component with the updated PlacesUtils API
This commit is contained in:
parent
33038b14f2
commit
12a5dc96b5
2 changed files with 34 additions and 23 deletions
|
|
@ -146,14 +146,21 @@ this.PlacesUIUtils = {
|
||||||
* annotations are synced from the old one.
|
* annotations are synced from the old one.
|
||||||
* @see this._copyableAnnotations for the list of copyable annotations.
|
* @see this._copyableAnnotations for the list of copyable annotations.
|
||||||
*/
|
*/
|
||||||
_getFolderCopyTransaction:
|
_getFolderCopyTransaction(aData, aContainer, aIndex) {
|
||||||
function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex)
|
function getChildItemsTransactions(aRoot) {
|
||||||
{
|
|
||||||
function getChildItemsTransactions(aChildren)
|
|
||||||
{
|
|
||||||
let transactions = [];
|
let transactions = [];
|
||||||
let index = aIndex;
|
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
|
// Make sure that items are given the correct index, this will be
|
||||||
// passed by the transaction manager to the backend for the insertion.
|
// passed by the transaction manager to the backend for the insertion.
|
||||||
// Insertion behaves differently for DEFAULT_INDEX (append).
|
// Insertion behaves differently for DEFAULT_INDEX (append).
|
||||||
|
|
@ -184,19 +191,21 @@ this.PlacesUIUtils = {
|
||||||
else {
|
else {
|
||||||
throw new Error("Unexpected item under a bookmarks folder");
|
throw new Error("Unexpected item under a bookmarks folder");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aContainer == PlacesUtils.tagsFolderId) { // Copying a tag folder.
|
if (aContainer == PlacesUtils.tagsFolderId) { // Copying into a tag folder.
|
||||||
let transactions = [];
|
let transactions = [];
|
||||||
if (aData.children) {
|
if (!aData.livemark && aData.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) {
|
||||||
aData.children.forEach(function(aChild) {
|
let {root} = PlacesUtils.getFolderContents(aData.id, false, false);
|
||||||
|
let urls = PlacesUtils.getURLsForContainerNode(root);
|
||||||
|
root.containerOpen = false;
|
||||||
|
for (let { uri } of urls) {
|
||||||
transactions.push(
|
transactions.push(
|
||||||
new PlacesTagURITransaction(PlacesUtils._uri(aChild.uri),
|
new PlacesTagURITransaction(NetUtil.newURI(uri), [aData.title])
|
||||||
[aData.title])
|
|
||||||
);
|
);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return new PlacesAggregatedTransaction("addTags", transactions);
|
return new PlacesAggregatedTransaction("addTags", transactions);
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +214,10 @@ this.PlacesUIUtils = {
|
||||||
return this._getLivemarkCopyTransaction(aData, aContainer, aIndex);
|
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) {
|
if (aData.dateAdded) {
|
||||||
transactions.push(
|
transactions.push(
|
||||||
new PlacesEditItemDateAddedTransaction(null, aData.dateAdded)
|
new PlacesEditItemDateAddedTransaction(null, aData.dateAdded)
|
||||||
|
|
|
||||||
|
|
@ -1287,15 +1287,15 @@ PlacesController.prototype = {
|
||||||
if (!didSuppressNotifications)
|
if (!didSuppressNotifications)
|
||||||
result.suppressNotifications = true;
|
result.suppressNotifications = true;
|
||||||
|
|
||||||
function addData(type, index, overrideURI) {
|
function addData(type, index, feedURI) {
|
||||||
let wrapNode = PlacesUtils.wrapNode(node, type, overrideURI, doCopy);
|
let wrapNode = PlacesUtils.wrapNode(node, type, feedURI);
|
||||||
dt.mozSetDataAt(type, wrapNode, index);
|
dt.mozSetDataAt(type, wrapNode, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addURIData(index, overrideURI) {
|
function addURIData(index, feedURI) {
|
||||||
addData(PlacesUtils.TYPE_X_MOZ_URL, index, overrideURI);
|
addData(PlacesUtils.TYPE_X_MOZ_URL, index, feedURI);
|
||||||
addData(PlacesUtils.TYPE_UNICODE, index, overrideURI);
|
addData(PlacesUtils.TYPE_UNICODE, index, feedURI);
|
||||||
addData(PlacesUtils.TYPE_HTML, index, overrideURI);
|
addData(PlacesUtils.TYPE_HTML, index, feedURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -1387,12 +1387,11 @@ PlacesController.prototype = {
|
||||||
copiedFolders.push(node);
|
copiedFolders.push(node);
|
||||||
|
|
||||||
let livemarkInfo = this.getCachedLivemarkInfo(node);
|
let livemarkInfo = this.getCachedLivemarkInfo(node);
|
||||||
let overrideURI = livemarkInfo ? livemarkInfo.feedURI.spec : null;
|
let feedURI = livemarkInfo && livemarkInfo.feedURI.spec;
|
||||||
let resolveShortcuts = !PlacesControllerDragHelper.canMoveNode(node);
|
|
||||||
|
|
||||||
contents.forEach(function (content) {
|
contents.forEach(function (content) {
|
||||||
content.entries.push(
|
content.entries.push(
|
||||||
PlacesUtils.wrapNode(node, content.type, overrideURI, resolveShortcuts)
|
PlacesUtils.wrapNode(node, content.type, feedURI)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue