Skip to content

Commit

Permalink
sometimes we go to the wrong rocket url
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Feb 13, 2024
1 parent 751f5c2 commit 5a1020b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/novoproblems/ProblemView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/views/RocketHome.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
}
}
function selectedTabIndex(name: string) {
switch (name) {
case "info":
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stores/nostrocket_state/master_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
61 changes: 56 additions & 5 deletions src/routes/nr/[rocket]/[tab]/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}`);
// }
// }
// }
// }
// }
</script>

<RocketHome
rocketName={$rocketName}
rocket={$rocket}
selectedTab={$page.params.tab}
id={$page.params.id}
selectedTab={$selectedtab}
id={$id}
/>

0 comments on commit 5a1020b

Please sign in to comment.