Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 374 - favorites migration and fixes #424

Merged
merged 2 commits into from
Dec 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,33 @@
spiderOakApp.favoritesCollection =
new spiderOakApp.FavoritesCollection(favorites);

// THIS IS A MIGRATION FOR PRE-3.0.0 FAVOURITES
var processed = false;
_.forEach(spiderOakApp.favoritesCollection.models, function(model) {
if (model.get("faveVersion")) {
return;
}
var hiveRegex = new RegExp(
spiderOakApp.accountModel.get("b32username") + "\/.*\/SpiderOak(\\s|%20)Hive"
);
var newUrl = model.get("url").replace(
hiveRegex,spiderOakApp.accountModel.get("b32username")+"\/s"
);
model.set("url", newUrl);
model.set("faveVersion", spiderOakApp.version);
model.set(
"icon",
window.fileHelper.fileTypeFromExtension(model.get("url")).icon
);
processed = true;
});
if (processed) {
window.store.set(
"favorites-" + spiderOakApp.accountModel.get("b32username"),
spiderOakApp.favoritesCollection.toJSON()
);
}

// Fresh new recents collection
spiderOakApp.recentsCollection = new spiderOakApp.RecentsCollection();
spiderOakApp.dialogView.hide();
Expand Down
9 changes: 8 additions & 1 deletion src/views/FavoritesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
},
viewDeactivate: function(event) {
this.refreshAllFavoritesButtonView.remove();
this.close();
},
remove: function() {
this.close();
Expand Down Expand Up @@ -122,6 +123,12 @@
this.subViews = [];
},
render: function() {
_.each(this.subViews, function(subViews){
if (subViews.close){
subViews.close();
}
});
this.subViews = [];
this.addAll();
return this;
},
Expand Down Expand Up @@ -172,7 +179,7 @@
close: function(){
this.remove();
this.unbind();
$(document).off("refreshAllFavorites");
$(document).off("refreshAllFavorites", this.refreshAllFavorites);
// handle other unbinding needs, here
_.each(this.subViews, function(subViews){
if (subViews.close){
Expand Down
7 changes: 7 additions & 0 deletions src/views/FilesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,13 @@
.replace(new RegExp("^.*(share|storage)\/([A-Z2-7]*)\/"), "/$1/$2/")
.replace(new RegExp(model.get("encodedUrl") || model.get("url")), "");
callback = callback || function(fileEntry) {
if (model.get("path") !== path) {
model.set("path", path);
window.store.set(
"favorites-" + spiderOakApp.accountModel.get("b32username"),
spiderOakApp.favoritesCollection.toJSON()
);
}
spiderOakApp.dialogView.hide();
};
this.downloadFile(model, path, callback);
Expand Down