2022-09-29 10:02:41 +00:00
|
|
|
/*
|
2023-01-18 13:45:14 +00:00
|
|
|
GoToSocial
|
2023-03-12 17:49:06 +00:00
|
|
|
Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2023-01-18 13:45:14 +00:00
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2022-09-29 10:02:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2022-11-08 16:51:44 +00:00
|
|
|
const { combineReducers } = require("redux");
|
|
|
|
const { configureStore } = require("@reduxjs/toolkit");
|
|
|
|
const {
|
|
|
|
persistStore,
|
|
|
|
persistReducer,
|
|
|
|
FLUSH,
|
|
|
|
REHYDRATE,
|
|
|
|
PAUSE,
|
|
|
|
PERSIST,
|
|
|
|
PURGE,
|
|
|
|
REGISTER,
|
|
|
|
} = require("redux-persist");
|
2022-09-29 10:02:41 +00:00
|
|
|
|
2022-11-08 16:51:44 +00:00
|
|
|
const query = require("../lib/query/base");
|
2023-01-18 15:41:00 +00:00
|
|
|
const { Promise } = require("bluebird");
|
2022-09-29 10:02:41 +00:00
|
|
|
|
|
|
|
const combinedReducers = combineReducers({
|
2023-01-18 13:45:14 +00:00
|
|
|
oauth: require("./oauth").reducer,
|
2022-11-08 16:51:44 +00:00
|
|
|
[query.reducerPath]: query.reducer
|
2022-09-29 10:02:41 +00:00
|
|
|
});
|
|
|
|
|
2022-11-08 16:51:44 +00:00
|
|
|
const persistedReducer = persistReducer({
|
|
|
|
key: "gotosocial-settings",
|
|
|
|
storage: require("redux-persist/lib/storage").default,
|
2023-01-18 13:45:14 +00:00
|
|
|
stateReconciler: require("redux-persist/lib/stateReconciler/autoMergeLevel1").default,
|
2022-11-08 16:51:44 +00:00
|
|
|
whitelist: ["oauth"],
|
2023-01-18 15:41:00 +00:00
|
|
|
migrate: (state) => {
|
|
|
|
return Promise.try(() => {
|
|
|
|
if (state?.oauth != undefined) {
|
|
|
|
state.oauth.expectingRedirect = false;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
});
|
|
|
|
}
|
2022-11-08 16:51:44 +00:00
|
|
|
}, combinedReducers);
|
|
|
|
|
|
|
|
const store = configureStore({
|
|
|
|
reducer: persistedReducer,
|
|
|
|
middleware: (getDefaultMiddleware) => {
|
|
|
|
return getDefaultMiddleware({
|
|
|
|
serializableCheck: {
|
2023-01-18 13:45:14 +00:00
|
|
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
|
2022-11-08 16:51:44 +00:00
|
|
|
}
|
|
|
|
}).concat(query.middleware);
|
|
|
|
}
|
|
|
|
});
|
2022-09-29 10:02:41 +00:00
|
|
|
|
|
|
|
const persistor = persistStore(store);
|
|
|
|
|
|
|
|
module.exports = { store, persistor };
|