Pinned conversations no longer move on click or new messages
Build & Auto-Repair / build (push) Has been cancelled
Build & Auto-Repair / build (push) Has been cancelled
This commit is contained in:
@@ -510,10 +510,13 @@ const formatPreviewContent = (content: string) => {
|
|||||||
? { ...conv, lastMessage: getDisplayContent(content), lastMessageTime: "Just now" }
|
? { ...conv, lastMessage: getDisplayContent(content), lastMessageTime: "Just now" }
|
||||||
: conv
|
: conv
|
||||||
)
|
)
|
||||||
const idx = updated.findIndex((c) => c.id === activeChat)
|
const conv = updated.find((c) => c.id === activeChat)
|
||||||
if (idx > 0) {
|
if (conv && !conv.pinned) {
|
||||||
const [item] = updated.splice(idx, 1)
|
const idx = updated.findIndex((c) => c.id === activeChat)
|
||||||
updated.unshift(item)
|
if (idx > 0) {
|
||||||
|
const [item] = updated.splice(idx, 1)
|
||||||
|
updated.unshift(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return updated
|
return updated
|
||||||
})
|
})
|
||||||
@@ -842,7 +845,7 @@ const formatPreviewContent = (content: string) => {
|
|||||||
setUnreadMap((prev) => { const m = new Map(prev); m.set(conv.id, 0); return m })
|
setUnreadMap((prev) => { const m = new Map(prev); m.set(conv.id, 0); return m })
|
||||||
setConversations((prev) => {
|
setConversations((prev) => {
|
||||||
const idx = prev.findIndex((c) => c.id === conv.id)
|
const idx = prev.findIndex((c) => c.id === conv.id)
|
||||||
if (idx > 0) {
|
if (idx > 0 && !conv.pinned) {
|
||||||
const u = [...prev]
|
const u = [...prev]
|
||||||
const [item] = u.splice(idx, 1)
|
const [item] = u.splice(idx, 1)
|
||||||
u.unshift(item)
|
u.unshift(item)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export async function GET() {
|
|||||||
WHERE c.id IN (
|
WHERE c.id IN (
|
||||||
SELECT conversation_id FROM conversation_participants WHERE user_id = $1
|
SELECT conversation_id FROM conversation_participants WHERE user_id = $1
|
||||||
)
|
)
|
||||||
ORDER BY cp_me.pinned_at DESC NULLS LAST, c.updated_at DESC
|
ORDER BY cp_me.pinned_at DESC NULLS LAST, CASE WHEN cp_me.pinned_at IS NULL THEN c.updated_at END DESC
|
||||||
LIMIT 50`,
|
LIMIT 50`,
|
||||||
[user.id],
|
[user.id],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user