Skip to content

Commit

Permalink
problem: can't see total number of open problems
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Nov 20, 2023
1 parent f00fa6b commit 1644258
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 30 deletions.
28 changes: 28 additions & 0 deletions src/components/rockets/RocketItem.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang="ts">
import { base } from "$app/paths";
import type { Rocket } from "$lib/stores/nostrocket_state/types";
import { AccordionItem, Tag } from "carbon-components-svelte";
export let rocket:Rocket|undefined = undefined
</script>
{#if rocket}
<AccordionItem>
<svelte:fragment slot="title">
<h3 class="problem-title">{#if !rocket.Consensus}<Tag type="red">UNCONFIRMED</Tag>{/if}
{rocket.Name}
</h3>

<div class="problem-summary">
<Tag>{rocket.Problems.size} Problems</Tag>
</div>
</svelte:fragment>
<p>
<a href="{base}/problems/rocket/{rocket.Name}">View Open Problems</a><br />
{#if rocket.ProblemID}<a href="{base}/problems/{rocket.ProblemID}">View the root problem for this Rocket</a>{:else}No Associated Problem{/if}
<br />
</p>
<p>Created By: {rocket.CreatedBy}</p>
<a href="{base}/rockets/{rocket.UID}">More...</a>
</AccordionItem>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ function eventToProblemData(
if (existing.Events.includes(ev.rawEvent())) {
return "event is already included";
}

let currentRocket = state.RocketMap.get(rocket)
if (currentRocket) {
currentRocket.Problems.add(existing.UID)
state.RocketMap.set(currentRocket.UID, currentRocket)
}
existing.Title = tldr!;
existing.Summary = paragraph!;
existing.Status = status;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stores/nostrocket_state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export class Rocket {
Event: NostrEvent;
Participants: Map<Account, Account[]>;
Consensus:boolean;
Problems:Set<string>
constructor() {
this.Maintainers = new Map<Account, Account[]>();
this.Participants = new Map<Account, Account[]>();
this.Problems = new Set()
}

isParticipant(pubkey: string): boolean {
Expand Down
37 changes: 19 additions & 18 deletions src/routes/rockets/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<script>
import { base } from "$app/paths";
import { Column, Row, Tile } from "carbon-components-svelte";
import { Rocket } from "carbon-pictograms-svelte";
import CreateRocket from "../../components/modals/CreateRocket.svelte";
import { consensusTipState } from "$lib/stores/nostrocket_state/master_state";
import { Accordion, AccordionItem, Column, Row, Tag } from "carbon-components-svelte";
import CreateRocket from "../../components/modals/CreateRocket.svelte";
import RocketItem from "../../components/rockets/RocketItem.svelte";
import { derived } from "svelte/store";
let sortedRockets = derived(consensusTipState, ($current) => {
let rockets = [...$current.RocketMap];
rockets.sort(([s0, a], [s1, b])=>{
return b.Problems.size - a.Problems.size
})
return rockets
}
);
</script>

<Row>
Expand All @@ -12,20 +24,9 @@
</Column>
</Row>
<Row>
{#each [...$consensusTipState.RocketMap] as [key, rocket]}
<Column max={8}>
<Tile style="margin:1px;" light={!rocket.Consensus}>
<!-- <Avatar ndk={$ndk} pubkey={rocket.CreatedBy} /> -->
<h3><Rocket />{#if !rocket.Consensus}[UNCONFIRMED] {/if}{rocket.Name}</h3>
<p>
<a href="{base}/problems/rocket/{rocket.Name}">View Open Problems</a><br />
{#if rocket.ProblemID}<a href="{base}/problems/{rocket.ProblemID}">View the root problem for this Rocket</a>{:else}No Associated Problem{/if}
<br />
</p>
<p>Event ID: {key}</p>
<p>Created By: {rocket.CreatedBy}</p>
<a href="{base}/rockets/{key}">More...</a>
</Tile>
</Column>
<Accordion>
{#each [...$sortedRockets] as [key, rocket]}
<RocketItem {rocket} />
{/each}
</Accordion>
</Row>
14 changes: 3 additions & 11 deletions src/routes/rockets/[id]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script>
import { base } from "$app/paths";
import { page } from "$app/stores";
import { consensusTipState } from "$lib/stores/nostrocket_state/master_state";
import {
AspectRatio,
CodeSnippet,
Column,
Loading,
Row,
Tile,
Tile
} from "carbon-components-svelte";
</script>

Expand All @@ -22,15 +22,7 @@
<Column sm={16} md={16} lg={16} max={8}
><AspectRatio ratio="2x1" style="margin:1%;"
><Tile style="height:100%; width:100%;">
<CodeSnippet
type="multi"
code={JSON.stringify(
$consensusTipState.RocketMap.get($page.params.id)?.Event,
null,
"\t"
)}
expanded
/>
<a style="color:deeppink;" href="{base}/eventviewer/{$page.params.id}">View Event</a>
</Tile></AspectRatio
></Column
>
Expand Down

0 comments on commit 1644258

Please sign in to comment.