PromucFlow_constructor/app/client/src/store.ts
Ravi Kumar Prasad ca2e8f8e23
fix: geolocation api callbacks are not called (#18235)
* fix: geolocation api callbacks are not called

The success and error callbacks are not being called. The code was absent.

fixes #11147

* Add comment

* Fix error callback not being called when location is turned off

* Fixes #9852 incorrect error handling on watchPosition

* Fix unit test

* fix unit tests
2022-11-30 16:08:15 +05:30

51 lines
1.6 KiB
TypeScript

import { reduxBatch } from "@manaflair/redux-batch";
import { createStore, applyMiddleware, compose } from "redux";
import appReducer, { AppState } from "@appsmith/reducers";
import createSagaMiddleware from "redux-saga";
import { rootSaga } from "@appsmith/sagas";
import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction";
import * as Sentry from "@sentry/react";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import routeParamsMiddleware from "RouteParamsMiddleware";
const sagaMiddleware = createSagaMiddleware();
const ignoredSentryActionTypes = [
ReduxActionTypes.SET_EVALUATED_TREE,
ReduxActionTypes.EXECUTE_PLUGIN_ACTION_SUCCESS,
ReduxActionTypes.SET_LINT_ERRORS,
];
const sentryReduxEnhancer = Sentry.createReduxEnhancer({
actionTransformer: (action) => {
if (ignoredSentryActionTypes.includes(action.type)) {
// Return null to not log the action to Sentry
action.payload = null;
}
return action;
},
});
export default createStore(
appReducer,
composeWithDevTools(
reduxBatch,
applyMiddleware(sagaMiddleware, routeParamsMiddleware),
reduxBatch,
sentryReduxEnhancer,
),
);
export const testStore = (initialState: Partial<AppState>) =>
createStore(
appReducer,
initialState,
compose(
reduxBatch,
applyMiddleware(sagaMiddleware, routeParamsMiddleware),
reduxBatch,
),
);
// We don't want to run the saga middleware in tests, so exporting it from here
// And running it only when the app runs
export const runSagaMiddleware = () => sagaMiddleware.run(rootSaga);