mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 15:46:43 +00:00
feat: add notification deletion functionality in API and EditorLayout
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user