Skip to content

Commit

Permalink
Merge branch 'fix/address_book_toggles' into 'develop'
Browse files Browse the repository at this point in the history
Fix/address book toggles

See merge request papers/airgap/airgap-vault!463
  • Loading branch information
godenzim committed Jul 18, 2023
2 parents e020a0b + f7599fe commit 891af2f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ <h3 class="ion-padding-bottom" [innerHTML]="'interaction-selection.heading' | tr
</ion-col>
</ion-row>

<airgap-add-address [airGapTxs]="(transactionsDetails$ | async).value"></airgap-add-address>
<airgap-add-address *ngIf="areSuggestionsEnabled" [airGapTxs]="(transactionsDetails$ | async).value"></airgap-add-address>
</ion-content>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core'
import { Component, OnInit } from '@angular/core'
import { InteractionType, VaultStorageKey, VaultStorageService } from 'src/app/services/storage/storage.service'

import { ErrorCategory, handleErrorLocal } from '../../services/error-handler/error-handler.service'
Expand All @@ -7,23 +7,30 @@ import { NavigationService } from '../../services/navigation/navigation.service'
import { Store } from '@ngrx/store'
import { selectTransactionsDetails } from '../deserialized-detail/deserialized-detail.reducer'
import * as fromDeserializedDetail from '../deserialized-detail/deserialized-detail.reducer'
import { ContactsService } from 'src/app/services/contacts/contacts.service'

@Component({
selector: 'airgap-interaction-selection',
templateUrl: './interaction-selection.page.html',
styleUrls: ['./interaction-selection.page.scss']
})
export class InteractionSelectionPage {
export class InteractionSelectionPage implements OnInit {
private interactionOptions: IInteractionOptions
transactionsDetails$ = this.store.select(selectTransactionsDetails)
areSuggestionsEnabled: boolean = true

constructor(
private readonly navigationService: NavigationService,
private readonly storageService: VaultStorageService,
private readonly interactionService: InteractionService,
private readonly contactService: ContactsService,
private store: Store<fromDeserializedDetail.State>
) {}

async ngOnInit() {
this.areSuggestionsEnabled = await this.contactService.isSuggestionsEnabled()
}

public ionViewDidEnter(): void {
this.interactionOptions = this.navigationService.getState().interactionOptions
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/tab-settings/tab-settings.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ion-icon name="book-outline" slot="start"></ion-icon>
{{ 'tab-settings.welcome-onboarding_label' | translate }}
</ion-item>
<ion-item lines="True" (click)="goToAddressBook()" detail="true">
<ion-item *ngIf="!(bookEnabled$ | async)" lines="True" (click)="goToAddressBook()" detail="true">
<ion-icon name="person-add-outline" slot="start"></ion-icon>
{{ 'tab-settings.address_book_label' | translate }}
</ion-item>
Expand Down
10 changes: 4 additions & 6 deletions src/app/pages/tab-settings/tab-settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { EnvironmentContext, EnvironmentService } from 'src/app/services/environ
styleUrls: ['./tab-settings.page.scss']
})
export class TabSettingsPage implements OnInit {
public readonly secrets$: Observable<MnemonicSecret[]>
public readonly context$: Observable<EnvironmentContext>
public readonly secrets$: Observable<MnemonicSecret[]> = this.secretsService.getSecretsObservable()
public readonly context$: Observable<EnvironmentContext> = this.environmentService.getContextObservable()
public readonly bookEnabled$: Observable<boolean> = this.contactsService.isBookDisabled$()

constructor(
public readonly serializerService: SerializerService,
Expand All @@ -37,10 +38,7 @@ export class TabSettingsPage implements OnInit {
private readonly secureStorage: SecureStorageService,
public readonly storageService: VaultStorageService,
private readonly environmentService: EnvironmentService
) {
this.secrets$ = this.secretsService.getSecretsObservable()
this.context$ = this.environmentService.getContextObservable()
}
) {}

ngOnInit() {}

Expand Down
4 changes: 4 additions & 0 deletions src/app/services/contacts/contacts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export class ContactsService {
return !(await this.storageService.get(VaultStorageKey.ADDRESS_BOOK_DISABLED))
}

isBookDisabled$(): Observable<boolean> {
return this.storageService.subscribe(VaultStorageKey.ADDRESS_BOOK_DISABLED)
}

async setBookEnable(value: boolean) {
await this.storageService.set(VaultStorageKey.ADDRESS_BOOK_DISABLED, !value)
}
Expand Down

0 comments on commit 891af2f

Please sign in to comment.