mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Add toot source to delete result to ease Delete & Redraft (#10669)
* Return Status with raw text in raw_content when deleting a status * Use raw content if available on delete & redraft * Rename raw_content to text; do not serialize formatted content when source is requested
This commit is contained in:
parent
be851321c0
commit
6d44f2441b
@ -65,7 +65,7 @@ class Api::V1::StatusesController < Api::BaseController
|
||||
|
||||
RemovalWorker.perform_async(@status.id)
|
||||
|
||||
render_empty
|
||||
render json: @status, serializer: REST::StatusSerializer, source_requested: true
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -131,10 +131,11 @@ export function fetchStatusFail(id, error, skipLoading) {
|
||||
};
|
||||
};
|
||||
|
||||
export function redraft(status) {
|
||||
export function redraft(status, raw_text) {
|
||||
return {
|
||||
type: REDRAFT,
|
||||
status,
|
||||
raw_text,
|
||||
};
|
||||
};
|
||||
|
||||
@ -148,13 +149,13 @@ export function deleteStatus(id, router, withRedraft = false) {
|
||||
|
||||
dispatch(deleteStatusRequest(id));
|
||||
|
||||
api(getState).delete(`/api/v1/statuses/${id}`).then(() => {
|
||||
api(getState).delete(`/api/v1/statuses/${id}`).then(response => {
|
||||
evictStatus(id);
|
||||
dispatch(deleteStatusSuccess(id));
|
||||
dispatch(deleteFromTimelines(id));
|
||||
|
||||
if (withRedraft) {
|
||||
dispatch(redraft(status));
|
||||
dispatch(redraft(status, response.data.text));
|
||||
|
||||
if (!getState().getIn(['compose', 'mounted'])) {
|
||||
router.push('/statuses/new');
|
||||
|
@ -331,7 +331,7 @@ export default function compose(state = initialState, action) {
|
||||
}));
|
||||
case REDRAFT:
|
||||
return state.withMutations(map => {
|
||||
map.set('text', unescapeHTML(expandMentions(action.status)));
|
||||
map.set('text', action.raw_content || unescapeHTML(expandMentions(action.status)));
|
||||
map.set('in_reply_to', action.status.get('in_reply_to_id'));
|
||||
map.set('privacy', action.status.get('visibility'));
|
||||
map.set('media_attachments', action.status.get('media_attachments'));
|
||||
|
@ -3,7 +3,7 @@
|
||||
class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id,
|
||||
:sensitive, :spoiler_text, :visibility, :language,
|
||||
:uri, :content, :url, :replies_count, :reblogs_count,
|
||||
:uri, :url, :replies_count, :reblogs_count,
|
||||
:favourites_count
|
||||
|
||||
attribute :favourited, if: :current_user?
|
||||
@ -11,6 +11,9 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attribute :muted, if: :current_user?
|
||||
attribute :pinned, if: :pinnable?
|
||||
|
||||
attribute :content, unless: :source_requested?
|
||||
attribute :text, if: :source_requested?
|
||||
|
||||
belongs_to :reblog, serializer: REST::StatusSerializer
|
||||
belongs_to :application, if: :show_application?
|
||||
belongs_to :account, serializer: REST::AccountSerializer
|
||||
@ -105,6 +108,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
%w(public unlisted).include?(object.visibility)
|
||||
end
|
||||
|
||||
def source_requested?
|
||||
instance_options[:source_requested]
|
||||
end
|
||||
|
||||
def ordered_mentions
|
||||
object.active_mentions.to_a.sort_by(&:id)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user