bigbuffet-rw/app/soapbox/reducers/index.js

128 lines
3.2 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import { combineReducers } from 'redux-immutable';
2020-09-27 17:09:35 -07:00
import { Map as ImmutableMap } from 'immutable';
import { AUTH_LOGGED_OUT } from 'soapbox/actions/auth';
2020-03-27 13:59:38 -07:00
import dropdown_menu from './dropdown_menu';
import timelines from './timelines';
import meta from './meta';
import alerts from './alerts';
import { loadingBarReducer } from 'react-redux-loading-bar';
import modal from './modal';
import user_lists from './user_lists';
import domain_lists from './domain_lists';
import accounts from './accounts';
import accounts_counters from './accounts_counters';
import statuses from './statuses';
import relationships from './relationships';
import settings from './settings';
import push_notifications from './push_notifications';
import status_lists from './status_lists';
import mutes from './mutes';
import reports from './reports';
import contexts from './contexts';
import compose from './compose';
import search from './search';
import media_attachments from './media_attachments';
import notifications from './notifications';
import height_cache from './height_cache';
import custom_emojis from './custom_emojis';
import lists from './lists';
import listEditor from './list_editor';
import listAdder from './list_adder';
import filters from './filters';
import conversations from './conversations';
import suggestions from './suggestions';
import polls from './polls';
import identity_proofs from './identity_proofs';
import trends from './trends';
import groups from './groups';
import group_relationships from './group_relationships';
import group_lists from './group_lists';
import group_editor from './group_editor';
import sidebar from './sidebar';
2020-03-31 15:45:12 -07:00
import patron from './patron';
import soapbox from './soapbox';
2020-04-01 13:05:52 -07:00
import instance from './instance';
import me from './me';
2020-04-05 14:54:51 -07:00
import auth from './auth';
import admin from './admin';
2020-08-24 19:26:42 -07:00
import chats from './chats';
2020-08-25 18:33:49 -07:00
import chat_messages from './chat_messages';
import chat_message_lists from './chat_message_lists';
import profile_hover_card from './profile_hover_card';
2021-01-07 12:17:06 -08:00
import backups from './backups';
2020-03-27 13:59:38 -07:00
2020-09-27 17:09:35 -07:00
const appReducer = combineReducers({
2020-03-27 13:59:38 -07:00
dropdown_menu,
timelines,
meta,
alerts,
loadingBar: loadingBarReducer,
modal,
user_lists,
domain_lists,
status_lists,
accounts,
accounts_counters,
statuses,
relationships,
settings,
push_notifications,
mutes,
reports,
contexts,
compose,
search,
media_attachments,
notifications,
height_cache,
custom_emojis,
identity_proofs,
lists,
listEditor,
listAdder,
filters,
conversations,
suggestions,
polls,
trends,
groups,
group_relationships,
group_lists,
group_editor,
sidebar,
2020-03-31 15:45:12 -07:00
patron,
soapbox,
2020-04-01 13:05:52 -07:00
instance,
me,
2020-04-05 14:54:51 -07:00
auth,
admin,
2020-08-24 19:26:42 -07:00
chats,
2020-08-25 18:33:49 -07:00
chat_messages,
chat_message_lists,
profile_hover_card,
2021-01-07 12:17:06 -08:00
backups,
2020-09-27 17:09:35 -07:00
});
// Clear the state (mostly) when the user logs out
const logOut = (state = ImmutableMap()) => {
const whitelist = ['instance', 'soapbox', 'custom_emojis'];
return ImmutableMap(
whitelist.reduce((acc, curr) => {
acc[curr] = state.get(curr);
return acc;
}, {}),
2020-09-27 17:09:35 -07:00
);
};
const rootReducer = (state, action) => {
switch(action.type) {
case AUTH_LOGGED_OUT:
return appReducer(logOut(state), action);
default:
return appReducer(state, action);
}
2020-03-27 13:59:38 -07:00
};
2020-09-27 17:09:35 -07:00
export default rootReducer;