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:
1 parent
4ad11ea4ee
commit
44b481e177
4 files changed
+100
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user