2013-08-12 00:10:37 +00:00
|
|
|
define([
|
|
|
|
"underscore",
|
|
|
|
"utils",
|
2014-04-10 23:22:30 +00:00
|
|
|
"storage",
|
2013-08-12 00:10:37 +00:00
|
|
|
"classes/FolderDescriptor",
|
|
|
|
"storage",
|
2014-04-10 23:22:30 +00:00
|
|
|
], function(_, utils, storage, FolderDescriptor) {
|
2013-08-12 00:10:37 +00:00
|
|
|
var folderList = {};
|
|
|
|
|
|
|
|
// Retrieve folder descriptors from localStorage
|
2014-04-10 23:22:30 +00:00
|
|
|
utils.retrieveIndexArray("folder.list").forEach(function(folderIndex) {
|
2013-08-12 00:10:37 +00:00
|
|
|
folderList[folderIndex] = new FolderDescriptor(folderIndex);
|
|
|
|
});
|
|
|
|
|
2014-04-10 23:22:30 +00:00
|
|
|
// Clean fields from deleted folders in local storage
|
|
|
|
Object.keys(storage).forEach(function(key) {
|
|
|
|
var match = key.match(/(folder\.\S+?)\.\S+/);
|
|
|
|
if(match && !folderList.hasOwnProperty(match[1])) {
|
|
|
|
storage.removeItem(key);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-12 00:10:37 +00:00
|
|
|
return folderList;
|
2014-04-10 23:22:30 +00:00
|
|
|
});
|