θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ThreadItem({
hasNext,
ctrlPressed = false,
}) {
const { slug } = useParams();
const { slug, threadSlug = null } = useParams();
const optionsContainer = useRef(null);
const [showOptions, setShowOptions] = useState(false);
const linkTo = !thread.slug
Expand Down Expand Up @@ -142,6 +142,7 @@ export default function ThreadItem({
thread={thread}
onRemove={onRemove}
close={() => setShowOptions(false)}
currentThreadSlug={threadSlug}
/>
)}
</div>
Expand All @@ -151,7 +152,14 @@ export default function ThreadItem({
);
}

function OptionsMenu({ containerRef, workspace, thread, onRemove, close }) {
function OptionsMenu({
containerRef,
workspace,
thread,
onRemove,
close,
currentThreadSlug,
}) {
const menuRef = useRef(null);

// Ref menu options
Expand Down Expand Up @@ -227,6 +235,10 @@ function OptionsMenu({ containerRef, workspace, thread, onRemove, close }) {
if (success) {
showToast("Thread deleted successfully!", "success", { clear: true });
onRemove(thread.id);
// Redirect if deleting the active thread
if (currentThreadSlug === thread.slug) {
window.location.href = paths.workspace.chat(workspace.slug);
}
return;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export default function ThreadContainer({ workspace }) {
const slugs = threads.filter((t) => t.deleted === true).map((t) => t.slug);
await Workspace.threads.deleteBulk(workspace.slug, slugs);
setThreads((prev) => prev.filter((t) => !t.deleted));

// Only redirect if current thread is being deleted
if (slugs.includes(threadSlug)) {
window.location.href = paths.workspace.chat(workspace.slug);
}
};

function removeThread(threadId) {
Expand Down