Skip to content

Commit 09dd203

Browse files
authored
Add ability to follow from event actions (#143)
Signed-off-by: Harshil-Jani <[email protected]>
1 parent 5d91211 commit 09dd203

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/app/shared/event-actions/event-actions.html

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
</button>
88

99
<mat-menu #menu="matMenu">
10+
<button mat-menu-item (click)="follow()" *ngIf="profile?.status == 0">
11+
<mat-icon>person_add</mat-icon>
12+
<span>Follow</span>
13+
</button>
14+
15+
<button mat-menu-item (click)="unfollow()" *ngIf="profile?.status == 1">
16+
<mat-icon>person_remove</mat-icon>
17+
<span>Unfollow</span>
18+
</button>
19+
1020
<button mat-menu-item (click)="saveNote()" *ngIf="event && !event.saved" [matMenuTriggerFor]="labelMenu">
1121
<mat-icon>bookmark_add</mat-icon>
1222
<span>Bookmark</span>

src/app/shared/event-actions/event-actions.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Input } from '@angular/core';
22
import { NotesService } from 'src/app/services/notes';
33
import { ProfileService } from 'src/app/services/profile';
44
import { Utilities } from 'src/app/services/utilities';
5-
import { NostrEventDocument, NostrNoteDocument, NostrProfile, NostrProfileDocument } from '../../services/interfaces';
5+
import { NostrEventDocument, NostrNoteDocument, NostrProfile, NostrProfileDocument, ProfileStatus } from '../../services/interfaces';
66
import { MatSnackBar } from '@angular/material/snack-bar';
77
import { copyToClipboard } from '../utilities';
88
import { nip19 } from 'nostr-tools';
@@ -44,16 +44,23 @@ export class EventActionsComponent {
4444
async follow(circle?: number) {
4545
console.log('FOLLOW:', this.profile);
4646

47+
if(circle==null){
48+
circle=0;
49+
}
50+
4751
if (!this.profile) {
4852
return;
4953
}
5054

5155
// If not already following, add a full follow and download recent:
5256
if (this.profile.status != 1) {
57+
this.profile.circle = circle;
58+
this.profile.status = 1;
5359
await this.profileService.follow(this.profile.pubkey, circle);
5460
// this.feedService.downloadRecent([this.profile.pubkey]);
5561
} else {
5662
// If we already follow but just change the circle, do a smaller operation.
63+
this.profile.circle = circle;
5764
await this.profileService.setCircle(this.profile.pubkey, circle);
5865
}
5966
}
@@ -141,7 +148,7 @@ export class EventActionsComponent {
141148
if (!this.profile) {
142149
return;
143150
}
144-
151+
this.profile.status = 0;
145152
await this.profileService.unfollow(this.profile.pubkey);
146153
}
147154

@@ -184,9 +191,10 @@ export class EventActionsComponent {
184191

185192
if (this.event) {
186193
this.pubkey = this.event.pubkey;
187-
// this.profile = await this.profileService.getProfile(this.pubkey);
194+
this.profile = await this.profileService.getProfile(this.pubkey);
188195
} else if (this.profile) {
189196
this.pubkey = this.profile.pubkey;
197+
this.profile = await this.profileService.getProfile(this.pubkey);
190198
} else {
191199
// this.profile = await this.profileService.getProfile(this.pubkey);
192200
}

0 commit comments

Comments
 (0)