hide broadcast from context menu

This commit is contained in:
Jeff-Emmett 2025-03-05 18:06:22 -05:00
parent 47db716af3
commit a770d516df
2 changed files with 61 additions and 44 deletions

View File

@ -203,7 +203,7 @@ export function CustomContextMenu(props: TLUiContextMenuProps) {
/>
<TldrawUiMenuItem
id="Prompt"
label="Create Prompt"
label="Create LLM Chat Prompt"
icon="prompt"
kbd="alt+p"
disabled={hasSelection}
@ -245,37 +245,36 @@ export function CustomContextMenu(props: TLUiContextMenuProps) {
))}
</TldrawUiMenuSubmenu>
</TldrawUiMenuGroup>
<TldrawUiMenuGroup id="broadcast-controls">
{/* TODO: FIX & IMPLEMENT BROADCASTING*/}
{/* <TldrawUiMenuGroup id="broadcast-controls">
<TldrawUiMenuItem
id="broadcast-view"
label="Start Broadcasting View"
id="start-broadcast"
label="Start Broadcasting"
icon="broadcast"
kbd="alt+b"
onSelect={() => {
const otherUsers = Array.from(editor.store.allRecords()).filter(
(record) =>
record.typeName === "instance_presence" &&
record.id !== editor.user.getId(),
)
otherUsers.forEach((user) => editor.startFollowingUser(user.id))
editor.markHistoryStoppingPoint('start-broadcast')
editor.updateInstanceState({ isBroadcasting: true })
const url = new URL(window.location.href)
url.searchParams.set("followId", editor.user.getId())
window.history.replaceState(null, "", url.toString())
}}
/>
<TldrawUiMenuItem
id="stop-broadcast"
label="Stop Broadcasting View"
label="Stop Broadcasting"
icon="broadcast-off"
kbd="alt+shift+b"
onSelect={() => {
const otherUsers = Array.from(editor.store.allRecords()).filter(
(record) =>
record.typeName === "instance_presence" &&
record.id !== editor.user.getId(),
)
otherUsers.forEach((_user) => editor.stopFollowingUser())
editor.markHistoryStoppingPoint('stop-broadcast')
editor.updateInstanceState({ isBroadcasting: false })
editor.stopFollowingUser()
const url = new URL(window.location.href)
url.searchParams.delete("followId")
window.history.replaceState(null, "", url.toString())
}}
/>
</TldrawUiMenuGroup>
</TldrawUiMenuGroup> */}
<TldrawUiMenuGroup id="search-controls">
<TldrawUiMenuItem

View File

@ -51,25 +51,38 @@ export const overrides: TLUiOverrides = {
},
//TODO: Fix double click to zoom on selector tool later...
onDoubleClick: (info: any) => {
const shape = editor.getShapeAtPoint(info.point)
if (shape?.type === "Embed") {
// Let the Embed shape handle its own double-click behavior
const util = editor.getShapeUtil(shape) as EmbedShape
util?.onDoubleClick?.(shape as IEmbedShape)
return
}
// onDoubleClick: (info: any) => {
// const shape = editor.getShapeAtPoint(info.point)
// if (shape?.type === "Embed") {
// // Let the Embed shape handle its own double-click behavior
// const util = editor.getShapeUtil(shape) as EmbedShape
// util?.onDoubleClick?.(shape as IEmbedShape)
// return true
// }
// Handle all pointer types (mouse, touch, pen)
const point = info.point || (info.touches && info.touches[0]) || info
// // Handle all pointer types (mouse, touch, pen)
// const point = info.point || (info.touches && info.touches[0]) || info
// Zoom in at the clicked/touched point
editor.zoomIn(point, { animation: { duration: 200 } })
// // Zoom in at the clicked/touched point
// editor.zoomIn(point, { animation: { duration: 200 } })
// Stop event propagation and prevent default handling
info.stopPropagation?.()
return false
},
// // Prevent default text creation
// info.preventDefault?.()
// info.stopPropagation?.()
// return true
// },
// onDoubleClickCanvas: (info: any) => {
// // Handle all pointer types (mouse, touch, pen)
// const point = info.point || (info.touches && info.touches[0]) || info
// // Zoom in at the clicked/touched point
// editor.zoomIn(point, { animation: { duration: 200 } })
// // Prevent default text creation
// info.preventDefault?.()
// info.stopPropagation?.()
// return true
// },
},
VideoChat: {
id: "VideoChat",
@ -276,18 +289,17 @@ export const overrides: TLUiOverrides = {
},
},
//TODO: MAKE THIS WORK, ADD USER PERMISSIONING TO JOIN BROADCAST?
broadcastView: {
id: "broadcast-view",
label: "Broadcast View",
startBroadcast: {
id: "start-broadcast",
label: "Start Broadcasting",
kbd: "alt+b",
readonlyOk: true,
onSelect: () => {
const collaborators = editor.getCollaborators()
collaborators
.filter((user) => user.id !== editor.user.getId())
.forEach((user) => {
editor.startFollowingUser(user.id)
})
editor.markHistoryStoppingPoint('start-broadcast')
editor.updateInstanceState({ isBroadcasting: true })
const url = new URL(window.location.href)
url.searchParams.set("followId", editor.user.getId())
window.history.replaceState(null, "", url.toString())
},
},
stopBroadcast: {
@ -296,7 +308,13 @@ export const overrides: TLUiOverrides = {
kbd: "alt+shift+b",
readonlyOk: true,
onSelect: () => {
editor.updateInstanceState({ isBroadcasting: false })
editor.stopFollowingUser()
// Remove followId from URL
const url = new URL(window.location.href)
url.searchParams.delete("followId")
window.history.replaceState(null, "", url.toString())
},
},
searchShapes: {