#13: pin a message
Any participant can pin/unpin a message from its ⋮ menu. Adds pinned_at/pinned_by columns, /api/messages/pin (toggle, broadcasts chat-pinned) and /api/messages/pinned (list, newest first, excludes deleted + delete-for-me). The conversation shows a pinned strip under the header (latest pin + count); tap it to jump to the message, × to unpin. Live-updates across participants and devices. Added pin/pinOff Lucide icons. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -211,6 +211,11 @@ const messages = {
|
||||
// Last message in a group that THIS user hasn't hidden (so a "delete for me" on the last message
|
||||
// rolls the sidebar preview back to the previous one, instead of showing what they just removed).
|
||||
lastInConversationForUser: (conversationId, userId) => db.prepare('SELECT * FROM messages WHERE conversation_id=? AND id NOT IN (SELECT message_id FROM message_hidden WHERE user_id=?) ORDER BY created_at DESC LIMIT 1').get(conversationId, userId),
|
||||
// #13 Pin a message: set/clear pinned_at + pinned_by.
|
||||
setPinned: (id, pinnedAt, pinnedBy) => db.prepare('UPDATE messages SET pinned_at=?, pinned_by=? WHERE id=?').run(pinnedAt, pinnedBy, id),
|
||||
// Pinned messages in a group / DM (newest pin first, deleted excluded).
|
||||
pinnedInConversation: (conversationId) => db.prepare('SELECT * FROM messages WHERE conversation_id=? AND pinned_at IS NOT NULL AND deleted=0 ORDER BY pinned_at DESC').all(conversationId),
|
||||
pinnedInDm: (teamId, a, b) => db.prepare('SELECT * FROM messages WHERE team_id=? AND conversation_id IS NULL AND ((sender_id=? AND recipient_id=?) OR (sender_id=? AND recipient_id=?)) AND pinned_at IS NOT NULL AND deleted=0 ORDER BY pinned_at DESC').all(teamId, a, b, b, a),
|
||||
// Shared media/files in a conversation (group) or DM — newest first.
|
||||
attachmentsForConversation: (teamId, conversationId) => db.prepare(`SELECT a.id, a.name, a.mime, a.size, m.created_at FROM messages m JOIN attachments a ON a.id=m.attachment_id WHERE m.team_id=? AND m.conversation_id=? AND m.deleted=0 ORDER BY m.created_at DESC`).all(teamId, conversationId),
|
||||
attachmentsForDm: (teamId, a, b) => db.prepare(`SELECT at.id, at.name, at.mime, at.size, m.created_at FROM messages m JOIN attachments at ON at.id=m.attachment_id WHERE m.team_id=? AND m.conversation_id IS NULL AND ((m.sender_id=? AND m.recipient_id=?) OR (m.sender_id=? AND m.recipient_id=?)) AND m.deleted=0 ORDER BY m.created_at DESC`).all(teamId, a, b, b, a),
|
||||
|
||||
Reference in New Issue
Block a user