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

Commit 18c82d5

Browse files
authored
Add setting for enabling location sharing (#7547)
1 parent ae2cb63 commit 18c82d5

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

src/components/views/rooms/MessageComposer.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,16 @@ export default class MessageComposer extends React.Component<IProps, IState> {
286286
showStickers: false,
287287
showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"),
288288
showPollsButton: SettingsStore.getValue("feature_polls"),
289-
showLocationButton: SettingsStore.getValue("feature_location_share"),
289+
showLocationButton: (
290+
SettingsStore.getValue("feature_location_share") &&
291+
SettingsStore.getValue("MessageComposerInput.showLocationButton")
292+
),
290293
};
291294

292295
this.instanceId = instanceCount++;
293296

294297
SettingsStore.monitorSetting("MessageComposerInput.showStickersButton", null);
298+
SettingsStore.monitorSetting("MessageComposerInput.showLocationButton", null);
295299
SettingsStore.monitorSetting("feature_polls", null);
296300
SettingsStore.monitorSetting("feature_location_share", null);
297301
}
@@ -348,9 +352,14 @@ export default class MessageComposer extends React.Component<IProps, IState> {
348352
break;
349353
}
350354

355+
case "MessageComposerInput.showLocationButton":
351356
case "feature_location_share": {
352-
const showLocationButton = SettingsStore.getValue(
353-
"feature_location_share");
357+
const showLocationButton = (
358+
SettingsStore.getValue("feature_location_share") &&
359+
SettingsStore.getValue(
360+
"MessageComposerInput.showLocationButton",
361+
)
362+
);
354363
if (this.state.showLocationButton !== showLocationButton) {
355364
this.setState({ showLocationButton });
356365
}
@@ -525,7 +534,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
525534
buttons.push(
526535
<UploadButton key="controls_upload" roomId={this.props.room.roomId} relation={this.props.relation} />,
527536
);
528-
if (SettingsStore.getValue("feature_location_share")) {
537+
if (this.state.showLocationButton) {
529538
const sender = this.props.room.getMember(
530539
MatrixClientPeg.get().getUserId(),
531540
);

src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
296296
});
297297
}
298298

299+
getShowLocationIfEnabled(): string[] {
300+
// TODO: when location sharing is out of labs, this can be deleted and
301+
// we can just add this to COMPOSER_SETTINGS
302+
if (SettingsStore.getValue("feature_location_share")) {
303+
return ['MessageComposerInput.showLocationButton'];
304+
} else {
305+
return [];
306+
}
307+
}
308+
299309
render() {
300310
let autoLaunchOption = null;
301311
if (this.state.autoLaunchSupported) {
@@ -377,7 +387,10 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
377387

378388
<div className="mx_SettingsTab_section">
379389
<span className="mx_SettingsTab_subheading">{ _t("Composer") }</span>
380-
{ this.renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS) }
390+
{ this.renderGroup([
391+
...PreferencesUserSettingsTab.COMPOSER_SETTINGS,
392+
...this.getShowLocationIfEnabled(),
393+
]) }
381394
</div>
382395

383396
<div className="mx_SettingsTab_section">

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@
892892
"Use custom size": "Use custom size",
893893
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
894894
"Show stickers button": "Show stickers button",
895+
"Enable location sharing": "Enable location sharing",
895896
"Use a more compact 'Modern' layout": "Use a more compact 'Modern' layout",
896897
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
897898
"Show join/leave messages (invites/removes/bans unaffected)": "Show join/leave messages (invites/removes/bans unaffected)",

src/settings/Settings.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ export const SETTINGS: {[setting: string]: ISetting} = {
407407
default: true,
408408
controller: new UIFeatureController(UIFeature.Widgets, false),
409409
},
410+
"MessageComposerInput.showLocationButton": {
411+
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
412+
displayName: _td('Enable location sharing'),
413+
default: true,
414+
controller: new UIFeatureController(UIFeature.Widgets, false),
415+
},
410416
// TODO: Wire up appropriately to UI (FTUE notifications)
411417
"Notifications.alwaysShowBadgeCounts": {
412418
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,

0 commit comments

Comments
 (0)