Merge pull request #309 from multica-ai/agent/lambda/83f444ab
fix(web): navigate to /issues when switching workspaces
This commit is contained in:
commit
08ba74b399
4 changed files with 17 additions and 2 deletions
|
|
@ -132,6 +132,7 @@ export function AppSidebar() {
|
|||
key={ws.id}
|
||||
onClick={() => {
|
||||
if (ws.id !== workspace?.id) {
|
||||
router.push("/issues");
|
||||
switchWorkspace(ws.id);
|
||||
}
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -204,12 +204,22 @@ export function IssueDetail({ issueId, onDelete, defaultSidebarOpen = true, layo
|
|||
const issue = useIssueStore((s) => s.issues.find((i) => i.id === id)) ?? null;
|
||||
const [issueLoading, setIssueLoading] = useState(!issue);
|
||||
|
||||
// If issue isn't in the store yet, fetch and upsert it
|
||||
// If issue isn't in the store yet, fetch and upsert it.
|
||||
// loadedIdRef tracks which issue was already loaded — if it disappears
|
||||
// from the store (workspace switch clears all issues), skip refetch.
|
||||
const loadedIdRef = useRef<string | null>(null);
|
||||
useEffect(() => {
|
||||
if (issue) {
|
||||
loadedIdRef.current = id;
|
||||
setIssueLoading(false);
|
||||
return;
|
||||
}
|
||||
// Issue was loaded for this id but vanished → store cleared (workspace switch)
|
||||
if (loadedIdRef.current === id) {
|
||||
loadedIdRef.current = null;
|
||||
return;
|
||||
}
|
||||
// Issue not in store → fetch it
|
||||
setIssueLoading(true);
|
||||
api
|
||||
.getIssue(id)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { toast } from "sonner";
|
||||
import { ArrowLeft } from "lucide-react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
|
@ -18,6 +19,7 @@ import { useWorkspaceStore } from "@/features/workspace";
|
|||
const SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
||||
|
||||
export function CreateWorkspaceModal({ onClose }: { onClose: () => void }) {
|
||||
const router = useRouter();
|
||||
const [name, setName] = useState("");
|
||||
const [slug, setSlug] = useState("");
|
||||
const [creating, setCreating] = useState(false);
|
||||
|
|
@ -50,6 +52,7 @@ export function CreateWorkspaceModal({ onClose }: { onClose: () => void }) {
|
|||
slug: slug.trim(),
|
||||
});
|
||||
onClose();
|
||||
router.push("/issues");
|
||||
await switchWorkspace(ws.id);
|
||||
} catch {
|
||||
toast.error("Failed to create workspace");
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ export class ApiClient {
|
|||
if (!res.ok) {
|
||||
if (res.status === 401) this.handleUnauthorized();
|
||||
const message = await this.parseErrorMessage(res, `API error: ${res.status} ${res.statusText}`);
|
||||
this.logger.error(`← ${res.status} ${path}`, { rid, duration: `${Date.now() - start}ms`, error: message });
|
||||
const logLevel = res.status === 404 ? "warn" : "error";
|
||||
this.logger[logLevel](`← ${res.status} ${path}`, { rid, duration: `${Date.now() - start}ms`, error: message });
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue