From 6dc42ac2ce1d1664bced92b8877daaeb0724d4d2 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 17 Mar 2023 15:11:57 -0400 Subject: [PATCH 1/3] Privacy: Lurker mode: fix toggle behavior --- components/Amount.tsx | 16 ++-------------- stores/SettingsStore.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/components/Amount.tsx b/components/Amount.tsx index 78c8e45a1..540da225a 100644 --- a/components/Amount.tsx +++ b/components/Amount.tsx @@ -181,12 +181,7 @@ export default class Amount extends React.Component { UnitsStore.changeUnits()} onLongPress={() => { - if (lurkerMode) { - SettingsStore.toggleLurker(); - } - }} - onPressOut={() => { - if (!lurkerMode && lurkerExposed) { + if (!lurkerExposed && lurkerMode) { SettingsStore.toggleLurker(); } }} @@ -240,17 +235,10 @@ export default class Amount extends React.Component { UnitsStore.changeUnits()} onLongPress={() => { - if (lurkerMode) { + if (!lurkerExposed && lurkerMode) { SettingsStore.toggleLurker(); } }} - onPressOut={() => { - if (!lurkerMode && lurkerExposed) { - setTimeout(() => { - SettingsStore.toggleLurker(); - }, 3000); - } - }} > { - if (this.settings.privacy.lurkerMode) { - this.lurkerExposed = true; - } else { + this.lurkerExposed = true; + this.settings.privacy.lurkerMode = false; + + setTimeout(() => { this.lurkerExposed = false; - } - this.settings.privacy.lurkerMode = !this.settings.privacy.lurkerMode; + this.settings.privacy.lurkerMode = true; + }, 3000); }; @action From 5421c8d32cb25e574f78367ca9ca7a3157bd6b91 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Fri, 17 Mar 2023 15:25:08 -0400 Subject: [PATCH 2/3] Privacy: Lurker mode: make Channels pane toggleable --- components/Channels/ChannelsHeader.tsx | 2 +- views/Channels/ChannelsPane.tsx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/Channels/ChannelsHeader.tsx b/components/Channels/ChannelsHeader.tsx index 8a51942f7..98d2cdd02 100644 --- a/components/Channels/ChannelsHeader.tsx +++ b/components/Channels/ChannelsHeader.tsx @@ -32,7 +32,7 @@ function TotalRow({ {/* TODO: localize */} Total {kind} - + ); } diff --git a/views/Channels/ChannelsPane.tsx b/views/Channels/ChannelsPane.tsx index 5539dd829..01bd6d74e 100644 --- a/views/Channels/ChannelsPane.tsx +++ b/views/Channels/ChannelsPane.tsx @@ -137,6 +137,10 @@ export default class ChannelsPane extends React.PureComponent { closedChannels } = ChannelsStore; + // trigger channelPane update when lurkerMode status changes + // this allows us to redraw the channel balance bars + const { lurkerMode } = SettingsStore.settings.privacy; + let headerString; let channelsData; switch (channelsType) { @@ -174,9 +178,9 @@ export default class ChannelsPane extends React.PureComponent { } /> {loading ? ( From 290e8a7c12c0b88144d930f468d92290df2c3fa1 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Sat, 18 Mar 2023 14:32:24 -0400 Subject: [PATCH 3/3] Privacy: Lurker mode: make KeyValue component toggleable --- components/KeyValue.tsx | 135 +++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 63 deletions(-) diff --git a/components/KeyValue.tsx b/components/KeyValue.tsx index 9673eca41..8edeb143c 100644 --- a/components/KeyValue.tsx +++ b/components/KeyValue.tsx @@ -7,88 +7,97 @@ import { View } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; +import { inject, observer } from 'mobx-react'; import { Body } from './text/Body'; import { Row } from './layout/Row'; -import { themeColor } from './../utils/ThemeUtils'; -import PrivacyUtils from './../utils/PrivacyUtils'; +import { themeColor } from '../utils/ThemeUtils'; +import PrivacyUtils from '../utils/PrivacyUtils'; +import SettingsStore from '../stores/SettingsStore'; -export default function KeyValue({ - keyValue, - value, - color, - sensitive -}: { +interface KeyValueProps { keyValue: string; value?: any; color?: string; sensitive?: boolean; -}) { - { - /* TODO: rig up RTL */ - } - const isCopyable = typeof value === 'string' || typeof value === 'number'; - const rtl = false; - const Key = ( - + SettingsStore: SettingsStore; +} + +@inject('SettingsStore') +@observer +export default class KeyValue extends React.Component { + render() { + const { keyValue, value, color, sensitive, SettingsStore } = this.props; + + const { lurkerMode } = SettingsStore?.settings?.privacy; + + { + /* TODO: rig up RTL */ + } + const isCopyable = + typeof value === 'string' || typeof value === 'number'; + const rtl = false; + const Key = ( + + + {keyValue} + + + ); + const Value = isCopyable ? ( - {keyValue} + {sensitive ? PrivacyUtils.sensitiveValue(value) : value} - - ); - const Value = isCopyable ? ( - - {sensitive ? PrivacyUtils.sensitiveValue(value) : value} - - ) : ( - value - ); + ) : ( + value + ); - const copyText = () => { - Clipboard.setString(value); - Vibration.vibrate(50); - }; + const copyText = () => { + Clipboard.setString(value); + Vibration.vibrate(50); + }; - const KeyValueRow = () => ( - - - - {rtl ? Value : Key} - - - - {rtl ? Key : Value} - - - ); + const KeyValueRow = () => ( + + + + {rtl ? Value : Key} + + + + {rtl ? Key : Value} + + + ); - const InteractiveKeyValueRow = () => - isCopyable ? ( - copyText()}> + const InteractiveKeyValueRow = () => + !!lurkerMode && isCopyable ? ( + copyText()}> + + + ) : ( - - ) : ( - - ); + ); - return ( - - - - ); + return ( + + + + ); + } } const styles = StyleSheet.create({