@ -96,68 +96,68 @@ const insertSuggestion = (state, position, token, completion) => {
export default function compose ( state = initialState , action ) {
switch ( action . type ) {
case STORE _HYDRATE :
return state . merge ( action . state . get ( 'compose' ) ) ;
case COMPOSE _MOUNT :
return state . set ( 'mounted' , true ) ;
case COMPOSE _UNMOUNT :
return state . set ( 'mounted' , false ) ;
case COMPOSE _SENSITIVITY _CHANGE :
return state . set ( 'sensitive' , action . checked ) ;
case COMPOSE _SPOILERNESS _CHANGE :
return state . set ( 'spoiler' , action . checked ) ;
case COMPOSE _SPOILER _TEXT _CHANGE :
return state . set ( 'spoiler_text' , action . text ) ;
case COMPOSE _VISIBILITY _CHANGE :
return state . set ( 'private' , action . checked ) ;
case COMPOSE _LISTABILITY _CHANGE :
return state . set ( 'unlisted' , action . checked ) ;
case COMPOSE _CHANGE :
return state . set ( 'text' , action . text ) ;
case COMPOSE _REPLY :
return state . withMutations ( map => {
map . set ( 'in_reply_to' , action . status . get ( 'id' ) ) ;
map . set ( 'text' , statusToTextMentions ( state , action . status ) ) ;
} ) ;
case COMPOSE _REPLY _CANCEL :
return state . withMutations ( map => {
map . set ( 'in_reply_to' , null ) ;
map . set ( 'text' , '' ) ;
} ) ;
case COMPOSE _SUBMIT _REQUEST :
return state . set ( 'is_submitting' , true ) ;
case COMPOSE _SUBMIT _SUCCESS :
return clearAll ( state ) ;
case COMPOSE _SUBMIT _FAIL :
return state . set ( 'is_submitting' , false ) ;
case COMPOSE _UPLOAD _REQUEST :
return state . withMutations ( map => {
map . set ( 'is_uploading' , true ) ;
map . set ( 'fileDropDate' , new Date ( ) ) ;
} ) ;
case COMPOSE _UPLOAD _SUCCESS :
return appendMedia ( state , Immutable . fromJS ( action . media ) ) ;
case COMPOSE _UPLOAD _FAIL :
return state . set ( 'is_uploading' , false ) ;
case COMPOSE _UPLOAD _UNDO :
return removeMedia ( state , action . media _id ) ;
case COMPOSE _UPLOAD _PROGRESS :
return state . set ( 'progress' , Math . round ( ( action . loaded / action . total ) * 100 ) ) ;
case COMPOSE _MENTION :
return state . update ( 'text' , text => ` ${ text } @ ${ action . account . get ( 'acct' ) } ` ) ;
case COMPOSE _SUGGESTIONS _CLEAR :
return state . update ( 'suggestions' , Immutable . List ( ) , list => list . clear ( ) ) . set ( 'suggestion_token' , null ) ;
case COMPOSE _SUGGESTIONS _READY :
return state . set ( 'suggestions' , Immutable . List ( action . accounts . map ( item => item . id ) ) ) . set ( 'suggestion_token' , action . token ) ;
case COMPOSE _SUGGESTION _SELECT :
return insertSuggestion ( state , action . position , action . token , action . completion ) ;
case TIMELINE _DELETE :
if ( action . id === state . get ( 'in_reply_to' ) ) {
return state . set ( 'in_reply_to' , null ) ;
} else {
return state ;
}
default :
case STORE _HYDRATE :
return state . merge ( action . state . get ( 'compose' ) ) ;
case COMPOSE _MOUNT :
return state . set ( 'mounted' , true ) ;
case COMPOSE _UNMOUNT :
return state . set ( 'mounted' , false ) ;
case COMPOSE _SENSITIVITY _CHANGE :
return state . set ( 'sensitive' , action . checked ) ;
case COMPOSE _SPOILERNESS _CHANGE :
return ( action . checked ? state : state . set ( 'spoiler_text' , '' ) ) . set ( 'spoiler' , action . checked ) ;
case COMPOSE _SPOILER _TEXT _CHANGE :
return state . set ( 'spoiler_text' , action . text ) ;
case COMPOSE _VISIBILITY _CHANGE :
return state . set ( 'private' , action . checked ) ;
case COMPOSE _LISTABILITY _CHANGE :
return state . set ( 'unlisted' , action . checked ) ;
case COMPOSE _CHANGE :
return state . set ( 'text' , action . text ) ;
case COMPOSE _REPLY :
return state . withMutations ( map => {
map . set ( 'in_reply_to' , action . status . get ( 'id' ) ) ;
map . set ( 'text' , statusToTextMentions ( state , action . status ) ) ;
} ) ;
case COMPOSE _REPLY _CANCEL :
return state . withMutations ( map => {
map . set ( 'in_reply_to' , null ) ;
map . set ( 'text' , '' ) ;
} ) ;
case COMPOSE _SUBMIT _REQUEST :
return state . set ( 'is_submitting' , true ) ;
case COMPOSE _SUBMIT _SUCCESS :
return clearAll ( state ) ;
case COMPOSE _SUBMIT _FAIL :
return state . set ( 'is_submitting' , false ) ;
case COMPOSE _UPLOAD _REQUEST :
return state . withMutations ( map => {
map . set ( 'is_uploading' , true ) ;
map . set ( 'fileDropDate' , new Date ( ) ) ;
} ) ;
case COMPOSE _UPLOAD _SUCCESS :
return appendMedia ( state , Immutable . fromJS ( action . media ) ) ;
case COMPOSE _UPLOAD _FAIL :
return state . set ( 'is_uploading' , false ) ;
case COMPOSE _UPLOAD _UNDO :
return removeMedia ( state , action . media _id ) ;
case COMPOSE _UPLOAD _PROGRESS :
return state . set ( 'progress' , Math . round ( ( action . loaded / action . total ) * 100 ) ) ;
case COMPOSE _MENTION :
return state . update ( 'text' , text => ` ${ text } @ ${ action . account . get ( 'acct' ) } ` ) ;
case COMPOSE _SUGGESTIONS _CLEAR :
return state . update ( 'suggestions' , Immutable . List ( ) , list => list . clear ( ) ) . set ( 'suggestion_token' , null ) ;
case COMPOSE _SUGGESTIONS _READY :
return state . set ( 'suggestions' , Immutable . List ( action . accounts . map ( item => item . id ) ) ) . set ( 'suggestion_token' , action . token ) ;
case COMPOSE _SUGGESTION _SELECT :
return insertSuggestion ( state , action . position , action . token , action . completion ) ;
case TIMELINE _DELETE :
if ( action . id === state . get ( 'in_reply_to' ) ) {
return state . set ( 'in_reply_to' , null ) ;
} else {
return state ;
}
default :
return state ;
}
} ;