mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 06:35:45 +08:00
FEATURE: go to inbox after archiving a message
This commit is contained in:
parent
06b5798fb9
commit
65e808b26d
@ -6,6 +6,7 @@ import Quote from 'discourse/lib/quote';
|
|||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
import computed from 'ember-addons/ember-computed-decorators';
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
import Composer from 'discourse/models/composer';
|
import Composer from 'discourse/models/composer';
|
||||||
|
import DiscourseURL from 'discourse/lib/url';
|
||||||
|
|
||||||
export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
needs: ['header', 'modal', 'composer', 'quote-button', 'topic-progress', 'application'],
|
needs: ['header', 'modal', 'composer', 'quote-button', 'topic-progress', 'application'],
|
||||||
@ -96,6 +97,14 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||||||
return !isPrivateMessage && !containsMessages;
|
return !isPrivateMessage && !containsMessages;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
gotoInbox(name) {
|
||||||
|
var url = '/users/' + this.get('currentUser.username_lower') + '/messages';
|
||||||
|
if (name) {
|
||||||
|
url = url + '/group/' + name;
|
||||||
|
}
|
||||||
|
DiscourseURL.routeTo(url);
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
showTopicAdminMenu() {
|
showTopicAdminMenu() {
|
||||||
this.set('adminMenuVisible', true);
|
this.set('adminMenuVisible', true);
|
||||||
@ -109,12 +118,19 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||||||
this.deleteTopic();
|
this.deleteTopic();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
archiveMessage() {
|
archiveMessage() {
|
||||||
this.get('model').archiveMessage();
|
const topic = this.get('model');
|
||||||
|
topic.archiveMessage().then(()=>{
|
||||||
|
this.gotoInbox(topic.get("inboxGroupName"));
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
moveToInbox() {
|
moveToInbox() {
|
||||||
this.get('model').moveToInbox();
|
const topic = this.get('model');
|
||||||
|
topic.moveToInbox().then(()=>{
|
||||||
|
this.gotoInbox(topic.get("inboxGroupName"));
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Post related methods
|
// Post related methods
|
||||||
|
@ -424,8 +424,12 @@ const Topic = RestModel.extend({
|
|||||||
this.set("archiving", true);
|
this.set("archiving", true);
|
||||||
var promise = Discourse.ajax(`/t/${this.get('id')}/archive-message`, {type: 'PUT'});
|
var promise = Discourse.ajax(`/t/${this.get('id')}/archive-message`, {type: 'PUT'});
|
||||||
|
|
||||||
promise.then(()=>this.set('message_archived', true))
|
promise.then((msg)=> {
|
||||||
.finally(()=>this.set('archiving', false));
|
this.set('message_archived', true);
|
||||||
|
if (msg && msg.group_name) {
|
||||||
|
this.set('inboxGroupName', msg.group_name);
|
||||||
|
}
|
||||||
|
}).finally(()=>this.set('archiving', false));
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
@ -434,8 +438,12 @@ const Topic = RestModel.extend({
|
|||||||
this.set("archiving", true);
|
this.set("archiving", true);
|
||||||
var promise = Discourse.ajax(`/t/${this.get('id')}/move-to-inbox`, {type: 'PUT'});
|
var promise = Discourse.ajax(`/t/${this.get('id')}/move-to-inbox`, {type: 'PUT'});
|
||||||
|
|
||||||
promise.then(()=>this.set('message_archived', false))
|
promise.then((msg)=> {
|
||||||
.finally(()=>this.set('archiving', false));
|
this.set('message_archived', false);
|
||||||
|
if (msg && msg.group_name) {
|
||||||
|
this.set('inboxGroupName', msg.group_name);
|
||||||
|
}
|
||||||
|
}).finally(()=>this.set('archiving', false));
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -281,6 +281,9 @@ class TopicsController < ApplicationController
|
|||||||
|
|
||||||
def toggle_archive_message(archive)
|
def toggle_archive_message(archive)
|
||||||
topic = Topic.find(params[:id].to_i)
|
topic = Topic.find(params[:id].to_i)
|
||||||
|
|
||||||
|
group_id = nil
|
||||||
|
|
||||||
group_ids = current_user.groups.pluck(:id)
|
group_ids = current_user.groups.pluck(:id)
|
||||||
if group_ids.present?
|
if group_ids.present?
|
||||||
allowed_groups = topic.allowed_groups
|
allowed_groups = topic.allowed_groups
|
||||||
@ -289,6 +292,7 @@ class TopicsController < ApplicationController
|
|||||||
GroupArchivedMessage.where(group_id: id, topic_id: topic.id).destroy_all
|
GroupArchivedMessage.where(group_id: id, topic_id: topic.id).destroy_all
|
||||||
|
|
||||||
if archive
|
if archive
|
||||||
|
group_id = id
|
||||||
GroupArchivedMessage.create!(group_id: id, topic_id: topic.id)
|
GroupArchivedMessage.create!(group_id: id, topic_id: topic.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -302,8 +306,13 @@ class TopicsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if group_id
|
||||||
|
name = Group.find_by(id: group_id).try(:name)
|
||||||
|
render_json_dump(group_name: name)
|
||||||
|
else
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def bookmark
|
def bookmark
|
||||||
topic = Topic.find(params[:topic_id].to_i)
|
topic = Topic.find(params[:topic_id].to_i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user