-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
problem: not clear what parent a new problem is being logged under
- Loading branch information
1 parent
b5df0c5
commit d11881f
Showing
6 changed files
with
66 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores'; | ||
import { derived, type Readable } from 'svelte/store'; | ||
import LogNewProblem from '../../../../views/LogNewProblem.svelte'; | ||
import type { ExtendedBaseType, NDKEventStore } from '@nostr-dev-kit/ndk-svelte'; | ||
import { NDKEvent } from '@nostr-dev-kit/ndk'; | ||
import { ndk } from '@/ndk'; | ||
import { Problem } from '@/event_helpers/problems'; | ||
let latestEvent: Readable<ExtendedBaseType<NDKEvent> | undefined>; | ||
let atag = $page.params.parentID.split(':'); | ||
let events: NDKEventStore<ExtendedBaseType<NDKEvent>> | undefined; | ||
if (atag.length == 3) { | ||
events = $ndk.storeSubscribe( | ||
[{ '#d': [atag[2]], authors: [atag[1]], kinds: [31971 as number] }], | ||
{ subId: atag[2] } | ||
); | ||
} | ||
$: { | ||
if (events && !latestEvent) { | ||
latestEvent = derived(events, ($events) => { | ||
let sorted = $events.filter((e) => { | ||
return e.kind == 31971; | ||
}); | ||
sorted = sorted.toSorted((a, b) => { | ||
return a.created_at - b.created_at; | ||
}); | ||
return sorted[0]; | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
{#if latestEvent && $latestEvent} | ||
<LogNewProblem parent={Problem.fromEvent($latestEvent)} /> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters