diff --git a/app/assets/javascripts/discourse/routes/build-private-messages-route.js.es6 b/app/assets/javascripts/discourse/routes/build-private-messages-route.js.es6 index a0ae48b6b3e..3db308bbfc2 100644 --- a/app/assets/javascripts/discourse/routes/build-private-messages-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-private-messages-route.js.es6 @@ -5,6 +5,11 @@ export default (viewName, path, channel) => { return UserTopicListRoute.extend({ userActionType: Discourse.UserAction.TYPES.messages_received, + titleToken() { + const key = viewName === "index" ? "inbox" : viewName; + return [I18n.t(`user.messages.${key}`), I18n.t("user.private_messages")]; + }, + actions: { didTransition() { this.controllerFor("user-topics-list")._showFooter(); diff --git a/app/assets/javascripts/discourse/routes/user-private-messages-group-archive.js.es6 b/app/assets/javascripts/discourse/routes/user-private-messages-group-archive.js.es6 index 0f446249383..0594b9d1128 100644 --- a/app/assets/javascripts/discourse/routes/user-private-messages-group-archive.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-private-messages-group-archive.js.es6 @@ -1,27 +1,41 @@ import createPMRoute from "discourse/routes/build-private-messages-route"; export default createPMRoute('groups', 'private-messages-groups').extend({ - model(params) { - const username = this.modelFor("user").get("username_lower"); - return this.store.findFiltered("topicList", { - filter: `topics/private-messages-group/${username}/${params.name}/archive` - }); - }, + groupName: null, - afterModel(model) { - const split = model.get("filter").split('/'); - const groupName = split[split.length-2]; - const groups = this.modelFor("user").get("groups"); - const group = _.first(groups.filterBy("name", groupName)); - this.controllerFor("user-private-messages").set("group", group); - }, + titleToken() { + const groupName = this.get('groupName'); - setupController(controller, model) { - this._super.apply(this, arguments); - const split = model.get("filter").split('/'); - const group = split[split.length-2]; - this.controllerFor("user-private-messages").set("groupFilter", group); - this.controllerFor("user-private-messages").set("archive", true); - this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}/archive`); - } + if (groupName) { + return [ + `${groupName.capitalize()} ${I18n.t('user.messages.archive')}`, + I18n.t("user.private_messages") + ]; + }; + }, + + model(params) { + const username = this.modelFor("user").get("username_lower"); + return this.store.findFiltered("topicList", { + filter: `topics/private-messages-group/${username}/${params.name}/archive` + }); + }, + + afterModel(model) { + const split = model.get("filter").split('/'); + const groupName = split[split.length-2]; + this.set("groupName", groupName); + const groups = this.modelFor("user").get("groups"); + const group = _.first(groups.filterBy("name", groupName)); + this.controllerFor("user-private-messages").set("group", group); + }, + + setupController(controller, model) { + this._super.apply(this, arguments); + const split = model.get("filter").split('/'); + const group = split[split.length-2]; + this.controllerFor("user-private-messages").set("groupFilter", group); + this.controllerFor("user-private-messages").set("archive", true); + this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}/archive`); + } }); diff --git a/app/assets/javascripts/discourse/routes/user-private-messages-group.js.es6 b/app/assets/javascripts/discourse/routes/user-private-messages-group.js.es6 index f02361f3bad..556f65fded1 100644 --- a/app/assets/javascripts/discourse/routes/user-private-messages-group.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-private-messages-group.js.es6 @@ -1,25 +1,33 @@ import createPMRoute from "discourse/routes/build-private-messages-route"; export default createPMRoute('groups', 'private-messages-groups').extend({ - model(params) { - const username = this.modelFor("user").get("username_lower"); - return this.store.findFiltered("topicList", { - filter: `topics/private-messages-group/${username}/${params.name}` - }); - }, + groupName: null, - afterModel(model) { - const groupName = _.last(model.get("filter").split('/')); - const groups = this.modelFor("user").get("groups"); - const group = _.first(groups.filterBy("name", groupName)); - this.controllerFor("user-private-messages").set("group", group); - }, + titleToken() { + const groupName = this.get('groupName'); + if (groupName) return [groupName.capitalize(), I18n.t("user.private_messages")]; + }, - setupController(controller, model) { - this._super.apply(this, arguments); - const group = _.last(model.get("filter").split('/')); - this.controllerFor("user-private-messages").set("groupFilter", group); - this.controllerFor("user-private-messages").set("archive", false); - this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}`); - } + model(params) { + const username = this.modelFor("user").get("username_lower"); + return this.store.findFiltered("topicList", { + filter: `topics/private-messages-group/${username}/${params.name}` + }); + }, + + afterModel(model) { + const groupName = _.last(model.get("filter").split('/')); + this.set("groupName", groupName); + const groups = this.modelFor("user").get("groups"); + const group = _.first(groups.filterBy("name", groupName)); + this.controllerFor("user-private-messages").set("group", group); + }, + + setupController(controller, model) { + this._super.apply(this, arguments); + const group = _.last(model.get("filter").split('/')); + this.controllerFor("user-private-messages").set("groupFilter", group); + this.controllerFor("user-private-messages").set("archive", false); + this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}`); + } });