Skip to content

Commit

Permalink
Persist the last npub entered.
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Dec 28, 2024
1 parent 1f27e10 commit 280b834
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/app/pages/home/home.component.ts
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 { BreadcrumbComponent } from '../../components/breadcrumb.component';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
Expand Down Expand Up @@ -94,13 +94,22 @@ import { Router } from '@angular/router';
</div> -->
`
})
export class HomeComponent {
export class HomeComponent implements OnInit {
profileId: string = '';
private readonly STORAGE_KEY = 'angor-profile-id';

constructor(private router: Router) {}

ngOnInit() {
const savedProfileId = localStorage.getItem(this.STORAGE_KEY);
if (savedProfileId) {
this.profileId = savedProfileId;
}
}

openProfile() {
if (this.profileId) {
localStorage.setItem(this.STORAGE_KEY, this.profileId);
this.router.navigate(['/profile', this.profileId]);
}
}
Expand Down

0 comments on commit 280b834

Please sign in to comment.