glitch: reducers: set up correct state for quoting

feature/quote
Ariadne Conill 2022-12-26 01:41:45 +00:00
parent 766a643811
commit 214a4c9e6b
1 changed files with 25 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import {
COMPOSE_REPLY, COMPOSE_REPLY,
COMPOSE_REPLY_CANCEL, COMPOSE_REPLY_CANCEL,
COMPOSE_DIRECT, COMPOSE_DIRECT,
COMPOSE_QUOTE,
COMPOSE_QUOTE_CANCEL,
COMPOSE_MENTION, COMPOSE_MENTION,
COMPOSE_SUBMIT_REQUEST, COMPOSE_SUBMIT_REQUEST,
COMPOSE_SUBMIT_SUCCESS, COMPOSE_SUBMIT_SUCCESS,
@ -85,6 +87,7 @@ const initialState = ImmutableMap({
caretPosition: null, caretPosition: null,
preselectDate: null, preselectDate: null,
in_reply_to: null, in_reply_to: null,
quote_id: null,
is_submitting: false, is_submitting: false,
is_uploading: false, is_uploading: false,
is_changing_upload: false, is_changing_upload: false,
@ -173,6 +176,7 @@ function clearAll(state) {
map.set('is_submitting', false); map.set('is_submitting', false);
map.set('is_changing_upload', false); map.set('is_changing_upload', false);
map.set('in_reply_to', null); map.set('in_reply_to', null);
map.set('quote_id', null);
map.update( map.update(
'advanced_options', 'advanced_options',
map => map.mergeWith(overwrite, state.get('default_advanced_options')) map => map.mergeWith(overwrite, state.get('default_advanced_options'))
@ -410,6 +414,7 @@ export default function compose(state = initialState, action) {
return state.withMutations(map => { return state.withMutations(map => {
map.set('id', null); map.set('id', null);
map.set('in_reply_to', action.status.get('id')); map.set('in_reply_to', action.status.get('id'));
map.set('quote_id', null);
map.set('text', statusToTextMentions(state, action.status)); map.set('text', statusToTextMentions(state, action.status));
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy'))); map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.update( map.update(
@ -439,6 +444,26 @@ export default function compose(state = initialState, action) {
}); });
case COMPOSE_REPLY_CANCEL: case COMPOSE_REPLY_CANCEL:
state = state.setIn(['advanced_options', 'threaded_mode'], false); state = state.setIn(['advanced_options', 'threaded_mode'], false);
case COMPOSE_QUOTE:
return state.withMutations(map => {
map.set('id', null);
map.set('in_reply_to', null);
map.set('quote_id', action.status.get('id'));
map.set('text', '');
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.update(
'advanced_options',
map => map.merge(new ImmutableMap({ do_not_federate: !!action.status.get('local_only') }))
);
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('preselectDate', new Date());
map.set('idempotencyKey', uuid());
console.log('COMPOSE_QUOTE, state:', map);
console.log('COMPOSE_QUOTE, action:', action);
});
case COMPOSE_QUOTE_CANCEL:
case COMPOSE_RESET: case COMPOSE_RESET:
return state.withMutations(map => { return state.withMutations(map => {
map.set('in_reply_to', null); map.set('in_reply_to', null);