diff --git a/src/components/novoproblems/ProblemView.svelte b/src/components/novoproblems/ProblemView.svelte index 7b549e0..edae674 100644 --- a/src/components/novoproblems/ProblemView.svelte +++ b/src/components/novoproblems/ProblemView.svelte @@ -92,7 +92,7 @@ return $page.url.searchParams.get("extra") ?? ""; }) - $:{console.log($page.url.searchParams)} + //$:{console.log($page.url.searchParams)} let selectedTabIndex = derived(selectedTab, ($selectedTab) => { switch ($selectedTab) { diff --git a/src/components/views/RocketHome.svelte b/src/components/views/RocketHome.svelte index bf43d15..da6e668 100644 --- a/src/components/views/RocketHome.svelte +++ b/src/components/views/RocketHome.svelte @@ -43,6 +43,8 @@ } } + + function selectedTabIndex(name: string) { switch (name) { case "info": diff --git a/src/lib/stores/nostrocket_state/master_state.ts b/src/lib/stores/nostrocket_state/master_state.ts index 9bd1ca1..89c3b06 100644 --- a/src/lib/stores/nostrocket_state/master_state.ts +++ b/src/lib/stores/nostrocket_state/master_state.ts @@ -146,14 +146,14 @@ let softState = derived( }); fullStateTip.set($fullStateTip); } else { - if (e.id == "4934e1aa5c0d94158e3e3bd32ad7aa656065b134916cc257e56590da561f2bb3") {console.log(131, err)} + //if (e.id == "4934e1aa5c0d94158e3e3bd32ad7aa656065b134916cc257e56590da561f2bb3") {console.log(131, err)} // if (e.id == rootProblem) { // console.log(err, e); // } //console.log(err, e); } } catch (err) { - if (e.id == "4934e1aa5c0d94158e3e3bd32ad7aa656065b134916cc257e56590da561f2bb3") {console.log(138, err)} + //if (e.id == "4934e1aa5c0d94158e3e3bd32ad7aa656065b134916cc257e56590da561f2bb3") {console.log(138, err)} //console.log(131, err, e); } diff --git a/src/routes/nr/[rocket]/[tab]/[id]/+page.svelte b/src/routes/nr/[rocket]/[tab]/[id]/+page.svelte index 172e667..7feaae1 100644 --- a/src/routes/nr/[rocket]/[tab]/[id]/+page.svelte +++ b/src/routes/nr/[rocket]/[tab]/[id]/+page.svelte @@ -3,6 +3,8 @@ import { consensusTipState } from "$lib/stores/nostrocket_state/master_state"; import { derived } from "svelte/store"; import RocketHome from "../../../../../components/views/RocketHome.svelte"; + import { goto } from "$app/navigation"; + import { base } from "$app/paths"; let rocketName = derived(page, ($p) => { return $p.params.rocket; @@ -11,19 +13,68 @@ let rocket = derived( [rocketName, consensusTipState], ([$rocketName, $cts]) => { - for (let [_, r] of $cts.RocketMap) { - if (r.Name.toLowerCase() == $rocketName.toLowerCase()) { - return $cts.RocketMap.get(r.UID); + if ($rocketName) { + for (let [_, r] of $cts.RocketMap) { + if (r.Name.toLowerCase() == $rocketName.toLowerCase()) { + return $cts.RocketMap.get(r.UID); + } } } return undefined; } ); + + let selectedtab = derived(page, ($p) => { + return $p.params.tab; + }); + + let id = derived(page, ($p) => { + return $p.params.id; + }); + + let problem = derived( + [selectedtab, id, consensusTipState], + ([$selectedtab, $id, $cts]) => { + if ($selectedtab == "problems" && $id && $cts) { + return $cts.Problems.get($id); + } + } + ); + + let incorrectRocket = derived([problem, rocket], ([$problem, $rocket]) => { + if ($rocket && $problem) { + return $problem.Rocket !== $rocket.UID; + } + return false; + }); + + incorrectRocket.subscribe((v) => { + if (v && $problem && $selectedtab == "problems") { + let r = $consensusTipState.RocketMap.get($problem.Rocket); + if (r) { + goto(`${base}/nr/${r.Name}/problems/${$problem.UID}`); + } + } + }); + + // $: { + // if (rocket && id) { + // let p = problem(rocket, id); + // if (p) { + // if (p.Rocket !== rocket.UID) { + // let problemRocket = $consensusTipState.RocketMap.get(p.Rocket); + // if (problemRocket) { + // goto(`${base}/nr/${problemRocket.Name}/${id}`); + // } + // } + // } + // } + // }