Hide /share if disabled (#4215)

This commit is contained in:
Aiden Cline 2025-11-11 12:47:39 -08:00 committed by GitHub
commit e1fc4a756b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 28 deletions

View file

@ -217,12 +217,6 @@ export function Autocomplete(props: {
description: "compact the session", description: "compact the session",
onSelect: () => command.trigger("session.compact"), onSelect: () => command.trigger("session.compact"),
}, },
{
display: "/share",
disabled: !!s.share?.url,
description: "share a session",
onSelect: () => command.trigger("session.share"),
},
{ {
display: "/unshare", display: "/unshare",
disabled: !s.share, disabled: !s.share,
@ -250,7 +244,16 @@ export function Autocomplete(props: {
onSelect: () => command.trigger("session.timeline"), onSelect: () => command.trigger("session.timeline"),
}, },
) )
if (sync.data.config.share !== "disabled") {
results.push({
display: "/share",
disabled: !!s.share?.url,
description: "share a session",
onSelect: () => command.trigger("session.share"),
})
}
} }
results.push( results.push(
{ {
display: "/new", display: "/new",

View file

@ -217,29 +217,33 @@ export function Session() {
dialog.clear() dialog.clear()
}, },
}, },
{ ...(sync.data.config.share !== "disabled"
title: "Share session", ? [
value: "session.share", {
keybind: "session_share", title: "Share session",
disabled: !!session()?.share?.url, value: "session.share",
category: "Session", keybind: "session_share" as const,
onSelect: async (dialog) => { disabled: !!session()?.share?.url,
await sdk.client.session category: "Session",
.share({ onSelect: async (dialog: any) => {
path: { await sdk.client.session
id: route.sessionID, .share({
path: {
id: route.sessionID,
},
})
.then((res) =>
Clipboard.copy(res.data!.share!.url).catch(() =>
toast.show({ message: "Failed to copy URL to clipboard", variant: "error" }),
),
)
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
.catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
dialog.clear()
}, },
}) },
.then((res) => ]
Clipboard.copy(res.data!.share!.url).catch(() => : []),
toast.show({ message: "Failed to copy URL to clipboard", variant: "error" }),
),
)
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
.catch(() => toast.show({ message: "Failed to share session", variant: "error" }))
dialog.clear()
},
},
{ {
title: "Unshare session", title: "Unshare session",
value: "session.unshare", value: "session.unshare",