From 18c82d57ae0a36d7a46ad072143734de59b5ceb9 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 14 Jan 2022 15:57:39 +0000 Subject: [PATCH] Add setting for enabling location sharing (#7547) --- src/components/views/rooms/MessageComposer.tsx | 17 +++++++++++++---- .../tabs/user/PreferencesUserSettingsTab.tsx | 15 ++++++++++++++- src/i18n/strings/en_EN.json | 1 + src/settings/Settings.tsx | 6 ++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index dc6951fd46..8f737df273 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -286,12 +286,16 @@ export default class MessageComposer extends React.Component { 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); } @@ -348,9 +352,14 @@ export default class MessageComposer extends React.Component { 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 }); } @@ -525,7 +534,7 @@ export default class MessageComposer extends React.Component { buttons.push( , ); - if (SettingsStore.getValue("feature_location_share")) { + if (this.state.showLocationButton) { const sender = this.props.room.getMember( MatrixClientPeg.get().getUserId(), ); diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx index d3f99f31dc..e8e9af7f0d 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx @@ -296,6 +296,16 @@ export default class PreferencesUserSettingsTab extends React.Component { _t("Composer") } - { this.renderGroup(PreferencesUserSettingsTab.COMPOSER_SETTINGS) } + { this.renderGroup([ + ...PreferencesUserSettingsTab.COMPOSER_SETTINGS, + ...this.getShowLocationIfEnabled(), + ]) }
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 35049c2244..504834e1e5 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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)", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 7a2b952068..bc7e3d1bb3 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -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,