2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

Improvements to user drafts (#6226)

* drafts in user profile: only show to user herself (not to admins), use avatar replying to (instead of topic OP), add keyboard shortcut for drafts, simplify display labels

* use JSON when testing Draft.stream
This commit is contained in:
Penar Musaraj 2018-08-01 17:41:27 -04:00 committed by Sam
parent 8147130412
commit 4a872823e7
12 changed files with 34 additions and 54 deletions

View file

@ -16,29 +16,29 @@ class DraftsController < ApplicationController
limit: params[:limit]
}
guardian.ensure_can_see_drafts!(user)
stream = Draft.stream(opts)
stream.each do |d|
parsed_data = JSON.parse(d.data)
if parsed_data
if parsed_data['reply']
d.raw = parsed_data['reply']
end
if parsed_data['categoryId'].present? && !d.category_id.present?
d.category_id = parsed_data['categoryId']
help_key = "user_activity.no_drafts"
if user == current_user
stream = Draft.stream(opts)
stream.each do |d|
parsed_data = JSON.parse(d.data)
if parsed_data
if parsed_data['reply']
d.raw = parsed_data['reply']
end
if parsed_data['categoryId'].present? && !d.category_id.present?
d.category_id = parsed_data['categoryId']
end
end
end
end
help_key = "user_activity.no_drafts"
if user == current_user
help_key += ".self"
else
help_key += ".others"
end
render json: {
drafts: serialize_data(stream, DraftSerializer),
drafts: stream ? serialize_data(stream, DraftSerializer) : [],
no_results_help: I18n.t(help_key)
}