diff --git a/app/client.js b/app/client.js index f6bd29677b..3912e6ea12 100644 --- a/app/client.js +++ b/app/client.js @@ -24,7 +24,6 @@ import { ReactRelayContext } from 'react-relay'; import { setRelayEnvironment } from '@digitransit-search-util/digitransit-search-util-query-utils'; import { configShape } from './util/shapes'; import { historyMiddlewares, render } from './routes'; -import Raven from './util/Raven'; import configureMoment from './util/configure-moment'; import StoreListeningIntlProvider from './util/StoreListeningIntlProvider'; import appCreator from './app'; @@ -48,29 +47,11 @@ import { fetchFavouritesComplete, } from './action/FavouriteActions'; -const plugContext = f => () => ({ - plugComponentContext: f, - plugActionContext: f, - plugStoreContext: f, -}); - window.debug = debug; // Allow _debug.enable('*') in browser console // TODO: this is an ugly hack, but required due to cyclical processing in app const { config } = window.state.context.plugins['extra-context-plugin']; const app = appCreator(config); -const raven = Raven(config.SENTRY_DSN); -const addRaven = c => { - c.raven = raven; // eslint-disable-line no-param-reassign -}; - -const ravenPlugin = { - name: 'RavenPlugin', - plugContext: plugContext(addRaven), -}; - -// Add plugins -app.plug(ravenPlugin); const getParams = query => { if (!query) { @@ -252,7 +233,6 @@ async function init() { const ContextProvider = provideContext(StoreListeningIntlProvider, { /* eslint-disable-next-line */ - raven: PropTypes.object, config: configShape, headers: PropTypes.objectOf(PropTypes.string), }); diff --git a/app/component/ErrorBoundary.js b/app/component/ErrorBoundary.js index 5f40850584..c743487137 100644 --- a/app/component/ErrorBoundary.js +++ b/app/component/ErrorBoundary.js @@ -9,26 +9,17 @@ import isRelayNetworkError from '../util/relayUtils'; export default class ErrorBoundary extends React.Component { static propTypes = { children: PropTypes.node.isRequired }; - static contextTypes = { - raven: PropTypes.shape({ - captureException: PropTypes.func.isRequired, - }), - }; - state = { error: null, hasRetried: false }; resetState = () => this.setState({ error: null, hasRetried: true }); - componentDidCatch(error, errorInfo) { + componentDidCatch(error) { if (this.state.hasRetried) { // Did retry, didn't help window.location.reload(); return; } this.setState({ error }); - if (this.context.raven && !isRelayNetworkError(error)) { - this.context.raven.captureException(error, { extra: errorInfo }); - } } render() { @@ -49,11 +40,6 @@ export default class ErrorBoundary extends React.Component { - {/* - - */}
); diff --git a/app/component/itinerary/navigator/NaviCardContainer.js b/app/component/itinerary/navigator/NaviCardContainer.js index 0df50d1fba..86dc0d16d8 100644 --- a/app/component/itinerary/navigator/NaviCardContainer.js +++ b/app/component/itinerary/navigator/NaviCardContainer.js @@ -17,7 +17,7 @@ import { } from './NaviUtils'; import { updateClient, getTopics } from '../ItineraryPageUtils'; -const TIME_AT_DESTINATION = 3; // * 10 seconds +const COUNT_AT_LEG_END = 2; // update cycles within DESTINATION_RADIUS from leg.to const TOPBAR_PADDING = 8; // pixels const HIDE_TOPCARD_DURATION = 2000; // milliseconds @@ -27,13 +27,13 @@ function addMessages(incominMessages, newMessages) { }); } -const handleLegChange = (leg, firstLeg, time) => { +const getLegType = (leg, firstLeg, time, countAtLegEnd) => { let legType; if (time < legTime(firstLeg.start)) { legType = LEGTYPE.PENDING; } else if (leg) { if (!leg.transitLeg) { - if (leg.current >= TIME_AT_DESTINATION) { + if (countAtLegEnd >= COUNT_AT_LEG_END) { legType = LEGTYPE.WAIT; } else { legType = LEGTYPE.MOVE; @@ -73,7 +73,7 @@ function NaviCardContainer( const legRef = useRef(currentLeg); const focusRef = useRef(false); // Destination counter. How long user has been at the destination. * 10 seconds - const destCountRef = useRef(0); + const legEndRef = useRef(0); const cardRef = useRef(null); const { intl, config, match, router } = context; const handleRemove = index => { @@ -212,12 +212,13 @@ function NaviCardContainer( if ( position && currentLeg && + nextLeg && // itinerary end has its own logic distance(position, currentLeg.to) <= DESTINATION_RADIUS ) { - destCountRef.current += 1; + legEndRef.current += 1; } else { // Todo: this works in transit legs, but do we need additional logic for bikes / scooters? - destCountRef.current = 0; + legEndRef.current = 0; } return () => clearTimeout(timeoutId); @@ -225,7 +226,7 @@ function NaviCardContainer( // LegChange fires animation, we need to keep the old data until card goes out of the view. const l = legChanging ? previousLeg : currentLeg; - const legType = handleLegChange(l, firstLeg, time); + const legType = getLegType(l, firstLeg, time, legEndRef.current); const containerTopPosition = mapLayerRef.current.getBoundingClientRect().top + TOPBAR_PADDING; @@ -244,7 +245,7 @@ function NaviCardContainer( >