ScheduledStatuses: import into reducer
This commit is contained in:
parent
600146f2be
commit
840706a500
|
@ -52,6 +52,7 @@ import profile_hover_card from './profile_hover_card';
|
||||||
import backups from './backups';
|
import backups from './backups';
|
||||||
import admin_log from './admin_log';
|
import admin_log from './admin_log';
|
||||||
import security from './security';
|
import security from './security';
|
||||||
|
import scheduled_statuses from './scheduled_statuses';
|
||||||
|
|
||||||
const appReducer = combineReducers({
|
const appReducer = combineReducers({
|
||||||
dropdown_menu,
|
dropdown_menu,
|
||||||
|
@ -105,6 +106,7 @@ const appReducer = combineReducers({
|
||||||
backups,
|
backups,
|
||||||
admin_log,
|
admin_log,
|
||||||
security,
|
security,
|
||||||
|
scheduled_statuses,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear the state (mostly) when the user logs out
|
// Clear the state (mostly) when the user logs out
|
||||||
|
|
|
@ -1,44 +1,24 @@
|
||||||
|
import { STATUS_CREATE_SUCCESS } from 'soapbox/actions/statuses';
|
||||||
|
import { STATUS_IMPORT, STATUSES_IMPORT } from '../actions/importer';
|
||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const importStatus = (state, status) => state.set(status.id, fromJS(status));
|
const importStatus = (state, status) => {
|
||||||
|
if (!status.scheduled_at) return state;
|
||||||
|
return state.set(status.id, fromJS(status));
|
||||||
|
};
|
||||||
|
|
||||||
const importStatuses = (state, statuses) =>
|
const importStatuses = (state, statuses) =>
|
||||||
state.withMutations(mutable => statuses.forEach(status => importStatus(mutable, status)));
|
state.withMutations(mutable => statuses.forEach(status => importStatus(mutable, status)));
|
||||||
|
|
||||||
const deleteStatus = (state, id, references) => {
|
|
||||||
references.forEach(ref => {
|
|
||||||
state = deleteStatus(state, ref[0], []);
|
|
||||||
});
|
|
||||||
|
|
||||||
return state.delete(id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
export default function statuses(state = initialState, action) {
|
export default function statuses(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case STATUS_IMPORT:
|
case STATUS_IMPORT:
|
||||||
|
case STATUS_CREATE_SUCCESS:
|
||||||
return importStatus(state, action.status);
|
return importStatus(state, action.status);
|
||||||
case STATUSES_IMPORT:
|
case STATUSES_IMPORT:
|
||||||
return importStatuses(state, action.statuses);
|
return importStatuses(state, action.statuses);
|
||||||
case STATUS_REVEAL:
|
|
||||||
return state.withMutations(map => {
|
|
||||||
action.ids.forEach(id => {
|
|
||||||
if (!(state.get(id) === undefined)) {
|
|
||||||
map.setIn([id, 'hidden'], false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
case STATUS_HIDE:
|
|
||||||
return state.withMutations(map => {
|
|
||||||
action.ids.forEach(id => {
|
|
||||||
if (!(state.get(id) === undefined)) {
|
|
||||||
map.setIn([id, 'hidden'], true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
case TIMELINE_DELETE:
|
|
||||||
return deleteStatus(state, action.id, action.references);
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@ const initialState = ImmutableMap({
|
||||||
loaded: false,
|
loaded: false,
|
||||||
items: ImmutableList(),
|
items: ImmutableList(),
|
||||||
}),
|
}),
|
||||||
|
scheduled_statuses: ImmutableMap({
|
||||||
|
next: null,
|
||||||
|
loaded: false,
|
||||||
|
items: ImmutableList(),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeList = (state, listType, statuses, next) => {
|
const normalizeList = (state, listType, statuses, next) => {
|
||||||
|
|
Loading…
Reference in New Issue