1.2 #11

Merged
jank merged 6 commits from main into prod 2025-01-21 12:37:13 +00:00
2 changed files with 16 additions and 4 deletions
Showing only changes of commit 3e0b17ebe6 - Show all commits

View file

@ -9,6 +9,7 @@ import { Link } from '../models/link';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { ConfirmationModalComponent } from '../confirmation-modal/confirmation-modal.component';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'app-dashboard',
@ -20,7 +21,7 @@ export class DashboardComponent {
public links: Link[] = [];
displayedColumns: string[] = ['id', 'name', 'link', 'shortLink', 'actions'];
constructor(private linkService: LinkService, private router: Router, private dialog: MatDialog) { };
constructor(private linkService: LinkService, private router: Router, private dialog: MatDialog, private snackBar: MatSnackBar) { };
copyLink(id: string) {
navigator.clipboard.writeText(this.getShortLink(id));
@ -62,10 +63,21 @@ export class DashboardComponent {
}
}).afterClosed().subscribe((accepted: boolean) => {
if (accepted) {
this.linkService.deleteLink(link.id); // TODO Check if something went wrong
this.linkService.deleteLink(link.id).catch(() => {
const errorNotification = this.snackBar.open("Something went wrong.");
setTimeout(() => {
errorNotification.dismiss();
}, 5000);
});
this.links = this.links.filter(givenLink => {
return givenLink.id != link.id;
});
const notification = this.snackBar.open(link.name + " was deleted.");
setTimeout(() => {
notification.dismiss();
}, 2000);
}
});
}

View file

@ -18,8 +18,8 @@ export class LinkService {
return this.pb.collection('links').getOne<Link>(id);
}
deleteLink(id: string) {
this.pb.collection('links').delete(id);
deleteLink(id: string): Promise<boolean> {
return this.pb.collection('links').delete(id);
}
createLink(link: any): Promise<RecordModel> {