-
Notifications
You must be signed in to change notification settings - Fork 69
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
Share Dialog with QR Code #729
Conversation
- when clicked, a new modal dialog opens and shows share options for the planned route, which are currently: - a button to copy the URL of the current route to the clipboard - share buttons for 3rd party services, such as Facebook, Whatsapp, Email (and Mastodon, but currently disabled via config[^1]) - a QRCode - the QRCode is a representation of the current route (i.e. the current URL) with an added query parameter to the URL: `?export=dialog` - when BRouter-Web is loaded with the `export=dialog` query parameter, the export dialog is shown instantly (as discussed in nrenner#370) - using a query parameter (`export`) and a value (`dialog`) instead of only a paramater is required, because `URLSearchParams` needs both when adding a new parameter - we've the opportunity to add further options in the future (`download`, `gpx` etc.) - add a new keyboard shortcut 'A' (“action”) which opens the share dialog (would have used 'S', but that's already taken) - add 3rd-party QRCode library - add `URLSearchParams` polyfill for ancient browsers as Husky didn't allow me to commit otherwise … - add license information to README [^1]: Mastodon instances respond with HTTP 502 when the submitted text (= the route URL in our case) is longer than the maximum post character limit on that instance. That will probably confuse users. I decided to keep the code here as this bug will probably be fixed in the future.
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.
Thanks for the PR, nice!
The url-search-params-polyfill
isn't needed, as a URLSearchParams
polyfill is already included in core-js. The added entry in .eslintrc.json
is enough in this case, to make it stop complaining. That's just a manual checklist, it can't automatically detect missing polyfills.
There is an error on download when sharing a single route point, I would suggest to add an additional check before opening the export dialog, probably like if (routing.getWaypoints().length < 2)
as in Export.update
.
js/control/ShareRoute.js
Outdated
}, | ||
|
||
/** | ||
* Renders QR Code for the currect route: |
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.
currect -> current?
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.
good catch ;-)
js/control/ShareRoute.js
Outdated
/** | ||
* Renders QR Code for the currect route: | ||
* | ||
* - hides the export modal dialog (QR Code is shown in a new dialog) |
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.
doesn't apply to current implementation anymore?
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.
No, of course not. I've updated this doc block.
|
No strong opinions, we can merge as is, but there might be use cases where it makes sense to only share the current map view or a single route point. Therefore I meant to still allow sharing, just not to open the export dialog at the receiving end by adding that check to index.js. Don't know if my comment was misleading or if you prefer to disable the share dialog instead? |
Just a misunderstanding – you're absolutely right. I'll push an update later. |
…t dialog after opening QR Code URL if the route consists of less than 2 waypoints
Thanks! |
to only check once on init, not on every update. Waypoints available at time of callback. Add check for lonlats param as event isn't called without and error check.
This pull-request implements sharing a route by QRCode, external services or by using the clipboard
?export=dialog
export=dialog
query parameter, the export dialog is shown instantly (as discussed in Export GPX Route via QR Code #370)export
) and a value (dialog
) instead of only a paramater is required, becauseURLSearchParams
needs both when adding a new parameterdownload
,gpx
etc.)URLSearchParams
polyfill for ancient browsers as Husky didn't allow me to commit otherwise …Footnotes
Mastodon instances respond with HTTP 502 when the submitted text (= the route URL in our case) is longer than the maximum post character limit on that instance. That will probably confuse users. I decided to keep the code here as this bug will probably be fixed in the future. ↩