Bug 984900 - Places async transactions: Implement 'sort by name' ui command. r=mak

This commit is contained in:
Asaf Romano 2014-04-08 09:14:49 +03:00
parent c66bf31141
commit c77ef63e3a

View File

@ -139,7 +139,6 @@ PlacesController.prototype = {
case "placesCmd_new:folder":
case "placesCmd_new:livemark":
case "placesCmd_new:bookmark":
case "placesCmd_sortBy:name":
case "placesCmd_createBookmark":
return false;
}
@ -297,7 +296,7 @@ PlacesController.prototype = {
this.reloadSelectedLivemark();
break;
case "placesCmd_sortBy:name":
this.sortFolderByName();
this.sortFolderByName().then(null, Cu.reportError);
break;
case "placesCmd_createBookmark":
let node = this._view.selectedNode;
@ -781,7 +780,7 @@ PlacesController.prototype = {
throw Cr.NS_ERROR_NOT_AVAILABLE;
if (!PlacesUIUtils.useAsyncTransactions) {
var txn = new PlacesCreateSeparatorTransaction(ip.itemId, ip.index);
let txn = new PlacesCreateSeparatorTransaction(ip.itemId, ip.index);
PlacesUtils.transactionManager.doTransaction(txn);
// Select the new item.
let insertedNodeId = PlacesUtils.bookmarks
@ -810,11 +809,16 @@ PlacesController.prototype = {
/**
* Sort the selected folder by name
*/
sortFolderByName: function PC_sortFolderByName() {
var itemId = PlacesUtils.getConcreteItemId(this._view.selectedNode);
var txn = new PlacesSortFolderByNameTransaction(itemId);
PlacesUtils.transactionManager.doTransaction(txn);
},
sortFolderByName: Task.async(function* () {
let itemId = PlacesUtils.getConcreteItemId(this._view.selectedNode);
if (!PlacesUIUtils.useAsyncTransactions) {
var txn = new PlacesSortFolderByNameTransaction(itemId);
PlacesUtils.transactionManager.doTransaction(txn);
return;
}
let guid = yield PlacesUtils.promiseItemGUID(itemId);
yield PlacesTransactions.transact(PlacesTransactions.SortByName(guid));
}),
/**
* Walk the list of folders we're removing in this delete operation, and