@@ -70,6 +70,8 @@ export const INIT_MEDIA_EDIT_MODAL = 'INIT_MEDIA_EDIT_MODAL';
7070export const COMPOSE_CHANGE_MEDIA_DESCRIPTION = 'COMPOSE_CHANGE_MEDIA_DESCRIPTION' ;
7171export const COMPOSE_CHANGE_MEDIA_FOCUS = 'COMPOSE_CHANGE_MEDIA_FOCUS' ;
7272
73+ export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS' ;
74+
7375const messages = defineMessages ( {
7476 uploadErrorLimit : { id : 'upload_error.limit' , defaultMessage : 'File upload limit exceeded.' } ,
7577 uploadErrorPoll : { id : 'upload_error.poll' , defaultMessage : 'File upload not allowed with polls.' } ,
@@ -83,6 +85,15 @@ export const ensureComposeIsVisible = (getState, routerHistory) => {
8385 }
8486} ;
8587
88+ export function setComposeToStatus ( status , text , spoiler_text ) {
89+ return {
90+ type : COMPOSE_SET_STATUS ,
91+ status,
92+ text,
93+ spoiler_text,
94+ } ;
95+ } ;
96+
8697export function changeCompose ( text ) {
8798 return {
8899 type : COMPOSE_CHANGE ,
@@ -137,24 +148,28 @@ export function directCompose(account, routerHistory) {
137148
138149export function submitCompose ( routerHistory ) {
139150 return function ( dispatch , getState ) {
140- const status = getState ( ) . getIn ( [ 'compose' , 'text' ] , '' ) ;
141- const media = getState ( ) . getIn ( [ 'compose' , 'media_attachments' ] ) ;
151+ const status = getState ( ) . getIn ( [ 'compose' , 'text' ] , '' ) ;
152+ const media = getState ( ) . getIn ( [ 'compose' , 'media_attachments' ] ) ;
153+ const statusId = getState ( ) . getIn ( [ 'compose' , 'id' ] , null ) ;
142154
143155 if ( ( ! status || ! status . length ) && media . size === 0 ) {
144156 return ;
145157 }
146158
147159 dispatch ( submitComposeRequest ( ) ) ;
148160
149- api ( getState ) . post ( '/api/v1/statuses' , {
150- status,
151- in_reply_to_id : getState ( ) . getIn ( [ 'compose' , 'in_reply_to' ] , null ) ,
152- media_ids : media . map ( item => item . get ( 'id' ) ) ,
153- sensitive : getState ( ) . getIn ( [ 'compose' , 'sensitive' ] ) ,
154- spoiler_text : getState ( ) . getIn ( [ 'compose' , 'spoiler' ] ) ? getState ( ) . getIn ( [ 'compose' , 'spoiler_text' ] , '' ) : '' ,
155- visibility : getState ( ) . getIn ( [ 'compose' , 'privacy' ] ) ,
156- poll : getState ( ) . getIn ( [ 'compose' , 'poll' ] , null ) ,
157- } , {
161+ api ( getState ) . request ( {
162+ url : statusId === null ? '/api/v1/statuses' : `/api/v1/statuses/${ statusId } ` ,
163+ method : statusId === null ? 'post' : 'put' ,
164+ data : {
165+ status,
166+ in_reply_to_id : getState ( ) . getIn ( [ 'compose' , 'in_reply_to' ] , null ) ,
167+ media_ids : media . map ( item => item . get ( 'id' ) ) ,
168+ sensitive : getState ( ) . getIn ( [ 'compose' , 'sensitive' ] ) ,
169+ spoiler_text : getState ( ) . getIn ( [ 'compose' , 'spoiler' ] ) ? getState ( ) . getIn ( [ 'compose' , 'spoiler_text' ] , '' ) : '' ,
170+ visibility : getState ( ) . getIn ( [ 'compose' , 'privacy' ] ) ,
171+ poll : getState ( ) . getIn ( [ 'compose' , 'poll' ] , null ) ,
172+ } ,
158173 headers : {
159174 'Idempotency-Key' : getState ( ) . getIn ( [ 'compose' , 'idempotencyKey' ] ) ,
160175 } ,
@@ -176,11 +191,11 @@ export function submitCompose(routerHistory) {
176191 }
177192 } ;
178193
179- if ( response . data . visibility !== 'direct' ) {
194+ if ( statusId === null && response . data . visibility !== 'direct' ) {
180195 insertIfOnline ( 'home' ) ;
181196 }
182197
183- if ( response . data . in_reply_to_id === null && response . data . visibility === 'public' ) {
198+ if ( statusId === null && response . data . in_reply_to_id === null && response . data . visibility === 'public' ) {
184199 insertIfOnline ( 'community' ) ;
185200 insertIfOnline ( 'public' ) ;
186201 insertIfOnline ( `account:${ response . data . account . id } ` ) ;
0 commit comments