2022-09-29 12:02:41 +02:00
|
|
|
/*
|
2023-01-18 14:45:14 +01:00
|
|
|
GoToSocial
|
|
|
|
Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org
|
2022-09-29 12:02:41 +02:00
|
|
|
|
2023-01-18 14:45:14 +01: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 12:02:41 +02:00
|
|
|
|
2023-01-18 14:45:14 +01: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 12:02:41 +02:00
|
|
|
|
2023-01-18 14:45:14 +01: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 12:02:41 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2022-11-08 17:51:44 +01: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 12:02:41 +02:00
|
|
|
|
2022-11-08 17:51:44 +01:00
|
|
|
const query = require("../lib/query/base");
|
2023-01-18 16:41:00 +01:00
|
|
|
const { Promise } = require("bluebird");
|
2022-09-29 12:02:41 +02:00
|
|
|
|
|
|
|
const combinedReducers = combineReducers({
|
2023-01-18 14:45:14 +01:00
|
|
|
oauth: require("./oauth").reducer,
|
2022-11-08 17:51:44 +01:00
|
|
|
[query.reducerPath]: query.reducer
|
2022-09-29 12:02:41 +02:00
|
|
|
});
|
|
|
|
|
2022-11-08 17:51:44 +01:00
|
|
|
const persistedReducer = persistReducer({
|
|
|
|
key: "gotosocial-settings",
|
|
|
|
storage: require("redux-persist/lib/storage").default,
|
2023-01-18 14:45:14 +01:00
|
|
|
stateReconciler: require("redux-persist/lib/stateReconciler/autoMergeLevel1").default,
|
2022-11-08 17:51:44 +01:00
|
|
|
whitelist: ["oauth"],
|
2023-01-18 16:41:00 +01:00
|
|
|
migrate: (state) => {
|
|
|
|
return Promise.try(() => {
|
|
|
|
if (state?.oauth != undefined) {
|
|
|
|
state.oauth.expectingRedirect = false;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
});
|
|
|
|
}
|
2022-11-08 17:51:44 +01:00
|
|
|
}, combinedReducers);
|
|
|
|
|
|
|
|
const store = configureStore({
|
|
|
|
reducer: persistedReducer,
|
|
|
|
middleware: (getDefaultMiddleware) => {
|
|
|
|
return getDefaultMiddleware({
|
|
|
|
serializableCheck: {
|
2023-01-18 14:45:14 +01:00
|
|
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
|
2022-11-08 17:51:44 +01:00
|
|
|
}
|
|
|
|
}).concat(query.middleware);
|
|
|
|
}
|
|
|
|
});
|
2022-09-29 12:02:41 +02:00
|
|
|
|
|
|
|
const persistor = persistStore(store);
|
|
|
|
|
|
|
|
module.exports = { store, persistor };
|