Bug 445737 - undo delete bookmark doesn't restore keyword (r=dietrich)

This commit is contained in:
mak77@bonardo.net 2008-11-05 14:03:48 -08:00
parent 91d78ac749
commit e0c1031449
2 changed files with 19 additions and 8 deletions

View File

@ -488,18 +488,25 @@ function placesRemoveItemTransaction(aItemId) {
this._removeTxn = PlacesUtils.bookmarks
.getRemoveFolderTransaction(this._id);
}
else if (this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK) {
this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._id);
this._keyword = PlacesUtils.bookmarks.getKeywordForBookmark(this._id);
}
if (this._itemType != Ci.nsINavBookmarksService.TYPE_SEPARATOR)
this._title = PlacesUtils.bookmarks.getItemTitle(this._id);
this._oldContainer = PlacesUtils.bookmarks.getFolderIdForItem(this._id);
this._annotations = PlacesUtils.getAnnotationsForItem(this._id);
this._dateAdded = PlacesUtils.bookmarks.getItemDateAdded(this._id);
this._lastModified = PlacesUtils.bookmarks.getItemLastModified(this._id);
}
placesRemoveItemTransaction.prototype = {
__proto__: placesBaseTransaction.prototype,
doTransaction: function PRIT_doTransaction() {
this._oldContainer = PlacesUtils.bookmarks.getFolderIdForItem(this._id);
this._oldIndex = PlacesUtils.bookmarks.getItemIndex(this._id);
this._title = PlacesUtils.bookmarks.getItemTitle(this._id);
this._annotations = PlacesUtils.getAnnotationsForItem(this._id);
this._dateAdded = PlacesUtils.bookmarks.getItemDateAdded(this._id);
this._lastModified = PlacesUtils.bookmarks.getItemLastModified(this._id);
if (this._itemType == Ci.nsINavBookmarksService.TYPE_FOLDER) {
this._saveFolderContents();
@ -512,8 +519,6 @@ placesRemoveItemTransaction.prototype = {
this._removeTxn.doTransaction();
}
else {
if (this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK)
this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._id);
PlacesUtils.bookmarks.removeItem(this._id);
if (this._uri) {
// if this was the last bookmark (excluding tag-items and livemark
@ -535,6 +540,8 @@ placesRemoveItemTransaction.prototype = {
this._title);
if (this._tags && this._tags.length > 0)
PlacesUtils.tagging.tagURI(this._uri, this._tags);
if (this._keyword)
PlacesUtils.bookmarks.setKeywordForBookmark(this._id, this._keyword);
}
else if (this._itemType == Ci.nsINavBookmarksService.TYPE_FOLDER) {
this._removeTxn.undoTransaction();

View File

@ -291,20 +291,24 @@ function run_test() {
do_check_eq(observer._itemAddedParent, root);
do_check_eq(observer._itemAddedIndex, 3);
// Test removing an item
// Test removing an item with a keyword
bmsvc.setKeywordForBookmark(bkmk2Id, "test_keyword");
var txn5 = ptSvc.removeItem(bkmk2Id);
txn5.doTransaction();
do_check_eq(observer._itemRemovedId, bkmk2Id);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, 2);
do_check_eq(bmsvc.getKeywordForBookmark(bkmk2Id), null);
txn5.undoTransaction();
var newbkmk2Id = observer._itemAddedId;
do_check_eq(observer._itemAddedParent, root);
do_check_eq(observer._itemAddedIndex, 2);
do_check_eq(bmsvc.getKeywordForBookmark(newbkmk2Id), "test_keyword");
txn5.redoTransaction();
do_check_eq(observer._itemRemovedId, newbkmk2Id);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, 2);
do_check_eq(bmsvc.getKeywordForBookmark(newbkmk2Id), null);
txn5.undoTransaction();
do_check_eq(observer._itemAddedParent, root);
do_check_eq(observer._itemAddedIndex, 2);