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

Add setting for enabling location sharing #7547

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
),
Comment on lines +289 to +292
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should've leveraged Settings controllers to be always off when feature_location_share is off, e.g

"Spaces.enabledMetaSpaces": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
default: {
[MetaSpace.Home]: true,
},
controller: new IncompatibleController("feature_spaces_metaspaces", {
[MetaSpace.Home]: true,
}, false),
},

};

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