Date: Fri, 17 Dec 2021 12:26:02 +0000
Subject: [PATCH 041/145] Tidy location code (#7402)
---
.../views/location/LocationPicker.tsx | 84 ++++++++++++++-----
.../views/messages/MLocationBody.tsx | 9 +-
.../views/rooms/MessageComposer.tsx | 18 ++--
.../views/location/LocationPicker-test.tsx | 2 +-
4 files changed, 82 insertions(+), 31 deletions(-)
diff --git a/src/components/views/location/LocationPicker.tsx b/src/components/views/location/LocationPicker.tsx
index 5571f64d866..dc383d67a49 100644
--- a/src/components/views/location/LocationPicker.tsx
+++ b/src/components/views/location/LocationPicker.tsx
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React from 'react';
+import React, { SyntheticEvent } from 'react';
import maplibregl from 'maplibre-gl';
import { logger } from "matrix-js-sdk/src/logger";
@@ -40,16 +40,36 @@ const LocationShareTypeDropdown = ({
onChange,
}: IDropdownProps) => {
const options = [
- { _t("Share custom location") }
,
- { _t("Share my current location as a once off") }
,
- // { _t("Share my current location for one minute") }
,
- // { _t("Share my current location for five minutes") }
,
- // { _t("Share my current location for thirty minutes") }
,
- // { _t("Share my current location for one hour") }
,
- // { _t("Share my current location for three hours") }
,
- // { _t("Share my current location for six hours") }
,
- // { _t("Share my current location for one day") }
,
- // { _t("Share my current location until I disable it") }
,
+ {
+ _t("Share custom location")
+ }
,
+ {
+ _t("Share my current location as a once off")
+ }
,
+ // {
+ // _t("Share my current location for one minute")
+ // }
,
+ // {
+ // _t("Share my current location for five minutes")
+ // }
,
+ // {
+ // _t("Share my current location for thirty minutes")
+ // }
,
+ // {
+ // _t("Share my current location for one hour")
+ // }
,
+ // {
+ // _t("Share my current location for three hours")
+ // }
,
+ // {
+ // _t("Share my current location for six hours")
+ // }
,
+ // {
+ // _t("Share my current location for one day")
+ // }
,
+ // {
+ // _t("Share my current location until I disable it")
+ // }
,
];
return {
private marker: maplibregl.Marker;
private geolocate: maplibregl.GeolocateControl;
- constructor(props) {
+ constructor(props: IProps) {
super(props);
this.state = {
@@ -117,8 +142,11 @@ class LocationPicker extends React.Component {
this.map.addControl(this.geolocate);
this.map.on('error', (e) => {
- logger.error("Failed to load map: check map_style_url in config.json has a valid URL and API key",
- e.error);
+ logger.error(
+ "Failed to load map: check map_style_url in config.json "
+ + "has a valid URL and API key",
+ e.error,
+ );
this.setState({ error: e.error });
});
@@ -246,7 +274,10 @@ class LocationPicker extends React.Component {
+ primaryDisabled={
+ !this.state.position &&
+ !this.state.manualPosition
+ } />