set metadata for loged in user

This commit is contained in:
missmeowness 2023-05-02 18:34:11 +03:00
parent f19123c2cf
commit ca31c46f00
2 changed files with 14 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import { OptionsService } from './services/options';
import { LabelService } from './services/label';
import { TranslateService } from '@ngx-translate/core';
import { BadgeService } from './services/badge';
import { State } from './services/state';
@Component({
selector: 'app-root',
@ -66,7 +67,8 @@ export class AppComponent {
public ui: UIService,
private bottomSheet: MatBottomSheet,
public searchService: SearchService,
public theme: ThemeService
public theme: ThemeService,
private state: State
) {
if (!this.visibilityHandler) {
this.visibilityHandler = addEventListener('visibilitychange', (event) => {
@ -96,7 +98,8 @@ export class AppComponent {
}
this.authService.authInfo$.subscribe(async (auth) => {
auth.publicKeyHex;
this.state.pubkey = auth.publicKeyHex;
this.authenticated = auth.authenticated();

View File

@ -13,6 +13,9 @@ export class StateService {
switch (event.kind) {
case Kind.Metadata:
this.addIfNewer(event, event.pubkey, this.state.events.metadata);
if (this.state.pubkey == event.pubkey) {
this.state.metadata = event;
}
break;
case Kind.Text:
this.addIfMissing(event, this.state.events.shortTextNote);
@ -21,7 +24,8 @@ export class StateService {
this.addIfNewer(event, event.pubkey, this.state.events.contacts);
break;
case Kind.Reaction:
this.addIfNewer(event, event.content, this.state.events.reaction)
this.addIfNewer(event, event.content, this.state.events.reaction);
break;
}
}
@ -56,6 +60,10 @@ export class State {
circles: Circle[] = [];
metadata?: NostrEvent;
pubkey?: String;
events: EventsState = {
metadata: new Map(),
shortTextNote: new Map(),