diff --git a/app/assets/javascripts/discourse/controllers/user_activity_controller.js b/app/assets/javascripts/discourse/controllers/user_activity_controller.js index 038d786bc07..e765f09fee0 100644 --- a/app/assets/javascripts/discourse/controllers/user_activity_controller.js +++ b/app/assets/javascripts/discourse/controllers/user_activity_controller.js @@ -24,5 +24,6 @@ Discourse.UserActivityController = Discourse.ObjectController.extend({ }, privateMessagesActive: Em.computed.equal('pmView', 'index'), - privateMessagesSentActive: Em.computed.equal('pmView', 'sent') + privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), + privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread') }); diff --git a/app/assets/javascripts/discourse/routes/application_routes.js b/app/assets/javascripts/discourse/routes/application_routes.js index 663314d3fda..5772dc6a3db 100644 --- a/app/assets/javascripts/discourse/routes/application_routes.js +++ b/app/assets/javascripts/discourse/routes/application_routes.js @@ -50,7 +50,8 @@ Discourse.Route.buildRoutes(function() { }); this.resource('userPrivateMessages', { path: '/private-messages' }, function() { - this.route('sent', {path: '/messages-sent'}); + this.route('mine', {path: '/mine'}); + this.route('unread', {path: '/unread'}); }); this.resource('preferences', { path: '/preferences' }, function() { diff --git a/app/assets/javascripts/discourse/routes/user_routes.js b/app/assets/javascripts/discourse/routes/user_routes.js index 9ff40c4b188..ab8d8699bf4 100644 --- a/app/assets/javascripts/discourse/routes/user_routes.js +++ b/app/assets/javascripts/discourse/routes/user_routes.js @@ -171,33 +171,26 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({ } }); -Discourse.UserPrivateMessagesIndexRoute = Discourse.UserTopicListRoute.extend({ - userActionType: Discourse.UserAction.TYPES.messages_received, +function createPMRoute(viewName, path, type) { + return Discourse.UserTopicListRoute.extend({ + userActionType: Discourse.UserAction.TYPES.messages_received, - model: function() { - return Discourse.TopicList.find('topics/private-messages/' + this.modelFor('user').get('username_lower')); - }, + model: function() { + return Discourse.TopicList.find('topics/' + path + '/' + this.modelFor('user').get('username_lower')); + }, - setupController: function(controller, model) { - this._super(controller, model); - controller.set('hideCategories', true); - this.controllerFor('userActivity').set('pmView', 'index'); - } + setupController: function(controller, model) { + this._super(controller, model); + controller.set('hideCategories', true); + this.controllerFor('userActivity').set('pmView', viewName); + } + }); +} -}); -Discourse.UserPrivateMessagesSentRoute = Discourse.UserTopicListRoute.extend({ - userActionType: Discourse.UserAction.TYPES.messages_sent, +Discourse.UserPrivateMessagesIndexRoute = createPMRoute('index', 'private-messages'); +Discourse.UserPrivateMessagesMineRoute = createPMRoute('mine', 'private-messages-sent'); +Discourse.UserPrivateMessagesUnreadRoute = createPMRoute('unread', 'private-messages-unread'); - model: function() { - return Discourse.TopicList.find('topics/private-messages-sent/' + this.modelFor('user').get('username_lower')); - }, - - setupController: function(controller, model) { - this._super(controller, model); - controller.set('hideCategories', true); - this.controllerFor('userActivity').set('pmView', 'sent'); - } -}); Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({ userActionType: Discourse.UserAction.TYPES.topics, @@ -205,7 +198,6 @@ Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({ model: function() { return Discourse.TopicList.find('topics/created-by/' + this.modelFor('user').get('username_lower')); } - }); Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({ diff --git a/app/assets/javascripts/discourse/templates/user/activity.js.handlebars b/app/assets/javascripts/discourse/templates/user/activity.js.handlebars index bdf292ff011..03cd3c61dcc 100644 --- a/app/assets/javascripts/discourse/templates/user/activity.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/activity.js.handlebars @@ -16,10 +16,13 @@