diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js index e6a01bbe4..a68bb037c 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_controller.js @@ -473,6 +473,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected removeAllowedUser: function(username) { this.get('details').removeAllowedUser(username); } + }); diff --git a/app/assets/javascripts/discourse/models/topic_details.js b/app/assets/javascripts/discourse/models/topic_details.js index a4f4858e9..59fe80302 100644 --- a/app/assets/javascripts/discourse/models/topic_details.js +++ b/app/assets/javascripts/discourse/models/topic_details.js @@ -49,6 +49,19 @@ Discourse.TopicDetails = Discourse.Model.extend({ type: 'POST', data: { notification_level: v } }); - } + }, + removeAllowedUser: function(username) { + var users = this.get('allowed_users'); + Discourse.ajax("/t/" + this.get('topic.id') + "/remove-allowed-user", { + type: 'PUT', + data: { username: username } + }).then(function(res) { + users.forEach(function(user, i) { + if (user.username === username) { + users.removeAt(i); + } + }); + }); + } });