Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings/Privacy: fix input of custom block explorer #1367

Merged
merged 1 commit into from
Mar 14, 2023
Merged
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
353 changes: 173 additions & 180 deletions views/Settings/Privacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { localeString } from './../../utils/LocaleUtils';
import { themeColor } from './../../utils/ThemeUtils';

import DropdownSetting from './../../components/DropdownSetting';
import LoadingIndicator from './../../components/LoadingIndicator';
import Switch from './../../components/Switch';
import TextInput from './../../components/TextInput';

Expand Down Expand Up @@ -56,10 +55,13 @@ export default class Privacy extends React.Component<
customBlockExplorer:
(settings.privacy && settings.privacy.customBlockExplorer) ||
'',
clipboard: settings.privacy && settings.privacy.clipboard,
lurkerMode: settings.privacy && settings.privacy.lurkerMode,
clipboard:
(settings.privacy && settings.privacy.clipboard) || false,
lurkerMode:
(settings.privacy && settings.privacy.lurkerMode) || false,
enableMempoolRates:
settings.privacy && settings.privacy.enableMempoolRates
(settings.privacy && settings.privacy.enableMempoolRates) ||
false
});
}
Copy link
Contributor

@shubhamkmr04 shubhamkmr04 Mar 14, 2023

Choose a reason for hiding this comment

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

Why did we change it. Do we want all three toggles to be false by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hit a linter error. this made it go away

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay got it.


Expand All @@ -81,7 +83,7 @@ export default class Privacy extends React.Component<
lurkerMode,
enableMempoolRates
} = this.state;
const { updateSettings, loading }: any = SettingsStore;
const { updateSettings }: any = SettingsStore;

const BackButton = () => (
<Icon
Expand Down Expand Up @@ -117,198 +119,189 @@ export default class Privacy extends React.Component<
borderBottomWidth: 0
}}
/>
{loading ? (
<LoadingIndicator />
) : (
<ScrollView style={{ flex: 1, padding: 15 }}>
<DropdownSetting
title={localeString(
'views.Settings.Privacy.blockExplorer'
)}
selectedValue={defaultBlockExplorer}
onValueChange={async (value: string) => {
this.setState({
defaultBlockExplorer: value
});
await updateSettings({
privacy: {
defaultBlockExplorer: value,
customBlockExplorer,
clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
values={BLOCK_EXPLORER_KEYS}
/>

{defaultBlockExplorer === 'Custom' && (
<>
<Text
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular'
}}
>
{localeString(
'views.Settings.Privacy.customBlockExplorer'
)}
</Text>
<TextInput
value={customBlockExplorer}
onChangeText={async (text: string) => {
this.setState({
customBlockExplorer: text
});

await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer: text,
clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
/>
</>
<ScrollView style={{ flex: 1, padding: 15 }}>
<DropdownSetting
title={localeString(
'views.Settings.Privacy.blockExplorer'
)}
selectedValue={defaultBlockExplorer}
onValueChange={async (value: string) => {
this.setState({
defaultBlockExplorer: value
});
await updateSettings({
privacy: {
defaultBlockExplorer: value,
customBlockExplorer,
clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
values={BLOCK_EXPLORER_KEYS}
/>

<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
}}
>
<ListItem.Title
{defaultBlockExplorer === 'Custom' && (
<>
<Text
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
fontFamily: 'Lato-Regular'
}}
>
{localeString(
'views.Settings.Privacy.clipboard'
'views.Settings.Privacy.customBlockExplorer'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
</Text>
<TextInput
value={customBlockExplorer}
onChangeText={async (text: string) => {
this.setState({
customBlockExplorer: text
});

await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer: text,
clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
>
<Switch
value={clipboard}
onValueChange={async () => {
this.setState({
clipboard: !clipboard
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard: !clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
/>
</View>
</ListItem>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
/>
</>
)}

<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
}}
>
{localeString(
'views.Settings.Privacy.lurkerMode'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<Switch
value={lurkerMode}
onValueChange={async () => {
this.setState({
lurkerMode: !lurkerMode
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard,
lurkerMode: !lurkerMode,
enableMempoolRates
}
});
}}
/>
</View>
</ListItem>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
{localeString('views.Settings.Privacy.clipboard')}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
<Switch
value={clipboard}
onValueChange={async () => {
this.setState({
clipboard: !clipboard
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard: !clipboard,
lurkerMode,
enableMempoolRates
}
});
}}
>
{localeString(
'views.Settings.Privacy.enableMempoolRates'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
/>
</View>
</ListItem>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
}}
>
{localeString('views.Settings.Privacy.lurkerMode')}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<Switch
value={lurkerMode}
onValueChange={async () => {
this.setState({
lurkerMode: !lurkerMode
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard,
lurkerMode: !lurkerMode,
enableMempoolRates
}
});
}}
>
<Switch
value={enableMempoolRates}
onValueChange={async () => {
this.setState({
/>
</View>
</ListItem>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: themeColor('background')
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular',
left: -10
}}
>
{localeString(
'views.Settings.Privacy.enableMempoolRates'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<Switch
value={enableMempoolRates}
onValueChange={async () => {
this.setState({
enableMempoolRates: !enableMempoolRates
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard,
lurkerMode,
enableMempoolRates:
!enableMempoolRates
});
await updateSettings({
privacy: {
defaultBlockExplorer,
customBlockExplorer,
clipboard,
lurkerMode,
enableMempoolRates:
!enableMempoolRates
}
});
}}
/>
</View>
</ListItem>
</ScrollView>
)}
}
});
}}
/>
</View>
</ListItem>
</ScrollView>
</View>
);
}
Expand Down