UX: navigate to staged posts faster right away
stop with the blue unread circle on new posts
This commit is contained in:
parent
34294ca748
commit
de107a60c2
|
@ -216,7 +216,9 @@ export default DiscourseController.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return composer.save({
|
var staged = false,
|
||||||
|
disableJumpReply = Discourse.User.currentProp('disable_jump_reply');
|
||||||
|
var promise = composer.save({
|
||||||
imageSizes: this.get('view').imageSizes(),
|
imageSizes: this.get('view').imageSizes(),
|
||||||
editReason: this.get("editReason")
|
editReason: this.get("editReason")
|
||||||
}).then(function(opts) {
|
}).then(function(opts) {
|
||||||
|
@ -236,8 +238,8 @@ export default DiscourseController.extend({
|
||||||
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
currentUser.set('reply_count', currentUser.get('reply_count') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!composer.get('replyingToTopic')) || (!Discourse.User.currentProp('disable_jump_reply'))) {
|
if (!composer.get('replyingToTopic') || !disableJumpReply) {
|
||||||
if (opts.post) {
|
if (opts.post && !staged) {
|
||||||
Discourse.URL.routeTo(opts.post.get('url'));
|
Discourse.URL.routeTo(opts.post.get('url'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,6 +247,18 @@ export default DiscourseController.extend({
|
||||||
composer.set('disableDrafts', false);
|
composer.set('disableDrafts', false);
|
||||||
bootbox.alert(error);
|
bootbox.alert(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
staged = composer.get('stagedPost');
|
||||||
|
|
||||||
|
Em.run.schedule('afterRender', function() {
|
||||||
|
if (staged && !disableJumpReply) {
|
||||||
|
var postNumber = staged.get('post_number');
|
||||||
|
Discourse.URL.jumpToPost(postNumber, {skipIfOnScreen: true});
|
||||||
|
self.appEvents.trigger('post:highlight', postNumber);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -429,7 +429,8 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
reply: null,
|
reply: null,
|
||||||
post: null,
|
post: null,
|
||||||
title: null,
|
title: null,
|
||||||
editReason: null
|
editReason: null,
|
||||||
|
stagedPost: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -518,6 +519,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
admin: currentUser.get('admin'),
|
admin: currentUser.get('admin'),
|
||||||
yours: true,
|
yours: true,
|
||||||
newPost: true,
|
newPost: true,
|
||||||
|
read: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.serialize(_create_serializer, createdPost);
|
this.serialize(_create_serializer, createdPost);
|
||||||
|
@ -532,6 +534,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var state = null;
|
||||||
|
|
||||||
// If we're in a topic, we can append the post instantly.
|
// If we're in a topic, we can append the post instantly.
|
||||||
if (postStream) {
|
if (postStream) {
|
||||||
|
@ -545,16 +548,18 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
// Furthermore calculating cooked is very complicated, especially since
|
// Furthermore calculating cooked is very complicated, especially since
|
||||||
// we would need to handle oneboxes and other bits that are not even in the
|
// we would need to handle oneboxes and other bits that are not even in the
|
||||||
// engine, staging will just cause a blank post to render
|
// engine, staging will just cause a blank post to render
|
||||||
if (!_.isEmpty(createdPost.get('cooked')) && !postStream.stagePost(createdPost, currentUser)) {
|
if (!_.isEmpty(createdPost.get('cooked'))) {
|
||||||
|
state = postStream.stagePost(createdPost, currentUser);
|
||||||
|
|
||||||
// If we can't stage the post, return and don't save. We're likely currently
|
if(state === "alreadyStaging"){
|
||||||
// staging a post.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var composer = this;
|
var composer = this;
|
||||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
var promise = new Ember.RSVP.Promise(function(resolve, reject) {
|
||||||
|
|
||||||
composer.set('composeState', SAVING);
|
composer.set('composeState', SAVING);
|
||||||
createdPost.save(function(result) {
|
createdPost.save(function(result) {
|
||||||
|
@ -613,6 +618,10 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
reject(parsedError);
|
reject(parsedError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
composer.set("stagedPost", state === "staged" && createdPost);
|
||||||
|
|
||||||
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
getCookedHtml: function() {
|
getCookedHtml: function() {
|
||||||
|
|
|
@ -295,7 +295,8 @@ const PostStream = Ember.Object.extend({
|
||||||
**/
|
**/
|
||||||
stagePost(post, user) {
|
stagePost(post, user) {
|
||||||
// We can't stage two posts simultaneously
|
// We can't stage two posts simultaneously
|
||||||
if (this.get('stagingPost')) { return false; }
|
if (this.get('stagingPost')) { return "alreadyStaging"; }
|
||||||
|
|
||||||
this.set('stagingPost', true);
|
this.set('stagingPost', true);
|
||||||
|
|
||||||
const topic = this.get('topic');
|
const topic = this.get('topic');
|
||||||
|
@ -317,9 +318,10 @@ const PostStream = Ember.Object.extend({
|
||||||
if (this.get('loadedAllPosts')) {
|
if (this.get('loadedAllPosts')) {
|
||||||
this.appendPost(post);
|
this.appendPost(post);
|
||||||
this.get('stream').addObject(post.get('id'));
|
this.get('stream').addObject(post.get('id'));
|
||||||
|
return "staged";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return "offScreen";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Commit the post we staged. Call this after a save succeeds.
|
// Commit the post we staged. Call this after a save succeeds.
|
||||||
|
|
Loading…
Reference in New Issue