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

Commit

Permalink
Add setting for enabling location sharing (#7547)
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam authored Jan 14, 2022
1 parent ae2cb63 commit 18c82d5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/components/views/rooms/MessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,16 @@ export default class MessageComposer extends React.Component<IProps, IState> {
showStickers: false,
showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"),
showPollsButton: SettingsStore.getValue("feature_polls"),
showLocationButton: SettingsStore.getValue("feature_location_share"),
showLocationButton: (
SettingsStore.getValue("feature_location_share") &&
SettingsStore.getValue("MessageComposerInput.showLocationButton")
),
};

this.instanceId = instanceCount++;

SettingsStore.monitorSetting("MessageComposerInput.showStickersButton", null);
SettingsStore.monitorSetting("MessageComposerInput.showLocationButton", null);
SettingsStore.monitorSetting("feature_polls", null);
SettingsStore.monitorSetting("feature_location_share", null);
}
Expand Down Expand Up @@ -348,9 +352,14 @@ export default class MessageComposer extends React.Component<IProps, IState> {
break;
}

case "MessageComposerInput.showLocationButton":
case "feature_location_share": {
const showLocationButton = SettingsStore.getValue(
"feature_location_share");
const showLocationButton = (
SettingsStore.getValue("feature_location_share") &&
SettingsStore.getValue(
"MessageComposerInput.showLocationButton",
)
);
if (this.state.showLocationButton !== showLocationButton) {
this.setState({ showLocationButton });
}
Expand Down Expand Up @@ -525,7 +534,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
buttons.push(
<UploadButton key="controls_upload" roomId={this.props.room.roomId} relation={this.props.relation} />,
);
if (SettingsStore.getValue("feature_location_share")) {
if (this.state.showLocationButton) {
const sender = this.props.room.getMember(
MatrixClientPeg.get().getUserId(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
});
}

getShowLocationIfEnabled(): string[] {
// TODO: when location sharing is out of labs, this can be deleted and
// we can just add this to COMPOSER_SETTINGS
if (SettingsStore.getValue("feature_location_share")) {
return ['MessageComposerInput.showLocationButton'];
} else {
return [];
}
}

render() {
let autoLaunchOption = null;
if (this.state.autoLaunchSupported) {
Expand Down Expand Up @@ -377,7 +387,10 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,

<div className="mx_SettingsTab_section">
<span className="mx_SettingsTab_subheading">{ _t("Composer") }</span>
{ this.renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS) }
{ this.renderGroup([
...PreferencesUserSettingsTab.COMPOSER_SETTINGS,
...this.getShowLocationIfEnabled(),
]) }
</div>

<div className="mx_SettingsTab_section">
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
"Use custom size": "Use custom size",
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
"Show stickers button": "Show stickers button",
"Enable location sharing": "Enable location sharing",
"Use a more compact 'Modern' layout": "Use a more compact 'Modern' layout",
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
"Show join/leave messages (invites/removes/bans unaffected)": "Show join/leave messages (invites/removes/bans unaffected)",
Expand Down
6 changes: 6 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ export const SETTINGS: {[setting: string]: ISetting} = {
default: true,
controller: new UIFeatureController(UIFeature.Widgets, false),
},
"MessageComposerInput.showLocationButton": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: _td('Enable location sharing'),
default: true,
controller: new UIFeatureController(UIFeature.Widgets, false),
},
// TODO: Wire up appropriately to UI (FTUE notifications)
"Notifications.alwaysShowBadgeCounts": {
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
Expand Down

0 comments on commit 18c82d5

Please sign in to comment.