improvements + bookmarks

This commit is contained in:
2021-10-04 13:02:30 +02:00
parent a69a85aeb0
commit 0cabe9b0a5
12 changed files with 169 additions and 15 deletions
+18 -6
View File
@@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
import { AuthService } from '../../services/auth.service';
import { VoteService } from '../../services/vote.service';
import { CommentService } from '../../services/comment.service';
import { BookmarksService } from '../../services/bookmarks.service';
import { ModerationService } from '../../services/moderarion.service';
import { ConfirmDialog } from '../../ui/confirm/confirm.component';
@@ -20,7 +20,7 @@ export class UiEntry implements OnInit {
@Input() change: Function;
constructor(private authService: AuthService, private voteService: VoteService,
private moderationService: ModerationService, public dialog: MatDialog) { }
private moderationService: ModerationService, private bookmarksService: BookmarksService, public dialog: MatDialog) { }
ngOnInit(): void {
this.authService.auth.subscribe((auth: any) => {
@@ -36,26 +36,38 @@ export class UiEntry implements OnInit {
voteUp() {
this.voteService.voteEntryUp(this.entry.id).subscribe((result) => {
this.change && this.change()
this.change && this.change();
});
}
voteDown() {
this.voteService.voteEntryDown(this.entry.id).subscribe((result) => {
this.change && this.change()
this.change && this.change();
});
}
addBookmark() {
this.bookmarksService.addEntry(this.entry.id).subscribe((result) => {
this.entry.metadata.bookmarked = true;
});
}
removeBookmark() {
this.bookmarksService.removeEntry(this.entry.id).subscribe((result) => {
this.entry.metadata.bookmarked = false;
});
}
unvote() {
this.voteService.unvoteEntry(this.entry.id).subscribe((result) => {
this.change && this.change()
this.change && this.change();
});
}
deleteEntry(entry: any) {
const dialogRef = this.dialog.open(ConfirmDialog, {
data: {
'label': 'comment.confirmDelete',
'label': 'entry.confirmDelete',
'args': [ entry.title, entry.author ]
}
})