Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9562deb

Browse files
authored
Remove the Description from the location picker (#7485)
1 parent fe16f22 commit 9562deb

File tree

6 files changed

+16
-212
lines changed

6 files changed

+16
-212
lines changed

res/css/views/location/_LocationPicker.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ limitations under the License.
2626
}
2727

2828
#mx_LocationPicker_map {
29-
height: 324px;
29+
height: 408px;
3030
border-radius: 8px 8px 0px 0px;
3131
}
3232

src/components/views/location/LocationButton.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ import { Room } from "matrix-js-sdk/src/models/room";
1919
import classNames from 'classnames';
2020

2121
import { _t } from '../../../languageHandler';
22-
import LocationShareType from "./LocationShareType";
2322
import LocationPicker from './LocationPicker';
2423
import { CollapsibleButton, ICollapsibleButtonProps } from '../rooms/CollapsibleButton';
2524
import ContextMenu, { aboveLeftOf, useContextMenu, AboveLeftOf } from "../../structures/ContextMenu";
2625

2726
interface IProps extends Pick<ICollapsibleButtonProps, "narrowMode"> {
2827
room: Room;
29-
shareLocation: (
30-
uri: string,
31-
ts: number,
32-
type: LocationShareType,
33-
description: string,
34-
) => boolean;
28+
shareLocation: (uri: string, ts: number) => boolean;
3529
menuPosition: AboveLeftOf;
3630
narrowMode: boolean;
3731
}

src/components/views/location/LocationPicker.tsx

Lines changed: 11 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -19,105 +19,38 @@ import maplibregl from 'maplibre-gl';
1919
import { logger } from "matrix-js-sdk/src/logger";
2020

2121
import SdkConfig from '../../../SdkConfig';
22-
import Field from "../elements/Field";
2322
import DialogButtons from "../elements/DialogButtons";
24-
import Dropdown from "../elements/Dropdown";
25-
import LocationShareType from "./LocationShareType";
2623
import { _t } from '../../../languageHandler';
2724
import { replaceableComponent } from "../../../utils/replaceableComponent";
2825

29-
interface IDropdownProps {
30-
value: LocationShareType;
31-
label: string;
32-
width?: number;
33-
onChange(type: LocationShareType): void;
34-
}
35-
36-
const LocationShareTypeDropdown = ({
37-
value,
38-
label,
39-
width,
40-
onChange,
41-
}: IDropdownProps) => {
42-
const options = [
43-
<div key={LocationShareType.Custom}>{
44-
_t("Share custom location")
45-
}</div>,
46-
<div key={LocationShareType.OnceOff}>{
47-
_t("Share my current location as a once off")
48-
}</div>,
49-
// <div key={LocationShareType.OneMin}>{
50-
// _t("Share my current location for one minute")
51-
// }</div>,
52-
// <div key={LocationShareType.FiveMins}>{
53-
// _t("Share my current location for five minutes")
54-
// }</div>,
55-
// <div key={LocationShareType.ThirtyMins}>{
56-
// _t("Share my current location for thirty minutes")
57-
// }</div>,
58-
// <div key={LocationShareType.OneHour}>{
59-
// _t("Share my current location for one hour")
60-
// }</div>,
61-
// <div key={LocationShareType.ThreeHours}>{
62-
// _t("Share my current location for three hours")
63-
// }</div>,
64-
// <div key={LocationShareType.SixHours}>{
65-
// _t("Share my current location for six hours")
66-
// }</div>,
67-
// <div key={LocationShareType.OneDay}>{
68-
// _t("Share my current location for one day")
69-
// }</div>,
70-
// <div key={LocationShareType.Forever}>{
71-
// _t("Share my current location until I disable it")
72-
// }</div>,
73-
];
74-
75-
return <Dropdown
76-
id="mx_LocationShareTypeDropdown"
77-
className="mx_LocationShareTypeDropdown"
78-
onOptionChange={(key: string) => {
79-
onChange(LocationShareType[LocationShareType[parseInt(key)]]);
80-
}}
81-
menuWidth={width}
82-
label={label}
83-
value={value.toString()}
84-
>
85-
{ options }
86-
</Dropdown>;
87-
};
88-
8926
interface IProps {
90-
onChoose(
91-
uri: string,
92-
ts: number,
93-
type: LocationShareType,
94-
description: string,
95-
): boolean;
27+
onChoose(uri: string, ts: number): boolean;
9628
onFinished(ev?: SyntheticEvent): void;
9729
}
9830

9931
interface IState {
100-
description: string;
101-
type: LocationShareType;
10232
position?: GeolocationPosition;
103-
manualPosition?: GeolocationPosition;
10433
error: Error;
10534
}
10635

36+
/*
37+
* An older version of this file allowed manually picking a location on
38+
* the map to share, instead of sharing your current location.
39+
* Since the current designs do not cover this case, it was removed from
40+
* the code but you should be able to find it in the git history by
41+
* searching for the commit that remove manualPosition from this file.
42+
*/
43+
10744
@replaceableComponent("views.location.LocationPicker")
10845
class LocationPicker extends React.Component<IProps, IState> {
10946
private map: maplibregl.Map;
110-
private marker: maplibregl.Marker;
11147
private geolocate: maplibregl.GeolocateControl;
11248

11349
constructor(props: IProps) {
11450
super(props);
11551

11652
this.state = {
117-
description: _t("My location"),
118-
type: LocationShareType.OnceOff,
11953
position: undefined,
120-
manualPosition: undefined,
12154
error: undefined,
12255
};
12356
}
@@ -154,53 +87,13 @@ class LocationPicker extends React.Component<IProps, IState> {
15487
this.geolocate.trigger();
15588
});
15689

157-
this.map.on('click', (e) => {
158-
this.addMarker(e.lngLat);
159-
this.storeManualPosition(e.lngLat);
160-
this.setState({ type: LocationShareType.Custom });
161-
});
162-
16390
this.geolocate.on('geolocate', this.onGeolocate);
16491
} catch (e) {
16592
logger.error("Failed to render map", e.error);
16693
this.setState({ error: e.error });
16794
}
16895
}
16996

170-
private addMarker(lngLat: maplibregl.LngLat): void {
171-
if (this.marker) return;
172-
this.marker = new maplibregl.Marker({
173-
draggable: true,
174-
})
175-
.setLngLat(lngLat)
176-
.addTo(this.map)
177-
.on('dragend', () => {
178-
this.storeManualPosition(this.marker.getLngLat());
179-
});
180-
}
181-
182-
private removeMarker(): void {
183-
if (!this.marker) return;
184-
this.marker.remove();
185-
this.marker = undefined;
186-
}
187-
188-
private storeManualPosition(lngLat: maplibregl.LngLat): void {
189-
const manualPosition: GeolocationPosition = {
190-
coords: {
191-
longitude: lngLat.lng,
192-
latitude: lngLat.lat,
193-
altitude: undefined,
194-
accuracy: undefined,
195-
altitudeAccuracy: undefined,
196-
heading: undefined,
197-
speed: undefined,
198-
},
199-
timestamp: Date.now(),
200-
};
201-
this.setState({ manualPosition });
202-
}
203-
20497
componentWillUnmount() {
20598
this.geolocate?.off('geolocate', this.onGeolocate);
20699
}
@@ -209,41 +102,16 @@ class LocationPicker extends React.Component<IProps, IState> {
209102
this.setState({ position });
210103
};
211104

212-
private onDescriptionChange = (ev: React.ChangeEvent<HTMLInputElement>) => {
213-
this.setState({ description: ev.target.value });
214-
};
215-
216105
private onOk = () => {
217-
const position = (this.state.type == LocationShareType.Custom) ?
218-
this.state.manualPosition : this.state.position;
106+
const position = this.state.position;
219107

220108
this.props.onChoose(
221109
position ? getGeoUri(position) : undefined,
222110
position ? position.timestamp : undefined,
223-
this.state.type,
224-
this.state.description,
225111
);
226112
this.props.onFinished();
227113
};
228114

229-
private onTypeChange= (type: LocationShareType) => {
230-
if (type == LocationShareType.Custom) {
231-
if (!this.state.manualPosition) {
232-
this.setState({ manualPosition: this.state.position });
233-
}
234-
if (this.state.manualPosition) {
235-
this.addMarker(new maplibregl.LngLat(
236-
this.state.manualPosition?.coords.longitude,
237-
this.state.manualPosition?.coords.latitude,
238-
));
239-
}
240-
} else {
241-
this.removeMarker();
242-
}
243-
244-
this.setState({ type });
245-
};
246-
247115
render() {
248116
const error = this.state.error ?
249117
<div className="mx_LocationPicker_error">
@@ -256,28 +124,10 @@ class LocationPicker extends React.Component<IProps, IState> {
256124
{ error }
257125
<div className="mx_LocationPicker_footer">
258126
<form onSubmit={this.onOk}>
259-
<LocationShareTypeDropdown
260-
value={this.state.type}
261-
label={_t("Type of location share")}
262-
onChange={this.onTypeChange}
263-
width={400}
264-
/>
265-
266-
<Field
267-
label={_t('Description')}
268-
onChange={this.onDescriptionChange}
269-
value={this.state.description}
270-
width={400}
271-
className="mx_LocationPicker_description"
272-
/>
273-
274127
<DialogButtons primaryButton={_t('Share')}
275128
onPrimaryButtonClick={this.onOk}
276129
onCancel={this.props.onFinished}
277-
primaryDisabled={
278-
!this.state.position &&
279-
!this.state.manualPosition
280-
} />
130+
primaryDisabled={!this.state.position} />
281131
</form>
282132
</div>
283133
</div>

src/components/views/location/LocationShareType.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/views/rooms/MessageComposer.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import Modal from "../../../Modal";
5858
import RoomContext from '../../../contexts/RoomContext';
5959
import ErrorDialog from "../dialogs/ErrorDialog";
6060
import PollCreateDialog from "../elements/PollCreateDialog";
61-
import LocationShareType from "../location/LocationShareType";
6261
import { SettingUpdatedPayload } from "../../../dispatcher/payloads/SettingUpdatedPayload";
6362
import { CollapsibleButton, ICollapsibleButtonProps } from './CollapsibleButton';
6463
import { LocationButton, textForLocation } from '../location/LocationButton';
@@ -453,18 +452,13 @@ export default class MessageComposer extends React.Component<IProps, IState> {
453452
return true;
454453
};
455454

456-
private shareLocation = (
457-
uri: string,
458-
ts: number,
459-
_type: LocationShareType,
460-
description: string | null,
461-
): boolean => {
455+
private shareLocation = (uri: string, ts: number): boolean => {
462456
if (!uri) return false;
463457
try {
464-
const text = textForLocation(uri, ts, description);
458+
const text = textForLocation(uri, ts, null);
465459
MatrixClientPeg.get().sendMessage(
466460
this.props.room.roomId,
467-
makeLocationContent(text, uri, ts, description),
461+
makeLocationContent(text, uri, ts, null),
468462
);
469463
} catch (e) {
470464
logger.error("Error sending location:", e);

src/i18n/strings/en_EN.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,10 +2129,6 @@
21292129
"Can't load this message": "Can't load this message",
21302130
"toggle event": "toggle event",
21312131
"Share location": "Share location",
2132-
"Share custom location": "Share custom location",
2133-
"Share my current location as a once off": "Share my current location as a once off",
2134-
"My location": "My location",
2135-
"Type of location share": "Type of location share",
21362132
"Failed to load group members": "Failed to load group members",
21372133
"Filter community members": "Filter community members",
21382134
"Are you sure you want to remove '%(roomName)s' from %(groupId)s?": "Are you sure you want to remove '%(roomName)s' from %(groupId)s?",

0 commit comments

Comments
 (0)