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

Option to skip "name this contact" screen when send a TX to an unknown address. #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions src/components/layouts/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@
</select>
</div>

<div class="setting">
<div class="description">
<label class="nq-h2" for="askForLabeling">{{ $t('Ask for labels') }}</label>
<p class="nq-text">
{{ $t('Ask for a label when sending to an unknown address?') }}
</p>
</div>

<select
id="askForLabeling"
name="askForLabeling"
@input="setAskForRecipientLabeling(!!parseInt($event.target.value))"
>
<option value="1" :selected="askForRecipientLabeling">{{ $t('Yes') }}</option>
<option value="0" :selected="!askForRecipientLabeling">{{ $t('No') }}</option>
</select>
</div>

<div class="setting">
<div class="description">
<label class="nq-h2" for="contact-import">{{ $t('Import Contacts') }}</label>
Expand Down
5 changes: 2 additions & 3 deletions src/components/modals/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export default defineComponent({
const { state: addresses$, activeAddressInfo, addressInfos } = useAddressStore();
const { contactsArray: contacts, setContact, getLabel } = useContactsStore();
const { state: network$ } = useNetworkStore();
const { amountsHidden, askForRecipientLabeling } = useSettingsStore();

const recipientDetailsOpened = ref(false);
const recipientWithLabel = ref<{address: string, label: string, type: RecipientType} | null>(null);
Expand Down Expand Up @@ -295,7 +296,7 @@ export default defineComponent({
}

recipientWithLabel.value = { address, label, type };
if (!label) {
if (askForRecipientLabeling.value && !label) {
recipientDetailsOpened.value = true;
} else {
page.value = Pages.AMOUNT_INPUT;
Expand Down Expand Up @@ -542,8 +543,6 @@ export default defineComponent({
feeSelectionOpened.value = false;
}

const { amountsHidden } = useSettingsStore();

return {
// General
Pages,
Expand Down
6 changes: 6 additions & 0 deletions src/stores/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type SettingsState = {
language: string, // locale
colorMode: ColorMode,
amountsHidden: boolean,
askForRecipientLabeling: boolean,
};

export const useSettingsStore = createStore({
Expand All @@ -21,12 +22,14 @@ export const useSettingsStore = createStore({
language: detectLanguage(),
colorMode: ColorMode.AUTOMATIC,
amountsHidden: false,
askForRecipientLabeling: true,
}),
getters: {
decimals: (state): Readonly<number> => state.decimals,
language: (state): Readonly<string> => state.language,
colorMode: (state): Readonly<ColorMode> => state.colorMode,
amountsHidden: (state): Readonly<boolean> => state.amountsHidden,
askForRecipientLabeling: (state): Readonly<boolean> => state.askForRecipientLabeling,
},
actions: {
setDecimals(num: 0 | 2 | 5 = 0) {
Expand All @@ -41,6 +44,9 @@ export const useSettingsStore = createStore({
this.state.colorMode = colorMode;
}
},
setAskForRecipientLabeling(ask: boolean) {
this.state.askForRecipientLabeling = ask;
},
toggleAmountsHidden() {
this.state.amountsHidden = !this.state.amountsHidden;
},
Expand Down