Add in-app and OS notifications for new messages

Polls every 30s for unread messages on both kid and admin sides.
Kid app shows a tappable in-page toast and fires a browser OS
notification when a parent message arrives while the tab is open.
Admin app shows a toast and OS notification when a student replies.
Clicking the OS notification focuses the tab and opens the messages view.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-08-24 10:19:29 -04:00
1 parent 4ad11ea4ee
commit 44b481e177
4 files changed
+100

No files matched your search

+5
View File
@@ -1770,6 +1770,11 @@ app.put('/api/submissions/:id/grade', requirePin, (req, res) => {
// ---------- messages ----------
app.get('/api/students/:id/messages/count', (req, res) => {
const { n } = db.prepare(`SELECT COUNT(*) AS n FROM messages WHERE student_id = ? AND sender = 'parent' AND read_at IS NULL`).get(req.params.id);
res.json({ count: n });
});
app.get('/api/students/:id/messages', (req, res) => {
const msgs = db.prepare(`SELECT id, sender, body, sent_at, read_at FROM messages WHERE student_id = ? ORDER BY sent_at`).all(req.params.id);
// Mark parent messages as read when student loads the thread