2024-10-08 20:49:56 -07:00
|
|
|
import { combineReducers } from '@reduxjs/toolkit';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2024-08-28 04:41:08 -07:00
|
|
|
import { AUTH_LOGGED_OUT } from 'pl-fe/actions/auth';
|
|
|
|
import * as BuildConfig from 'pl-fe/build-config';
|
|
|
|
import entities from 'pl-fe/entity-store/reducer';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-11-16 05:32:32 -08:00
|
|
|
import accounts_meta from './accounts-meta';
|
2022-01-10 14:17:52 -08:00
|
|
|
import admin from './admin';
|
2022-12-25 15:31:07 -08:00
|
|
|
import admin_user_index from './admin-user-index';
|
2022-01-10 14:17:52 -08:00
|
|
|
import aliases from './aliases';
|
|
|
|
import auth from './auth';
|
|
|
|
import backups from './backups';
|
2020-03-27 13:59:38 -07:00
|
|
|
import compose from './compose';
|
2022-01-10 14:17:52 -08:00
|
|
|
import contexts from './contexts';
|
|
|
|
import conversations from './conversations';
|
2022-11-15 12:39:43 -08:00
|
|
|
import custom_emojis from './custom-emojis';
|
|
|
|
import domain_lists from './domain-lists';
|
2024-03-27 14:52:57 -07:00
|
|
|
import draft_statuses from './draft-statuses';
|
2020-03-27 13:59:38 -07:00
|
|
|
import filters from './filters';
|
2023-07-02 04:19:27 -07:00
|
|
|
import followed_tags from './followed-tags';
|
2022-04-27 13:50:35 -07:00
|
|
|
import history from './history';
|
2020-04-01 13:05:52 -07:00
|
|
|
import instance from './instance';
|
2022-11-15 12:39:43 -08:00
|
|
|
import listAdder from './list-adder';
|
|
|
|
import listEditor from './list-editor';
|
2022-01-10 14:17:52 -08:00
|
|
|
import lists from './lists';
|
2022-08-30 13:26:42 -07:00
|
|
|
import locations from './locations';
|
2020-04-01 19:20:47 -07:00
|
|
|
import me from './me';
|
2022-01-10 14:17:52 -08:00
|
|
|
import meta from './meta';
|
|
|
|
import mutes from './mutes';
|
|
|
|
import notifications from './notifications';
|
2022-05-02 13:55:52 -07:00
|
|
|
import onboarding from './onboarding';
|
2022-11-15 12:39:43 -08:00
|
|
|
import pending_statuses from './pending-statuses';
|
2024-08-28 05:48:35 -07:00
|
|
|
import plfe from './pl-fe';
|
2022-01-10 14:17:52 -08:00
|
|
|
import polls from './polls';
|
2022-11-15 12:39:43 -08:00
|
|
|
import push_notifications from './push-notifications';
|
|
|
|
import scheduled_statuses from './scheduled-statuses';
|
2022-01-10 14:17:52 -08:00
|
|
|
import search from './search';
|
|
|
|
import security from './security';
|
2022-11-15 12:39:43 -08:00
|
|
|
import status_lists from './status-lists';
|
2022-01-10 14:17:52 -08:00
|
|
|
import statuses from './statuses';
|
|
|
|
import suggestions from './suggestions';
|
2023-01-19 06:06:17 -08:00
|
|
|
import tags from './tags';
|
2022-01-10 14:17:52 -08:00
|
|
|
import timelines from './timelines';
|
2022-11-15 12:39:43 -08:00
|
|
|
import trending_statuses from './trending-statuses';
|
2022-01-10 14:17:52 -08:00
|
|
|
import trends from './trends';
|
2022-11-15 12:39:43 -08:00
|
|
|
import user_lists from './user-lists';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-03-09 13:24:42 -08:00
|
|
|
const reducers = {
|
2023-02-07 13:22:23 -08:00
|
|
|
accounts_meta,
|
|
|
|
admin,
|
|
|
|
admin_user_index,
|
|
|
|
aliases,
|
|
|
|
auth,
|
|
|
|
backups,
|
2020-03-27 13:59:38 -07:00
|
|
|
compose,
|
2023-02-07 13:22:23 -08:00
|
|
|
contexts,
|
|
|
|
conversations,
|
2020-03-27 13:59:38 -07:00
|
|
|
custom_emojis,
|
2023-02-07 13:22:23 -08:00
|
|
|
domain_lists,
|
2024-03-27 14:52:57 -07:00
|
|
|
draft_statuses,
|
2023-03-09 08:36:07 -08:00
|
|
|
entities,
|
2020-03-27 13:59:38 -07:00
|
|
|
filters,
|
2023-05-11 11:10:22 -07:00
|
|
|
followed_tags,
|
2023-02-07 13:22:23 -08:00
|
|
|
history,
|
2020-04-01 13:05:52 -07:00
|
|
|
instance,
|
2020-03-27 13:59:38 -07:00
|
|
|
listAdder,
|
2023-02-07 13:22:23 -08:00
|
|
|
listEditor,
|
|
|
|
lists,
|
2022-08-30 13:26:42 -07:00
|
|
|
locations,
|
2020-04-01 19:20:47 -07:00
|
|
|
me,
|
2023-02-07 13:22:23 -08:00
|
|
|
meta,
|
|
|
|
mutes,
|
|
|
|
notifications,
|
|
|
|
onboarding,
|
|
|
|
pending_statuses,
|
2024-08-28 04:41:08 -07:00
|
|
|
plfe,
|
2020-03-27 13:59:38 -07:00
|
|
|
polls,
|
2023-02-07 13:22:23 -08:00
|
|
|
push_notifications,
|
2021-06-27 12:58:40 -07:00
|
|
|
scheduled_statuses,
|
2023-02-07 13:22:23 -08:00
|
|
|
search,
|
|
|
|
security,
|
|
|
|
status_lists,
|
|
|
|
statuses,
|
|
|
|
suggestions,
|
2023-05-02 14:32:43 -07:00
|
|
|
tags,
|
2023-02-07 13:22:23 -08:00
|
|
|
timelines,
|
2022-03-21 11:09:01 -07:00
|
|
|
trending_statuses,
|
2023-02-07 13:22:23 -08:00
|
|
|
trends,
|
|
|
|
user_lists,
|
2022-03-09 13:24:42 -08:00
|
|
|
};
|
|
|
|
|
2024-10-08 20:49:56 -07:00
|
|
|
const appReducer = combineReducers(reducers);
|
2022-03-09 13:24:42 -08:00
|
|
|
|
2024-10-08 20:49:56 -07:00
|
|
|
type AppState = ReturnType<typeof appReducer>;
|
2020-09-27 17:09:35 -07:00
|
|
|
|
|
|
|
// Clear the state (mostly) when the user logs out
|
2024-10-08 20:49:56 -07:00
|
|
|
const logOut = (state: AppState): ReturnType<typeof appReducer> => {
|
2022-03-21 11:09:01 -07:00
|
|
|
if (BuildConfig.NODE_ENV === 'production') {
|
|
|
|
location.href = '/login';
|
|
|
|
}
|
|
|
|
|
2024-10-08 20:49:56 -07:00
|
|
|
const newState = rootReducer(undefined, { type: '' });
|
2020-09-27 17:09:35 -07:00
|
|
|
|
2024-10-08 20:49:56 -07:00
|
|
|
const { instance, plfe, custom_emojis, auth } = state;
|
|
|
|
return { ...newState, instance, plfe, custom_emojis, auth };
|
2020-09-27 17:09:35 -07:00
|
|
|
};
|
|
|
|
|
2022-03-15 06:48:18 -07:00
|
|
|
const rootReducer: typeof appReducer = (state, action) => {
|
2022-05-11 10:40:34 -07:00
|
|
|
switch (action.type) {
|
2022-05-11 14:06:35 -07:00
|
|
|
case AUTH_LOGGED_OUT:
|
2024-10-08 20:49:56 -07:00
|
|
|
return appReducer(logOut(state as AppState), action);
|
2022-05-11 14:06:35 -07:00
|
|
|
default:
|
|
|
|
return appReducer(state, action);
|
2020-09-27 17:09:35 -07:00
|
|
|
}
|
2020-03-27 13:59:38 -07:00
|
|
|
};
|
|
|
|
|
2024-10-08 20:49:56 -07:00
|
|
|
export default appReducer;
|