-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/prd 504 Remove routing bridge between MapView and native SDK #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
80500b4
f225669
ac5c4d2
d4bc9da
16c31d0
2be003f
857f3a6
c6e5312
3411ec5
2a96744
2c0b5fe
8e89e32
aab7c2a
f246476
9e6a2e7
544777c
f3b291c
e039e40
6cf0c7b
bb9dfd1
c1c6c03
f5456f5
6a6c501
b2c30cc
f849990
499e817
22ec8b6
fd61126
0e18307
ccab37f
021f572
ca185cb
cf94bc3
11f885e
e78e8b0
98c92a3
41fbe58
2f1a255
658bd82
c91050d
0884145
a165f12
5b4a309
35456ba
2d316d3
87b8ce0
b8cd3d2
0d03415
ba12364
ad72f03
2b86366
2a28fb7
70b83b1
e39fa42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,8 +100,8 @@ let exitGeofencesCallback = (_: any) => {}; | |
|
|
||
| // Internal callbacks: | ||
| // These callback functions will be added as listeners to SitumPluginEventEmitter as soon as possible and will be | ||
| // listening events for all the plugin lifecycle. They will forward calls to both client callbacks and the MapView | ||
| // internal callback. | ||
| // listening events for all the plugin lifecycle. Location and geofence events will forward calls to both client | ||
| // callbacks and the MapView internal callback. Navigation events are forwarded only to the client callbacks. | ||
|
|
||
| const _internalLocationCallback = (loc: Location) => { | ||
| DelegatedStateManager.getInstance().updateLocation(loc); | ||
|
|
@@ -143,56 +143,6 @@ const _internalLocationErrorCallback = (error: Error) => { | |
| locationErrorCallback?.(adaptedError); | ||
| }; | ||
|
|
||
| const _internalNavigationStartedCallback = (route: Route) => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_START, route), | ||
| ); | ||
| navigationStartedCallback?.(route); | ||
| }; | ||
|
|
||
| const _internalNavigationProgressCallback = (progress: NavigationProgress) => { | ||
| internalMethodCallMapDelegate( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ten sentido manter a callback interna? Non se podería eliminar e usar directamente a callback de cliente? Igual para os casos de abaixo.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claro, aplicaré el cambio |
||
| new InternalCall(InternalCallType.NAVIGATION_PROGRESS, progress), | ||
| ); | ||
| navigationProgressCallback?.(progress); | ||
| }; | ||
|
|
||
| const _internalNavigationDestinationReachedCallback = (route: Route) => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_DESTINATION_REACHED, route), | ||
| ); | ||
| navigationDestinationReachedCallback?.(route); | ||
| }; | ||
|
|
||
| const _internalNavigationOutOfRouteCallback = () => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_OUT_OF_ROUTE, undefined), | ||
| ); | ||
| navigationOutOfRouteCallback?.(); | ||
| }; | ||
|
|
||
| const _internalNavigationFinishedCallback = () => { | ||
| // Deprecated! | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined), | ||
| ); | ||
| navigationFinishedCallback?.(); | ||
| }; | ||
|
|
||
| const _internalNavigationCancellationCallback = () => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined), | ||
| ); | ||
| navigationCancellationCallback?.(); | ||
| }; | ||
|
|
||
| const _internalNavigationErrorCallback = (error: any) => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.NAVIGATION_ERROR, error), | ||
| ); | ||
| navigationErrorCallback?.(error); | ||
| }; | ||
|
|
||
| const _internalEnterGeofencesCallback = (data: any) => { | ||
| internalMethodCallMapDelegate( | ||
| new InternalCall(InternalCallType.GEOFENCES_ENTER, data), | ||
|
|
@@ -213,16 +163,30 @@ const _registerCallbacks = () => { | |
| statusChanged: _internalLocationStatusCallback, | ||
| locationStopped: _internalLocationStoppedCallback, | ||
| locationError: _internalLocationErrorCallback, | ||
| [SdkNavigationUpdateType.START]: _internalNavigationStartedCallback, | ||
| [SdkNavigationUpdateType.PROGRESS]: _internalNavigationProgressCallback, | ||
| [SdkNavigationUpdateType.DESTINATION_REACHED]: | ||
| _internalNavigationDestinationReachedCallback, | ||
| [SdkNavigationUpdateType.OUTSIDE_ROUTE]: | ||
| _internalNavigationOutOfRouteCallback, | ||
| [SdkNavigationUpdateType.FINISHED]: _internalNavigationFinishedCallback, | ||
| [SdkNavigationUpdateType.CANCELLATION]: | ||
| _internalNavigationCancellationCallback, | ||
| [SdkNavigationUpdateType.ERROR]: _internalNavigationErrorCallback, | ||
| [SdkNavigationUpdateType.START]: (route: Route) => { | ||
| navigationStartedCallback(route); | ||
| }, | ||
| [SdkNavigationUpdateType.PROGRESS]: (progress: NavigationProgress) => { | ||
| navigationProgressCallback(progress); | ||
| }, | ||
| [SdkNavigationUpdateType.DESTINATION_REACHED]: (route: Route) => { | ||
| navigationDestinationReachedCallback(route); | ||
| navigationRunning = false; | ||
| }, | ||
| [SdkNavigationUpdateType.OUTSIDE_ROUTE]: () => { | ||
| navigationOutOfRouteCallback(); | ||
| }, | ||
| [SdkNavigationUpdateType.FINISHED]: () => { | ||
| navigationFinishedCallback(); | ||
| navigationRunning = false; | ||
| }, | ||
| [SdkNavigationUpdateType.CANCELLATION]: () => { | ||
| navigationCancellationCallback(); | ||
| navigationRunning = false; | ||
| }, | ||
| [SdkNavigationUpdateType.ERROR]: (error: any) => { | ||
| navigationErrorCallback(error); | ||
| }, | ||
| onEnterGeofences: _internalEnterGeofencesCallback, | ||
| onExitGeofences: _internalExitGeofencesCallback, | ||
| }; | ||
|
|
@@ -685,8 +649,11 @@ export default class SitumPlugin { | |
| * | ||
| */ | ||
| static removeNavigationUpdates = () => { | ||
| return promiseWrapper<void>(({ onCallback }) => { | ||
| if (!SitumPlugin.navigationIsRunning()) return; | ||
| return promiseWrapper<void>(({ resolve, onCallback }) => { | ||
| if (!SitumPlugin.navigationIsRunning()) { | ||
| resolve(); | ||
| return; | ||
| } | ||
|
|
||
| navigationRunning = false; | ||
| RNCSitumPlugin.removeNavigationUpdates((response) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,20 @@ | ||
| /** | ||
| * @deprecated This enum was used by the legacy navigation bridge between the native SDK and the MapView. | ||
| * That bridge has been removed. | ||
| * It is kept for backward compatibility and is no longer used or emitted by the plugin. | ||
| */ | ||
| export enum NavigationStatus { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Estame vindo á cabeza que esta enum quizais estivera aí unicamente para ser usada desde o lado cliente, para que dispoña dun listado exhaustivo de estados. Quizais non atopaches usos no código por eso. Pode ser?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tenía usos en el puente que se eliminó, pero me suena bastante realista pensar que un integrador podría haberlo usado. Lo vuelvo a añadir como deprecado. Si consideras que no debería estar deprecado avísame y lo cambio sin problema. |
||
| START = "start", | ||
| STOP = "stop", | ||
| OUT_OF_ROUTE = "outOfRoute", | ||
| UPDATE = "update", | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated This enum was used by the legacy navigation bridge between the native SDK and the MapView. | ||
| * That bridge has been removed. | ||
| * It is kept for backward compatibility and is no longer used or emitted by the plugin. | ||
| */ | ||
| export enum NavigationUpdateType { | ||
| PROGRESS = "PROGRESS", | ||
| OUT_OF_ROUTE = "OUT_OF_ROUTE", | ||
|
|
@@ -33,7 +43,7 @@ export enum LocationStatusName { | |
| } | ||
|
|
||
| /** | ||
| * Available accessibility modes used in the {@link DirectionsRequest}. | ||
| * Available accessibility modes used in the {@link DirectionsOptions}. | ||
| * | ||
| * @property CHOOSE_SHORTEST The route should choose the best route, without taking into account if it is accessible or not. | ||
| * This option is the default so you don't have to do anything in order to use it | ||
|
|
@@ -51,12 +61,6 @@ export enum InternalCallType { | |
| LOCATION_STATUS = "LOCATION_STATUS", | ||
| LOCATION_ERROR = "LOCATION_ERROR", | ||
| LOCATION_STOPPED = "LOCATION_STOPPED", // TODO: Exists only in RN, delete! | ||
| NAVIGATION_START = "NAVIGATION_START", | ||
| NAVIGATION_DESTINATION_REACHED = "NAVIGATION_DESTINATION_REACHED", | ||
| NAVIGATION_PROGRESS = "NAVIGATION_PROGRESS", | ||
| NAVIGATION_OUT_OF_ROUTE = "NAVIGATION_OUT_OF_ROUTE", | ||
| NAVIGATION_CANCELLATION = "NAVIGATION_CANCELLATION", | ||
| NAVIGATION_ERROR = "NAVIGATION_ERROR", | ||
| GEOFENCES_ENTER = "GEOFENCES_ENTER", | ||
| GEOFENCES_EXIT = "GEOFENCES_EXIT", | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ import SitumPlugin from "../../sdk"; | |
| import useSitum from "../hooks"; | ||
| import { | ||
| selectApiDomain, | ||
| selectUser, | ||
| setError, | ||
| setLocationStatus, | ||
| } from "../store"; | ||
|
|
@@ -40,7 +39,6 @@ import { | |
| type NavigateToCarPayload, | ||
| type NavigateToPointPayload, | ||
| type NavigateToPoiPayload, | ||
| type OnDirectionsRequestInterceptor, | ||
| type OnExternalLinkClickedResult, | ||
| type OnFavoritePoisUpdatedResult, | ||
| type OnFloorChangedResult, | ||
|
|
@@ -53,7 +51,7 @@ import { | |
| import { ErrorName } from "../types/constants"; | ||
| import { sendMessageToViewer } from "../utils"; | ||
| import ViewerMapper from "../utils/mapper"; | ||
| import { areSameAuth, authStore, SitumAuth } from "../../sdk/authStore"; | ||
| import { authStore, SitumAuth } from "../../sdk/authStore"; | ||
| const SITUM_BASE_DOMAIN = "https://maps.situm.com"; | ||
|
|
||
| const NETWORK_ERROR_CODE = { | ||
|
|
@@ -183,8 +181,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| ref, | ||
| ) => { | ||
| const webViewRef = useRef<WebView>(null); | ||
| const [_onDirectionsRequestInterceptor, setInterceptor] = | ||
| useState<OnDirectionsRequestInterceptor>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El Interceptor permitía modificar los valores de una ruta antes de calcularse. Ya no se usa el sdk para calcularse así que no tiene sentido dejarlo. |
||
| const internalMessageCallbackRef = | ||
| useRef<OnInternalMapViewMessageCallback>(); | ||
|
|
||
|
|
@@ -203,11 +199,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| init, | ||
| location, | ||
| locationStatus, | ||
| directions, | ||
| navigation, | ||
| calculateRoute, | ||
| startNavigation, | ||
| stopNavigation, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se han borrado estos estados y funciones de la store, sincronizaban la navegación y rutas del sdk con el viewer |
||
| error, | ||
| } = useSitum(); | ||
|
|
||
|
|
@@ -282,12 +273,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| if (!webViewRef.current) { | ||
| return; | ||
| } | ||
| if (SitumPlugin.navigationIsRunning()) { | ||
| console.error( | ||
| "Situm > hook > Navigation on course, poi category selection is unavailable", | ||
| ); | ||
| return; | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SitumPlugin.navigationIsRunning() comprueba si el SDK está utilizando la navegación, como ya no va sincronizado con el viewer no tiene usarlo aquí |
||
| sendMessageToViewer( | ||
| webViewRef.current, | ||
| ViewerMapper.selectPoiCategory(categoryId), | ||
|
|
@@ -299,12 +284,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| if (!webViewRef.current) { | ||
| return; | ||
| } | ||
| if (SitumPlugin.navigationIsRunning()) { | ||
| console.error( | ||
| "Situm > hook > Navigation on course, floor selection is unavailable", | ||
| ); | ||
| return; | ||
| } | ||
| sendMessageToViewer( | ||
| webViewRef.current, | ||
| ViewerMapper.selectFloor(floorId, options), | ||
|
|
@@ -412,7 +391,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| webViewRef.current && | ||
| sendMessageToViewer( | ||
| webViewRef.current, | ||
| ViewerMapper.selectPoi(null), | ||
| ViewerMapper.deselectPoi(), | ||
| ); | ||
| }, | ||
| navigateToPoi(payload): void { | ||
|
|
@@ -424,12 +403,8 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| navigateToPoint(payload: NavigateToPointPayload): void { | ||
| _navigateToPoint(payload); | ||
| }, | ||
| setOnDirectionsRequestInterceptor(directionRequestInterceptor): void { | ||
| setInterceptor(() => directionRequestInterceptor); | ||
| }, | ||
| cancelNavigation(): void { | ||
| if (!webViewRef.current) return; | ||
| stopNavigation(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stopNavigation detenía la navegación en el SDK y actualizaba la store, esto se borra y se deja el sendMessageToViewer, que es el método moderno, para que se pueda seguir deteniendo la navegación por medio de esta función |
||
| sendMessageToViewer( | ||
| webViewRef.current, | ||
| ViewerMapper.cancelNavigation(), | ||
|
|
@@ -450,7 +425,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| }, | ||
| }; | ||
| }, [ | ||
| stopNavigation, | ||
| _navigateToPoi, | ||
| _followUser, | ||
| _navigateToCar, | ||
|
|
@@ -516,23 +490,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| setError(null); | ||
| }, [error, mapLoaded]); | ||
|
|
||
| // Updated SDK navigation | ||
| useEffect(() => { | ||
| if (!webViewRef.current || !navigation || !mapLoaded) return; | ||
|
|
||
| sendMessageToViewer( | ||
| webViewRef.current, | ||
| ViewerMapper.navigation(navigation), | ||
| ); | ||
| }, [navigation, mapLoaded]); | ||
|
|
||
| // Updated SDK route | ||
| useEffect(() => { | ||
| if (!webViewRef.current || !directions || !mapLoaded) return; | ||
|
|
||
| sendMessageToViewer(webViewRef.current, ViewerMapper.route(directions)); | ||
| }, [directions, mapLoaded]); | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enviaban mensajes al viewer cuando la navegación o ruta de la store cambiaban. Se borraron estos valores de la store, así que de aquí también. |
||
| // Update language | ||
| useEffect(() => { | ||
| if (!webViewRef.current || !configuration.language || !mapLoaded) return; | ||
|
|
@@ -580,15 +537,6 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| case "app.ready_for_auth": | ||
| sendEffectiveAuth(); | ||
| break; | ||
| case "directions.requested": | ||
| calculateRoute(payload, _onDirectionsRequestInterceptor); | ||
| break; | ||
| case "navigation.requested": | ||
| startNavigation(payload, _onDirectionsRequestInterceptor); | ||
| break; | ||
| case "navigation.stopped": | ||
| stopNavigation(); | ||
| break; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. El viewer ya no emite estos mensaje |
||
| case "cartography.poi_selected": | ||
| onPoiSelected(payload); | ||
| break; | ||
|
|
@@ -620,6 +568,10 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>( | |
| case "viewer.navigation.started": | ||
| case "viewer.navigation.updated": | ||
| case "viewer.navigation.stopped": | ||
| // Forward Viewer navigation events to the existing SDK callbacks. | ||
| // This avoids introducing a separate set of callbacks just for the Viewer. | ||
| // Warning: running SDK and MapView navigations at the same time may mix | ||
| // events because both navigations use the same public SDK callbacks. | ||
| SitumPlugin.updateNavigationState(payload); | ||
| break; | ||
| case "share_location.uploading_locations_started": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Estos InternalCall servían para sincronizar el estado de la navegación del sdk con el de la store del SitumProvider. Se eliminan porque ya no se desea que el sdk controle la navegación del viewer