mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: New action arriving in stream via message bus
This commit is contained in:
parent
1147b9d2e5
commit
d53ac36818
5 changed files with 20 additions and 17 deletions
|
@ -21,16 +21,16 @@ export default Discourse.ObjectController.extend({
|
|||
if( this.get('newUsername') && this.get('newUsername').length < 3 ) {
|
||||
this.set('errorMessage', I18n.t('user.name.too_short'));
|
||||
} else {
|
||||
var preferencesUsernameController = this;
|
||||
var self = this;
|
||||
this.set('taken', false);
|
||||
this.set('errorMessage', null);
|
||||
if (this.blank('newUsername')) return;
|
||||
if (this.get('unchanged')) return;
|
||||
Discourse.User.checkUsername(this.get('newUsername'), undefined, this.get('content.id')).then(function(result) {
|
||||
if (result.errors) {
|
||||
preferencesUsernameController.set('errorMessage', result.errors.join(' '));
|
||||
self.set('errorMessage', result.errors.join(' '));
|
||||
} else if (result.available === false) {
|
||||
preferencesUsernameController.set('taken', true);
|
||||
self.set('taken', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -43,16 +43,16 @@ export default Discourse.ObjectController.extend({
|
|||
|
||||
actions: {
|
||||
changeUsername: function() {
|
||||
var preferencesUsernameController = this;
|
||||
var self = this;
|
||||
return bootbox.confirm(I18n.t("user.change_username.confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||
if (result) {
|
||||
preferencesUsernameController.set('saving', true);
|
||||
preferencesUsernameController.get('content').changeUsername(preferencesUsernameController.get('newUsername')).then(function() {
|
||||
Discourse.URL.redirectTo("/users/" + preferencesUsernameController.get('newUsername').toLowerCase() + "/preferences");
|
||||
self.set('saving', true);
|
||||
self.get('content').changeUsername(self.get('newUsername')).then(function() {
|
||||
Discourse.URL.redirectTo("/users/" + self.get('newUsername').toLowerCase() + "/preferences");
|
||||
}, function() {
|
||||
// error
|
||||
preferencesUsernameController.set('error', true);
|
||||
preferencesUsernameController.set('saving', false);
|
||||
self.set('error', true);
|
||||
self.set('saving', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -257,8 +257,8 @@ Discourse.User = Discourse.Model.extend({
|
|||
if (result) {
|
||||
if ((user.get('streamFilter') || result.action_type) !== result.action_type) return;
|
||||
var action = Discourse.UserAction.collapseStream([Discourse.UserAction.create(result)]);
|
||||
stream.set('itemsLoaded', user.get('itemsLoaded') + 1);
|
||||
stream.insertAt(0, action[0]);
|
||||
stream.set('itemsLoaded', stream.get('itemsLoaded') + 1);
|
||||
stream.get('content').insertAt(0, action[0]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -71,10 +71,6 @@ Discourse.UserStream = Discourse.Model.extend({
|
|||
url += "&filter=" + this.get('filterParam');
|
||||
}
|
||||
|
||||
var loadingFinished = function() {
|
||||
userStream.set('loading', false);
|
||||
};
|
||||
|
||||
return Discourse.ajax(url, {cache: 'false'}).then( function(result) {
|
||||
if (result && result.user_actions) {
|
||||
var copy = Em.A();
|
||||
|
@ -88,8 +84,9 @@ Discourse.UserStream = Discourse.Model.extend({
|
|||
itemsLoaded: userStream.get('itemsLoaded') + result.user_actions.length
|
||||
});
|
||||
}
|
||||
loadingFinished();
|
||||
}, loadingFinished);
|
||||
}).finally(function() {
|
||||
userStream.set('loading', false);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -21,6 +21,8 @@ Discourse.UserStreamView = Discourse.View.extend(Discourse.LoadMore, {
|
|||
stream.findItems().then(function() {
|
||||
self.set('loading', false);
|
||||
self.get('eyeline').flushRest();
|
||||
}).catch(function() {
|
||||
// If we were already loading...
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ class UserAction < ActiveRecord::Base
|
|||
# having strings where you would expect bools
|
||||
class UserActionRow < OpenStruct
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
def as_json(options = nil)
|
||||
@table.as_json(options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.last_action_in_topic(user_id, topic_id)
|
||||
|
|
Loading…
Reference in a new issue