leave maximised map when beacons expire (#9098)
This commit is contained in:
parent
ca1d9729fd
commit
0357b4f0dc
7 changed files with 61 additions and 27 deletions
|
@ -68,7 +68,7 @@ const getBoundsCenter = (bounds: Bounds): string | undefined => {
|
|||
});
|
||||
};
|
||||
|
||||
const useInitialMapPosition = (liveBeacons: Beacon[], { beacon, ts }: FocusedBeaconState): {
|
||||
const useMapPosition = (liveBeacons: Beacon[], { beacon, ts }: FocusedBeaconState): {
|
||||
bounds?: Bounds; centerGeoUri: string;
|
||||
} => {
|
||||
const [bounds, setBounds] = useState<Bounds | undefined>(getBeaconBounds(liveBeacons));
|
||||
|
@ -113,7 +113,7 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
|
||||
const [isSidebarOpen, setSidebarOpen] = useState(false);
|
||||
|
||||
const { bounds, centerGeoUri } = useInitialMapPosition(liveBeacons, focusedBeaconState);
|
||||
const { bounds, centerGeoUri } = useMapPosition(liveBeacons, focusedBeaconState);
|
||||
|
||||
const [mapDisplayError, setMapDisplayError] = useState<Error>();
|
||||
|
||||
|
@ -135,7 +135,7 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
fixedWidth={false}
|
||||
>
|
||||
<MatrixClientContext.Provider value={matrixClient}>
|
||||
{ (!!liveBeacons?.length && !mapDisplayError) && <Map
|
||||
{ (centerGeoUri && !mapDisplayError) && <Map
|
||||
id='mx_BeaconViewDialog'
|
||||
bounds={bounds}
|
||||
centerGeoUri={centerGeoUri}
|
||||
|
@ -162,7 +162,7 @@ const BeaconViewDialog: React.FC<IProps> = ({
|
|||
isMinimised
|
||||
/>
|
||||
}
|
||||
{ !liveBeacons?.length && !mapDisplayError &&
|
||||
{ !centerGeoUri && !mapDisplayError &&
|
||||
<MapFallback
|
||||
data-test-id='beacon-view-dialog-map-fallback'
|
||||
className='mx_BeaconViewDialog_map'
|
||||
|
|
|
@ -20,7 +20,6 @@ import { LocationAssetType } from 'matrix-js-sdk/src/@types/location';
|
|||
|
||||
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore';
|
||||
import { useEventEmitterState } from '../../../hooks/useEventEmitter';
|
||||
import { OwnProfileStore } from '../../../stores/OwnProfileStore';
|
||||
import OwnBeaconStatus from './OwnBeaconStatus';
|
||||
import { BeaconDisplayStatus } from './displayStatus';
|
||||
import MatrixClientContext from '../../../contexts/MatrixClientContext';
|
||||
|
@ -33,7 +32,7 @@ interface Props {
|
|||
|
||||
const useOwnBeacon = (roomId: Room['roomId']): Beacon | undefined => {
|
||||
const ownBeacon = useEventEmitterState(
|
||||
OwnProfileStore.instance,
|
||||
OwnBeaconStore.instance,
|
||||
OwnBeaconStoreEvent.LivenessChange,
|
||||
() => {
|
||||
const [ownBeaconId] = OwnBeaconStore.instance.getLiveBeaconIds(roomId);
|
||||
|
|
|
@ -46,13 +46,18 @@ const DialogSidebar: React.FC<Props> = ({
|
|||
<CloseIcon className='mx_DialogSidebar_closeButtonIcon' />
|
||||
</AccessibleButton>
|
||||
</div>
|
||||
<ol className='mx_DialogSidebar_list'>
|
||||
{ beacons.map((beacon) => <BeaconListItem
|
||||
key={beacon.identifier}
|
||||
beacon={beacon}
|
||||
onClick={() => onBeaconClick(beacon)}
|
||||
/>) }
|
||||
</ol>
|
||||
{ beacons?.length
|
||||
? <ol className='mx_DialogSidebar_list'>
|
||||
{ beacons.map((beacon) => <BeaconListItem
|
||||
key={beacon.identifier}
|
||||
beacon={beacon}
|
||||
onClick={() => onBeaconClick(beacon)}
|
||||
/>) }
|
||||
</ol>
|
||||
: <div className='mx_DialogSidebar_noResults'>
|
||||
{ _t('No live locations') }
|
||||
</div>
|
||||
}
|
||||
</div>;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue