Live location share - tiles without tile server (PSG-591) (#8962)
* live location without map POC * styles * force map tiles to show no map for test build * check latestlocationstate exists * just use loading style map fallback when cant display map * style map error for tile view * set pointer cursor when map error is clickable * test mbeaconbody with map display error, lint * lint more good * remove changes for first attempt tile * make maperror test id more accurate * fussy import ordering * PR tweaks
This commit is contained in:
parent
e65409861a
commit
60faf6d025
12 changed files with 430 additions and 211 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { useState, useRef } from 'react';
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
||||
import {
|
||||
Beacon,
|
||||
|
@ -38,6 +38,8 @@ import DialogSidebar from './DialogSidebar';
|
|||
import DialogOwnBeaconStatus from './DialogOwnBeaconStatus';
|
||||
import BeaconStatusTooltip from './BeaconStatusTooltip';
|
||||
import MapFallback from '../location/MapFallback';
|
||||
import { MapError } from '../location/MapError';
|
||||
import { LocationShareError } from '../../../utils/location';
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
roomId: Room['roomId'];
|
||||
|
@ -83,6 +85,15 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
|
||||
const { bounds, centerGeoUri } = useInitialMapPosition(liveBeacons, focusBeacon);
|
||||
|
||||
const [mapDisplayError, setMapDisplayError] = useState<Error>();
|
||||
|
||||
// automatically open the sidebar if there is no map to see
|
||||
useEffect(() => {
|
||||
if (mapDisplayError) {
|
||||
setSidebarOpen(true);
|
||||
}
|
||||
}, [mapDisplayError]);
|
||||
|
||||
return (
|
||||
<BaseDialog
|
||||
className='mx_BeaconViewDialog'
|
||||
|
@ -90,11 +101,12 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
fixedWidth={false}
|
||||
>
|
||||
<MatrixClientContext.Provider value={matrixClient}>
|
||||
{ !!liveBeacons?.length ? <Map
|
||||
{ (!!liveBeacons?.length && !mapDisplayError) && <Map
|
||||
id='mx_BeaconViewDialog'
|
||||
bounds={bounds}
|
||||
centerGeoUri={centerGeoUri}
|
||||
interactive
|
||||
onError={setMapDisplayError}
|
||||
className="mx_BeaconViewDialog_map"
|
||||
>
|
||||
{
|
||||
|
@ -109,7 +121,14 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
<ZoomButtons map={map} />
|
||||
</>
|
||||
}
|
||||
</Map> :
|
||||
</Map> }
|
||||
{ mapDisplayError &&
|
||||
<MapError
|
||||
error={mapDisplayError.message as LocationShareError}
|
||||
isMinimised
|
||||
/>
|
||||
}
|
||||
{ !liveBeacons?.length && !mapDisplayError &&
|
||||
<MapFallback
|
||||
data-test-id='beacon-view-dialog-map-fallback'
|
||||
className='mx_BeaconViewDialog_map'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue