diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-23 22:21:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 22:21:58 +0100 |
commit | e48eaf64cc7cb0cfab388331c4823ee5fb580d59 (patch) | |
tree | 18daedde9a2b7087e0b5e160680ed366cdd02546 /app/javascript/flavours/glitch/reducers | |
parent | 8c9c05d57914236dc7104a67e84743e1ce36f7cc (diff) | |
parent | 41ef41b9006e42b4001ebd89a3091fce609359fc (diff) |
Merge pull request #1701 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours/glitch/reducers')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/index.js | 4 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/reducers/reports.js | 77 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/reducers/rules.js | 13 |
3 files changed, 15 insertions, 79 deletions
diff --git a/app/javascript/flavours/glitch/reducers/index.js b/app/javascript/flavours/glitch/reducers/index.js index d9123b103..92348c0c5 100644 --- a/app/javascript/flavours/glitch/reducers/index.js +++ b/app/javascript/flavours/glitch/reducers/index.js @@ -17,7 +17,7 @@ import push_notifications from './push_notifications'; import status_lists from './status_lists'; import mutes from './mutes'; import blocks from './blocks'; -import reports from './reports'; +import rules from './rules'; import boosts from './boosts'; import contexts from './contexts'; import compose from './compose'; @@ -64,7 +64,7 @@ const reducers = { push_notifications, mutes, blocks, - reports, + rules, boosts, contexts, compose, diff --git a/app/javascript/flavours/glitch/reducers/reports.js b/app/javascript/flavours/glitch/reducers/reports.js deleted file mode 100644 index 1f7f3f273..000000000 --- a/app/javascript/flavours/glitch/reducers/reports.js +++ /dev/null @@ -1,77 +0,0 @@ -import { - REPORT_INIT, - REPORT_SUBMIT_REQUEST, - REPORT_SUBMIT_SUCCESS, - REPORT_SUBMIT_FAIL, - REPORT_CANCEL, - REPORT_STATUS_TOGGLE, - REPORT_COMMENT_CHANGE, - REPORT_FORWARD_CHANGE, -} from 'flavours/glitch/actions/reports'; -import { - TIMELINE_DELETE, -} from 'flavours/glitch/actions/timelines'; -import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable'; - -const initialState = ImmutableMap({ - new: ImmutableMap({ - isSubmitting: false, - account_id: null, - status_ids: ImmutableSet(), - comment: '', - forward: false, - }), -}); - -const deleteStatus = (state, id, references) => { - references.forEach(ref => { - state = deleteStatus(state, ref[0], []); - }); - - return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.remove(id)); -}; - -export default function reports(state = initialState, action) { - switch(action.type) { - case REPORT_INIT: - return state.withMutations(map => { - map.setIn(['new', 'isSubmitting'], false); - map.setIn(['new', 'account_id'], action.account.get('id')); - - if (state.getIn(['new', 'account_id']) !== action.account.get('id')) { - map.setIn(['new', 'status_ids'], action.status ? ImmutableSet([action.status.getIn(['reblog', 'id'], action.status.get('id'))]) : ImmutableSet()); - map.setIn(['new', 'comment'], ''); - } else if (action.status) { - map.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.add(action.status.getIn(['reblog', 'id'], action.status.get('id')))); - } - }); - case REPORT_STATUS_TOGGLE: - return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => { - if (action.checked) { - return set.add(action.statusId); - } - - return set.remove(action.statusId); - }); - case REPORT_COMMENT_CHANGE: - return state.setIn(['new', 'comment'], action.comment); - case REPORT_FORWARD_CHANGE: - return state.setIn(['new', 'forward'], action.forward); - case REPORT_SUBMIT_REQUEST: - return state.setIn(['new', 'isSubmitting'], true); - case REPORT_SUBMIT_FAIL: - return state.setIn(['new', 'isSubmitting'], false); - case REPORT_CANCEL: - case REPORT_SUBMIT_SUCCESS: - return state.withMutations(map => { - map.setIn(['new', 'account_id'], null); - map.setIn(['new', 'status_ids'], ImmutableSet()); - map.setIn(['new', 'comment'], ''); - map.setIn(['new', 'isSubmitting'], false); - }); - case TIMELINE_DELETE: - return deleteStatus(state, action.id, action.references); - default: - return state; - } -}; diff --git a/app/javascript/flavours/glitch/reducers/rules.js b/app/javascript/flavours/glitch/reducers/rules.js new file mode 100644 index 000000000..6cc2230bc --- /dev/null +++ b/app/javascript/flavours/glitch/reducers/rules.js @@ -0,0 +1,13 @@ +import { RULES_FETCH_SUCCESS } from 'flavours/glitch/actions/rules'; +import { List as ImmutableList, fromJS } from 'immutable'; + +const initialState = ImmutableList(); + +export default function rules(state = initialState, action) { + switch (action.type) { + case RULES_FETCH_SUCCESS: + return fromJS(action.rules); + default: + return state; + } +} |