Skip to content

Commit

Permalink
Add ability to follow from event actions (#143)
Browse files Browse the repository at this point in the history
Signed-off-by: Harshil-Jani <[email protected]>
  • Loading branch information
Harshil-Jani authored Apr 16, 2024
1 parent 5d91211 commit 09dd203
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/app/shared/event-actions/event-actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
</button>

<mat-menu #menu="matMenu">
<button mat-menu-item (click)="follow()" *ngIf="profile?.status == 0">
<mat-icon>person_add</mat-icon>
<span>Follow</span>
</button>

<button mat-menu-item (click)="unfollow()" *ngIf="profile?.status == 1">
<mat-icon>person_remove</mat-icon>
<span>Unfollow</span>
</button>

<button mat-menu-item (click)="saveNote()" *ngIf="event && !event.saved" [matMenuTriggerFor]="labelMenu">
<mat-icon>bookmark_add</mat-icon>
<span>Bookmark</span>
Expand Down
14 changes: 11 additions & 3 deletions src/app/shared/event-actions/event-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input } from '@angular/core';
import { NotesService } from 'src/app/services/notes';
import { ProfileService } from 'src/app/services/profile';
import { Utilities } from 'src/app/services/utilities';
import { NostrEventDocument, NostrNoteDocument, NostrProfile, NostrProfileDocument } from '../../services/interfaces';
import { NostrEventDocument, NostrNoteDocument, NostrProfile, NostrProfileDocument, ProfileStatus } from '../../services/interfaces';
import { MatSnackBar } from '@angular/material/snack-bar';
import { copyToClipboard } from '../utilities';
import { nip19 } from 'nostr-tools';
Expand Down Expand Up @@ -44,16 +44,23 @@ export class EventActionsComponent {
async follow(circle?: number) {
console.log('FOLLOW:', this.profile);

if(circle==null){
circle=0;
}

if (!this.profile) {
return;
}

// If not already following, add a full follow and download recent:
if (this.profile.status != 1) {
this.profile.circle = circle;
this.profile.status = 1;
await this.profileService.follow(this.profile.pubkey, circle);
// this.feedService.downloadRecent([this.profile.pubkey]);
} else {
// If we already follow but just change the circle, do a smaller operation.
this.profile.circle = circle;
await this.profileService.setCircle(this.profile.pubkey, circle);
}
}
Expand Down Expand Up @@ -141,7 +148,7 @@ export class EventActionsComponent {
if (!this.profile) {
return;
}

this.profile.status = 0;
await this.profileService.unfollow(this.profile.pubkey);
}

Expand Down Expand Up @@ -184,9 +191,10 @@ export class EventActionsComponent {

if (this.event) {
this.pubkey = this.event.pubkey;
// this.profile = await this.profileService.getProfile(this.pubkey);
this.profile = await this.profileService.getProfile(this.pubkey);
} else if (this.profile) {
this.pubkey = this.profile.pubkey;
this.profile = await this.profileService.getProfile(this.pubkey);
} else {
// this.profile = await this.profileService.getProfile(this.pubkey);
}
Expand Down

0 comments on commit 09dd203

Please sign in to comment.