Skip to content

Commit

Permalink
Simplify management of navigation application link
Browse files Browse the repository at this point in the history
  • Loading branch information
dough29 committed Sep 23, 2024
1 parent 1b99de9 commit 9b0f4c9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/common/components/StatusCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin
const positionAttributes = usePositionAttributes(t);
const positionItems = useAttributePreference('positionItems', 'fixTime,address,speed,totalDistance');

const serverNavigationAppLink = useSelector((state) => state.session.server.attributes.navigationAppLink);
const serverNavigationAppTitle = useSelector((state) => state.session.server.attributes.navigationAppTitle);
const userNavigationAppLink = user.attributes.navigationAppLink;
const userNavigationAppTitle = user.attributes.navigationAppTitle;
const navigationAppLink = useAttributePreference('navigationAppLink');
const navigationAppTitle = useAttributePreference('navigationAppTitle');

const [anchorEl, setAnchorEl] = useState(null);

Expand Down Expand Up @@ -274,8 +272,7 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin
<MenuItem component="a" target="_blank" href={`https://www.google.com/maps/search/?api=1&query=${position.latitude}%2C${position.longitude}`}>{t('linkGoogleMaps')}</MenuItem>
<MenuItem component="a" target="_blank" href={`http://maps.apple.com/?ll=${position.latitude},${position.longitude}`}>{t('linkAppleMaps')}</MenuItem>
<MenuItem component="a" target="_blank" href={`https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${position.latitude}%2C${position.longitude}&heading=${position.course}`}>{t('linkStreetView')}</MenuItem>
{serverNavigationAppLink && serverNavigationAppTitle && <MenuItem component="a" target="_blank" href={serverNavigationAppLink.replace('{latitude}', position.latitude).replace('{longitude}', position.longitude)}>{serverNavigationAppTitle}</MenuItem>}
{userNavigationAppLink && userNavigationAppTitle && <MenuItem component="a" target="_blank" href={userNavigationAppLink.replace('{latitude}', position.latitude).replace('{longitude}', position.longitude)}>{userNavigationAppTitle}</MenuItem>}
{navigationAppTitle && <MenuItem component="a" target="_blank" href={navigationAppLink.replace('{latitude}', position.latitude).replace('{longitude}', position.longitude)}>{navigationAppTitle}</MenuItem>}
{!shareDisabled && !user.temporary && <MenuItem onClick={() => navigate(`/settings/device/${deviceId}/share`)}>{t('deviceShare')}</MenuItem>}
</Menu>
)}
Expand Down

0 comments on commit 9b0f4c9

Please sign in to comment.