More webapp changes+fixes
This commit is contained in:
@@ -390,4 +390,33 @@ export class ChannelDetailComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isUserSubscribed(): boolean {
|
||||
return this.channel()?.subscription !== null;
|
||||
}
|
||||
|
||||
toggleSelfSubscription(): void {
|
||||
const channel = this.channel();
|
||||
const userId = this.authService.getUserId();
|
||||
if (!channel || !userId) return;
|
||||
|
||||
if (this.isUserSubscribed()) {
|
||||
// Unsubscribe
|
||||
const subscriptionId = channel.subscription!.subscription_id;
|
||||
this.apiService.deleteSubscription(userId, subscriptionId).subscribe({
|
||||
next: () => {
|
||||
this.notification.success('Unsubscribed from channel');
|
||||
this.loadChannel(channel.channel_id);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Subscribe
|
||||
this.apiService.createSubscription(userId, { channel_id: channel.channel_id }).subscribe({
|
||||
next: () => {
|
||||
this.notification.success('Subscribed to channel');
|
||||
this.loadChannel(channel.channel_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user