Refactoring intent receivers for gmap links

This commit is contained in:
vdv committed 2023-04-17 15:09:08 +02:00
1 parent f9517b07b4
commit d3c0cfd393
3 files changed
+31 -51

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { findLocation } from '../../components/finder';
const ACCEPTED_ACTIONS = ['android.intent.action.SEND'];
export const gmapReceiver = (
intent: any,
url: URL | undefined,
navigate: any
) => {
if (!ACCEPTED_ACTIONS.includes(intent.action)) {
return false;
}
if (!intent.extras || !intent.extras['android.intent.extra.TEXT']) {
return false;
}
const matches = intent.extras['android.intent.extra.TEXT'].match(
/^https:\/\/www\.google\..+\/maps\/place\/(.+\/)?@(-?[0-9.]+),(-?[0-9.]+),[0-9]+z\/.*$/
);
if (!matches) {
return false;
}
findLocation(navigate, [matches[3], matches[2]]);
return true;
};
+2
View File
@@ -1,4 +1,5 @@
import { geoLocationReceiver } from './geo-location';
import { gmapReceiver } from './gmap-receiver';
import { gpxReceiver } from './gpx-receiver';
import { invitationReceiver } from './invitation-receiver';
import { webLinksReceiver } from './web-links';
@@ -8,6 +9,7 @@ const receivers = {
gpxReceiver,
geoLocationReceiver,
webLinksReceiver,
gmapReceiver,
};
export const receiveIntent = (intent: any, navigate: any) => {