Bug 610375 - Make bookmark folders not sync last [r=mconnor]

This commit is contained in:
Philipp von Weitershausen 2010-11-09 13:53:50 -08:00
Родитель 80f1e34958
Коммит 959c42dca4
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -45,6 +45,7 @@ const Cu = Components.utils;
const PARENT_ANNO = "weave/parent"; const PARENT_ANNO = "weave/parent";
const PREDECESSOR_ANNO = "weave/predecessor"; const PREDECESSOR_ANNO = "weave/predecessor";
const SERVICE_NOT_SUPPORTED = "Service not supported on this platform"; const SERVICE_NOT_SUPPORTED = "Service not supported on this platform";
const FOLDER_SORTINDEX = 1000000;
try { try {
Cu.import("resource://gre/modules/PlacesUtils.jsm"); Cu.import("resource://gre/modules/PlacesUtils.jsm");
@ -862,6 +863,10 @@ BookmarksStore.prototype = {
}, },
_calculateIndex: function _calculateIndex(record) { _calculateIndex: function _calculateIndex(record) {
// Ensure folders have a very high sort index so they're not synced last.
if (record.type == "folder")
return FOLDER_SORTINDEX;
// For anything directly under the toolbar, give it a boost of more than an // For anything directly under the toolbar, give it a boost of more than an
// unvisited bookmark // unvisited bookmark
let index = 0; let index = 0;

Просмотреть файл

@ -42,6 +42,13 @@ function run_test() {
_("The calculated sort index is based on frecency data."); _("The calculated sort index is based on frecency data.");
do_check_true(newrecord.sortindex >= 150); do_check_true(newrecord.sortindex >= 150);
_("Folders have high sort index to ensure they're synced first.");
let folder_id = Svc.Bookmark.createFolder(Svc.Bookmark.toolbarFolder,
"Test Folder", 0);
let folder_guid = Svc.Bookmark.getItemGUID(folder_id);
let folder_record = store.createRecord(folder_guid, "http://fake/uri");
do_check_eq(folder_record.sortindex, 1000000);
} finally { } finally {
_("Clean up."); _("Clean up.");
store.wipe(); store.wipe();