v0.7.8 bugs fixes for pinned messages
This commit is contained in:
@@ -216,6 +216,7 @@ export default function Message({ message: msg, prevMessage, currentUser, onRepl
|
||||
onTouchStart={handleTouchStart}
|
||||
onTouchEnd={handleTouchEnd}
|
||||
onTouchMove={handleTouchEnd}
|
||||
onContextMenu={isDirect ? (e => { e.preventDefault(); setShowOptionsMenu(true); }) : undefined}
|
||||
>
|
||||
{/* Actions toolbar — floats above the bubble, aligned to correct side */}
|
||||
{!isDeleted && (showActions || showEmojiPicker) && (
|
||||
@@ -239,6 +240,16 @@ export default function Message({ message: msg, prevMessage, currentUser, onRepl
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>
|
||||
</button>
|
||||
)}
|
||||
{isDirect && (
|
||||
<button
|
||||
className={`btn-icon action-btn${isPinned ? ' action-pinned' : ''}`}
|
||||
onClick={() => { isPinned ? onUnpin(msg.id) : (pinCount < 5 && onPin(msg.id)); setShowActions(false); }}
|
||||
disabled={!isPinned && pinCount >= 5}
|
||||
title={isPinned ? 'Unpin message' : pinCount >= 5 ? 'Pin limit reached (5/5)' : `Pin message (${pinCount + 1}/5)`}
|
||||
>
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor"><path d="M16 2v4l-3 3v7l-4-4-4 4V9L2 6V2h14zm2 0h2v2h-2V2z"/></svg>
|
||||
</button>
|
||||
)}
|
||||
{/* Emoji picker anchored to the toolbar */}
|
||||
{showEmojiPicker && (
|
||||
<div
|
||||
@@ -275,38 +286,34 @@ export default function Message({ message: msg, prevMessage, currentUser, onRepl
|
||||
|
||||
<span className="msg-time">{formatTime(msg.created_at)}</span>
|
||||
|
||||
{/* Triple-dot pin button — sits outside the hover toolbar so mouse-leave doesn't race */}
|
||||
{isDirect && (
|
||||
<div className="msg-pin-wrap" ref={optionsMenuRef}>
|
||||
<button
|
||||
className={`btn-icon msg-pin-btn ${showOptionsMenu ? 'active' : ''}`}
|
||||
onClick={e => { e.stopPropagation(); setShowOptionsMenu(p => !p); }}
|
||||
title="Message options"
|
||||
{/* Mobile long-press / right-click bottom sheet for pin */}
|
||||
{isDirect && showOptionsMenu && (
|
||||
<div className="msg-sheet-overlay" onClick={() => setShowOptionsMenu(false)}>
|
||||
<div
|
||||
className="msg-sheet"
|
||||
ref={optionsMenuRef}
|
||||
onClick={e => e.stopPropagation()}
|
||||
>
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2"><circle cx="12" cy="5" r="1.2" fill="currentColor"/><circle cx="12" cy="12" r="1.2" fill="currentColor"/><circle cx="12" cy="19" r="1.2" fill="currentColor"/></svg>
|
||||
</button>
|
||||
{showOptionsMenu && (
|
||||
<div
|
||||
className={`msg-options-menu ${isOwn ? 'options-left' : 'options-right'}`}
|
||||
onMouseDown={e => e.stopPropagation()}
|
||||
>
|
||||
{isPinned ? (
|
||||
<button onClick={() => { onUnpin(msg.id); setShowOptionsMenu(false); }}>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M16 2v4l-3 3v7l-4-4-4 4V9L2 6V2h14zm2 0h2v2h-2V2z"/></svg>
|
||||
Unpin message
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => { if (pinCount < 5) { onPin(msg.id); setShowOptionsMenu(false); } }}
|
||||
disabled={pinCount >= 5}
|
||||
title={pinCount >= 5 ? 'Maximum 5 pinned messages reached' : ''}
|
||||
>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M16 2v4l-3 3v7l-4-4-4 4V9L2 6V2h14zm2 0h2v2h-2V2z"/></svg>
|
||||
{pinCount >= 5 ? 'Pin (5/5)' : `Pin (${pinCount + 1}/5)`}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="msg-sheet-handle" />
|
||||
{isPinned ? (
|
||||
<button className="msg-sheet-btn" onClick={() => { onUnpin(msg.id); setShowOptionsMenu(false); }}>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M16 2v4l-3 3v7l-4-4-4 4V9L2 6V2h14zm2 0h2v2h-2V2z"/></svg>
|
||||
Unpin message
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="msg-sheet-btn"
|
||||
onClick={() => { if (pinCount < 5) { onPin(msg.id); setShowOptionsMenu(false); } }}
|
||||
disabled={pinCount >= 5}
|
||||
>
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M16 2v4l-3 3v7l-4-4-4 4V9L2 6V2h14zm2 0h2v2h-2V2z"/></svg>
|
||||
{pinCount >= 5 ? 'Pin limit reached (5/5)' : `Pin message (${pinCount + 1}/5)`}
|
||||
</button>
|
||||
)}
|
||||
<button className="msg-sheet-btn msg-sheet-cancel" onClick={() => setShowOptionsMenu(false)}>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user