Skip to content

Commit

Permalink
problem: can't see sub-problems
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Oct 14, 2024
1 parent e8c491e commit 3c3a4c1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
22 changes: 20 additions & 2 deletions src/components/RecursiveProblemTile.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<script lang="ts">
import type { Problem } from '@/event_helpers/problems';
import { formatTimeAgo } from '@/helpers';
import { bloom, selected } from '@/stores/problems';
import { bloom, problems, selected } from '@/stores/problems';
import { onMount } from 'svelte';
import { derived } from 'svelte/store';
export let problem: Problem;
let children = derived(problems, ($problems) => {
return $problems.filter((p) => {
return p.parents().includes(problem.dtag);
});
});
</script>

{#if problem}
Expand All @@ -11,7 +19,10 @@
console.log(problem.event.rawEvent());
$selected = problem;
}}
class="problems-start flex w-full flex-col gap-2 rounded-lg border p-3 text-left text-sm transition-all hover:bg-accent"
class="problems-start flex w-full flex-col gap-2 rounded-lg border p-3 text-left text-sm transition-all hover:bg-accent hover:bg-opacity-100 {$selected ==
problem
? 'bg-accent bg-opacity-90'
: ''}"
>
<div class="flex w-full flex-col gap-1">
<div class="problems-center flex">
Expand Down Expand Up @@ -40,4 +51,11 @@
</div>
{/if} -->
</button>
{#if $selected == problem}
{#each $children as child}
<div class="pl-2">
<svelte:self problem={child}></svelte:self>
</div>
{/each}
{/if}
{/if}
16 changes: 9 additions & 7 deletions src/layouts/MailList.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<script lang="ts">
import { Input } from '@/components/ui/input';
import ScrollArea from '@/components/ui/scroll-area/scroll-area.svelte';
import type { Problem } from '@/event_helpers/problems';
import { problems } from '@/stores/problems';
import { Search } from 'lucide-svelte';
import Filters from '../components/Filters.svelte';
import ProblemTile from '../components/RecursiveProblemTile.svelte';
import { problems } from '@/stores/problems';
import { onMount } from 'svelte';
// export let problems: Problem[];
let selected: Problem;
let bloom: false; //todo: use a bloom filter from HH for problems that current user has already viewed, this should run on problem event ID not d-tag so that they see updates
import { derived } from 'svelte/store';
let filtered = derived(problems, ($problems) => {
return $problems.filter((p) => {
return p.parents().length == 0;
});
});
</script>

<div class="flex flex-col gap-2">
Expand All @@ -22,7 +24,7 @@
</form>
<ScrollArea class="h-[calc(100vh-154px)] px-4">
<div class="flex flex-col items-center gap-2">
{#each $problems as problem}
{#each $filtered as problem}
<ProblemTile {problem}></ProblemTile>
{/each}
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/lib/event_helpers/problems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ export class Problem {
this.event = event;
}

parents(): string[] {
let p: string[] = [];
for (let t of this.event.getMatchingTags('a')) {
if (t.length == 3 && t[2] == 'parent') {
let s = t[1].split(':');
if (s.length == 3 && s[0] == '31971') {
p.push(s[2]);
}
}
}
return p;
}

static fromEvent(event: NDKEvent): Problem {
return new Problem(
event,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores/problems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const problems = derived(_problems, ($problems) =>

export let selected = writable<Problem | undefined>(undefined);

export let bloom = writable(false); //todo
export let bloom = writable(false); //todo: use a bloom filter from HH for problems that current user has already viewed, this should run on problem event ID not d-tag so that they see updates
2 changes: 1 addition & 1 deletion src/views/Problems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<Resizable.PaneGroup direction="horizontal" class="h-full items-stretch overflow-hidden">
<Resizable.Pane defaultSize={30} minSize={30} maxSize={50}>
<MailList></MailList>
<MailList />
</Resizable.Pane>

<Resizable.Handle withHandle />
Expand Down

0 comments on commit 3c3a4c1

Please sign in to comment.