feat: add notification deletion functionality in API and EditorLayout

This commit is contained in:
SaelixCode
2026-02-27 12:47:16 -05:00
parent f4700ebfc9
commit 6bbd9b6484
3 changed files with 75 additions and 12 deletions
+19
View File
@@ -751,6 +751,25 @@ app.post('/api/notifications/read', async (req: Request, res: Response) => {
}
});
app.delete('/api/notifications/:id', async (req: Request, res: Response) => {
try {
const id = parseInt(req.params.id as string, 10);
DatabaseService.getInstance().deleteNotification(id);
res.json({ success: true });
} catch (error) {
res.status(500).json({ error: 'Failed to delete notification' });
}
});
app.delete('/api/notifications', async (req: Request, res: Response) => {
try {
DatabaseService.getInstance().deleteAllNotifications();
res.json({ success: true });
} catch (error) {
res.status(500).json({ error: 'Failed to clear notifications' });
}
});
app.post('/api/notifications/test', async (req: Request, res: Response) => {
try {
const { type, url } = req.body;
+10
View File
@@ -216,4 +216,14 @@ export class DatabaseService {
const stmt = this.db.prepare('UPDATE notification_history SET is_read = 1');
stmt.run();
}
public deleteNotification(id: number): void {
const stmt = this.db.prepare('DELETE FROM notification_history WHERE id = ?');
stmt.run(id);
}
public deleteAllNotifications(): void {
const stmt = this.db.prepare('DELETE FROM notification_history');
stmt.run();
}
}