fix: broadcast on task create (realtime), context menu position recalc, CDN_HOST in deploy.sh

This commit is contained in:
2026-03-24 19:57:12 +03:00
parent 0aaf26cbd1
commit 018b119772
2 changed files with 14 additions and 2 deletions

View File

@@ -119,6 +119,7 @@ const housekeeping: FastifyPluginAsync = async (fastify) => {
WHERE t.id = $1`,
[inserted[0].id],
)
broadcast(slug, { type: 'housekeeping_task_created', task: rows[0] })
return reply.code(201).send(rows[0])
},
)

View File

@@ -54,6 +54,17 @@ export function RoomContextMenu({ room, x, y, onClose, onStatusChange, onHkStatu
const [photoUploading, setPhotoUploading] = useState(false)
const photoInputRef = useRef<HTMLInputElement>(null)
// Recalculate position whenever content changes (e.g. photos added)
useEffect(() => {
if (ref.current) {
const rect = ref.current.getBoundingClientRect()
const overflowX = rect.right - window.innerWidth + 8
const overflowY = rect.bottom - window.innerHeight + 8
if (overflowX > 0) ref.current.style.left = `${rect.left - overflowX}px`
if (overflowY > 0) ref.current.style.top = `${Math.max(8, rect.top - overflowY)}px`
}
}, [techPhotos.length, subForm])
useEffect(() => {
const handler = (e: MouseEvent) => {
if (ref.current && !ref.current.contains(e.target as Node)) onClose()
@@ -131,8 +142,8 @@ export function RoomContextMenu({ room, x, y, onClose, onStatusChange, onHkStatu
return createPortal(
<div
ref={ref}
className="fixed z-[9999] w-60 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-600 rounded-xl shadow-xl overflow-y-auto select-none"
style={{ left: menuX, top: menuY, maxHeight: `${Math.min(window.innerHeight - menuY - 16, window.innerHeight * 0.9)}px` }}
className="fixed z-[9999] w-60 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-600 rounded-xl shadow-xl overflow-hidden select-none"
style={{ left: menuX, top: menuY }}
onContextMenu={e => e.preventDefault()}
>
{/* Header */}