Fix #2354 (attempt 3).
Sends the user to the application root (redirecting to /explore) after they remove post from the post page with one post on it.
This commit is contained in:
parent
097a8b409d
commit
1b058cf908
1 changed files with 9 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
$(this.el).attr("id", this.model.get("guid"));
|
$(this.el).attr("id", this.model.get("guid"));
|
||||||
|
|
||||||
this.model.bind('remove', this.remove, this);
|
this.model.bind('remove', this.remove, this);
|
||||||
|
this.model.bind('destroy', this.destroy, this);
|
||||||
|
|
||||||
//subviews
|
//subviews
|
||||||
this.commentStreamView = new app.views.CommentStream({ model : this.model});
|
this.commentStreamView = new app.views.CommentStream({ model : this.model});
|
||||||
|
|
@ -116,5 +117,13 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
|
|
||||||
authorIsNotCurrentUser : function() {
|
authorIsNotCurrentUser : function() {
|
||||||
return this.model.get("author").id != (!!app.user() && app.user().id)
|
return this.model.get("author").id != (!!app.user() && app.user().id)
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy : function() {
|
||||||
|
var posts_uri = new RegExp(this.model.collection.url + '\/[0-9]+$');
|
||||||
|
|
||||||
|
if ((this.model.collection.length == 1) && (posts_uri.test(document.location.pathname))) {
|
||||||
|
document.location.replace(Backbone.history.options.root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue