Skip to content

Commit

Permalink
problem: sub-problems are not nested
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Oct 13, 2023
1 parent dda3576 commit 1b85542
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 15 deletions.
30 changes: 29 additions & 1 deletion src/components/objects/Problem.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
<script></script>
<script lang="ts">
import { consensusTipState } from "$lib/stores/state";
import type { Problem } from "$lib/types";
import { Accordion, AccordionItem } from "carbon-components-svelte";
import AddProblem from "../modals/AddProblem.svelte";
export let problem:Problem;
export let depth:number;
</script>


<Accordion>
<AccordionItem style="margin-left:{depth}%">
<svelte:fragment slot="title">
<h5>{problem.Title}</h5>
{#if problem.Summary}<div>{problem.Summary}</div>{/if}
</svelte:fragment>
{#if problem.FullText}<p>{problem.FullText}</p>{/if}
<AddProblem parent={problem.UID}/>
</AccordionItem>
</Accordion>
{#if problem.Children}
{#each problem.Children.entries() as [childProblem]}
{#if $consensusTipState.Problems.get(childProblem)}
<svelte:self problem={$consensusTipState.Problems.get(childProblem)} depth={depth+1}/>
{/if}
{/each}
{/if}
15 changes: 13 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ p.Head.getMatchingTags("h").forEach(h=>{
p.Head.getMatchingTags("e").forEach(e=>{
if (e[e.length-1] == "parent") {
if (e[1].length == 64) {
p.Parent = e[1]
if (!p.Parents) {p.Parents = new Set()}
p.Parents.add(e[1])
}
}
if (e[e.length-1] == "commit") {
Expand All @@ -109,6 +110,15 @@ p.Head.getMatchingTags("e").forEach(e=>{
}

})
if (p.Parents) {
p.Parents.forEach(prnt=>{
let parentProblem = state.Problems.get(prnt)
if (parentProblem) {
if (!parentProblem.Children) {parentProblem.Children = new Set()}
parentProblem.Children.add(p.UID)
}
})
}
if (!p.Rocket) {
p.Rocket = nostrocketIgnitionEvent
}
Expand Down Expand Up @@ -431,7 +441,7 @@ export class Problem implements Problem {

export interface Problem {
UID: ProblemID;
Parent: ProblemID;
Parents: Set<string>;
Title: string;
Summary: string;
FullText: string;
Expand All @@ -447,6 +457,7 @@ export interface Problem {
LastHeadHash: string;
LastCommit: string;
CommitHistory: string[];
Children: Set<string>;
}

export interface Identity {
Expand Down
16 changes: 4 additions & 12 deletions src/routes/problems/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@
import { Problems, Rockets } from "$lib/stores/state";
import { Row, Tile } from "carbon-components-svelte";
import AddProblem from "../../components/modals/AddProblem.svelte";
import Problem from "../../components/objects/Problem.svelte";
fetchProblemEvents(undefined)
</script>
<h2>Problem Tracker</h2>
<AddProblem />



{#each $Problems as problem}
<Row>
<Tile>
<h3>{problem.Title}</h3>
{#if problem.Summary}<h6>{problem.Summary}</h6>{/if}
{#if problem.FullText}<p>{problem.FullText}</p>{/if}
<p>ID: {problem.UID}</p>
<p>Last Update: {problem.LastHeadHeight}</p>
<p>Status: {problem.Status}</p>
<p>Rocket: {$Rockets.get(problem.Rocket)?.Name.toUpperCase()}</p>
<AddProblem parent={problem.UID} />
</Tile>
</Row>
{#if !problem.Parents}<Problem {problem} depth={0}/>{/if}
{/each}

0 comments on commit 1b85542

Please sign in to comment.