gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

index.js (1986B)


      1 /*
      2 	GoToSocial
      3 	Copyright (C) GoToSocial Authors admin@gotosocial.org
      4 	SPDX-License-Identifier: AGPL-3.0-or-later
      5 
      6 	This program is free software: you can redistribute it and/or modify
      7 	it under the terms of the GNU Affero General Public License as published by
      8 	the Free Software Foundation, either version 3 of the License, or
      9 	(at your option) any later version.
     10 
     11 	This program is distributed in the hope that it will be useful,
     12 	but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 	GNU Affero General Public License for more details.
     15 
     16 	You should have received a copy of the GNU Affero General Public License
     17 	along with this program.  If not, see <http://www.gnu.org/licenses/>.
     18 */
     19 
     20 "use strict";
     21 
     22 const { combineReducers } = require("redux");
     23 const { configureStore } = require("@reduxjs/toolkit");
     24 const {
     25 	persistStore,
     26 	persistReducer,
     27 	FLUSH,
     28 	REHYDRATE,
     29 	PAUSE,
     30 	PERSIST,
     31 	PURGE,
     32 	REGISTER,
     33 } = require("redux-persist");
     34 
     35 const query = require("../lib/query/base");
     36 const { Promise } = require("bluebird");
     37 
     38 const combinedReducers = combineReducers({
     39 	oauth: require("./oauth").reducer,
     40 	[query.reducerPath]: query.reducer
     41 });
     42 
     43 const persistedReducer = persistReducer({
     44 	key: "gotosocial-settings",
     45 	storage: require("redux-persist/lib/storage").default,
     46 	stateReconciler: require("redux-persist/lib/stateReconciler/autoMergeLevel1").default,
     47 	whitelist: ["oauth"],
     48 	migrate: (state) => {
     49 		return Promise.try(() => {
     50 			if (state?.oauth != undefined) {
     51 				state.oauth.expectingRedirect = false;
     52 			}
     53 			return state;
     54 		});
     55 	}
     56 }, combinedReducers);
     57 
     58 const store = configureStore({
     59 	reducer: persistedReducer,
     60 	middleware: (getDefaultMiddleware) => {
     61 		return getDefaultMiddleware({
     62 			serializableCheck: {
     63 				ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
     64 			}
     65 		}).concat(query.middleware);
     66 	}
     67 });
     68 
     69 const persistor = persistStore(store);
     70 
     71 module.exports = { store, persistor };