Skip to content

Commit

Permalink
Add confirmation on backup
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Jul 4, 2024
1 parent 152a481 commit 4a16c48
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/src/app/account/backup/backup.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>Backup your account</h1>
</mat-card>

<p>
<button mat-flat-button (click)="backupToFile()">
<button mat-flat-button (click)="confirmBackup()">
<mat-icon>done</mat-icon>
Confirm you have saved the recovery phrase
</button>
Expand Down
1 change: 0 additions & 1 deletion app/src/app/account/backup/backup.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ mat-card {

.copy-button {
margin-left: 0.1em;

}
12 changes: 10 additions & 2 deletions app/src/app/account/backup/backup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { Web5IdentityAgent } from '@web5/identity-agent';
import { AppService } from '../../app.service';
import { CommonModule } from '@angular/common';
import { MatTooltipModule } from '@angular/material/tooltip';
import { Router, RouterModule } from '@angular/router';

@Component({
selector: 'app-backup',
standalone: true,
imports: [CommonModule, MatButtonModule, MatIconModule, MatCardModule, MatTooltipModule],
imports: [CommonModule, MatButtonModule, MatIconModule, MatCardModule, MatTooltipModule, RouterModule],
templateUrl: './backup.component.html',
styleUrl: './backup.component.scss'
})
Expand All @@ -21,7 +22,7 @@ export class BackupComponent {

reveal = signal<boolean>(false);

constructor(public identityService: IdentityService, public appService: AppService) {
constructor(private router: Router, public identityService: IdentityService, public appService: AppService) {
}

async backupToFile() {
Expand All @@ -39,6 +40,13 @@ export class BackupComponent {
}
}

confirmBackup() {
this.appService.state().backupConfirmed = true;
this.appService.saveState();

this.router.navigate(['/introduction']);
}

async saveFile(data: string) {

const blob = new Blob([data], { type: 'text/plain' });
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/account/password/password.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ export class PasswordComponent {
this.invalidPassword.set(false);
this.unlocking.set(false);

this.router.navigate(['/account', 'did:dht:umj7apgmkodtrb7mdpjo4h7xinqdnatzgy38j7wi67k9c7sdns1o']);
this.router.navigate(['/introduction']);
}
}
5 changes: 5 additions & 0 deletions app/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Web5ConnectResult } from '@web5/api';

export interface AppState {
selectedAccount: string;
backupConfirmed?: boolean;
}

export interface Account {
Expand Down Expand Up @@ -45,6 +46,10 @@ export class AppService {
this.storage.save('accounts', this.accounts());
}

saveState() {
this.storage.save('state', this.state());
}

async initialize() {
console.log('Initializing Ariton...');

Expand Down
10 changes: 8 additions & 2 deletions app/src/app/introduction/introduction.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ <h1>Welcome</h1>
<button mat-flat-button [routerLink]="['/account/password']">Set a password</button>
}
@else {
<button mat-flat-button disabled="true" [routerLink]="['/account/password']"><s>Set a password</s></button>
<button mat-flat-button [routerLink]="['/account/password']"><s>Set a password</s></button>
}

@if(!backup()) {
<button mat-flat-button [routerLink]="['/account/backup']">Backup your account</button>
}
@else {
<button mat-flat-button [routerLink]="['/account/backup']"><s>Backup your account</s></button>
}

<button mat-flat-button [routerLink]="['/account/backup']">Backup your account</button>


</p>

Expand Down
3 changes: 3 additions & 0 deletions app/src/app/introduction/introduction.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ export class IntroductionComponent {
appService = inject(AppService);

reset = computed(() => (this.appService.account().passwordHash));

backup = computed(() => (this.appService.state().backupConfirmed));

}

0 comments on commit 4a16c48

Please sign in to comment.