-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: send mobile-app param to map #1202
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a14fb54
feat: send mobile-app param to map
pyphilia 3dcdd07
refactor: get current loc, view item
pyphilia 68911bc
refactor: get nav only if function exists
pyphilia 2ae2870
refactor: fix show map
pyphilia f13f6a5
refactor: send full item
pyphilia f695755
refactor: fix
pyphilia 17db654
refactor: fix
pyphilia c8f9cc4
refactor: fix
pyphilia 4346a8f
refactor: change postmessage
pyphilia c5296e3
refactor: alert current pos
pyphilia e6a5e3a
refactor: remove alerts
pyphilia 09d0492
refactor: update package
pyphilia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,48 @@ | ||
import { useSearchParams } from 'react-router-dom'; | ||
|
||
import { DiscriminatedItem, redirect } from '@graasp/sdk'; | ||
|
||
import { buildGraaspPlayerView } from '@/config/externalPaths'; | ||
import { buildPlayerTabName } from '@/config/selectors'; | ||
|
||
import MapView from '../item/MapView'; | ||
|
||
// this page is used by the mobile app to display the map | ||
const MapItemScreen = (): JSX.Element | null => { | ||
const [urlSearchParams] = useSearchParams(); | ||
|
||
return <MapView parentId={urlSearchParams.get('parentId') ?? undefined} />; | ||
const isMobileApp = urlSearchParams.get('isMobileApp') === 'true'; | ||
|
||
const viewItem = (item: DiscriminatedItem) => { | ||
if (isMobileApp) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
// eslint-disable-next-line no-lonely-if | ||
if (window.ReactNativeWebView) { | ||
// todo: replace with universal/deep link? not sure it works inside iframe.. | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
window.ReactNativeWebView.postMessage( | ||
JSON.stringify({ itemId: item.id, action: 'open-player' }), | ||
'*', | ||
); | ||
} else { | ||
console.error('cannot open item in mobile player'); | ||
} | ||
} else { | ||
redirect(window, buildGraaspPlayerView(item.id), { | ||
name: buildPlayerTabName(item.id), | ||
openInNewTab: true, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<MapView | ||
viewItem={viewItem} | ||
parentId={urlSearchParams.get('parentId') ?? undefined} | ||
/> | ||
); | ||
}; | ||
|
||
export default MapItemScreen; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / SonarCloud
Origins should be verified during cross-origin communications High