mirror of
https://github.com/aljazceru/hypergolic.git
synced 2026-01-21 06:14:27 +01:00
problem: can't see votes
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
{#each $merits as [id, merit], _ (id)}
|
||||
<Table.Row
|
||||
on:click={() => {
|
||||
console.log(merit.Request.rawEvent());
|
||||
console.log(merit.Event.rawEvent());
|
||||
goto(`${base}/rockets/merits/${merit.ID}`);
|
||||
}}
|
||||
class="cursor-pointer bg-accent"
|
||||
|
||||
@@ -1,38 +1,49 @@
|
||||
<script lang="ts">
|
||||
import * as Card from '$lib/components/ui/card/index.js';
|
||||
import type { MeritRequest } from '@/event_helpers/merits';
|
||||
import { Vote, type MeritRequest } from '@/event_helpers/merits';
|
||||
import { ndk } from '@/ndk';
|
||||
import type { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||
import type { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
||||
import { Avatar, Name } from '@nostr-dev-kit/ndk-svelte-components';
|
||||
import { ExternalLink } from 'lucide-svelte';
|
||||
import { onDestroy } from 'svelte';
|
||||
import VoteOnMeritRequest from './VoteOnMeritRequest.svelte';
|
||||
|
||||
import ChevronLeft from 'lucide-svelte/icons/chevron-left';
|
||||
import ChevronRight from 'lucide-svelte/icons/chevron-right';
|
||||
import Copy from 'lucide-svelte/icons/copy';
|
||||
import CreditCard from 'lucide-svelte/icons/credit-card';
|
||||
import EllipsisVertical from 'lucide-svelte/icons/ellipsis-vertical';
|
||||
import Truck from 'lucide-svelte/icons/truck';
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
||||
import * as Pagination from '$lib/components/ui/pagination/index.js';
|
||||
import { Separator } from '$lib/components/ui/separator/index.js';
|
||||
import * as Table from '@/components/ui/table';
|
||||
import { RocketATagFilter } from '@/event_helpers/rockets';
|
||||
import { derived } from 'svelte/store';
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { unixToRelativeTime } from '@/helpers';
|
||||
|
||||
export let merit: MeritRequest;
|
||||
export let rocket: NDKEvent;
|
||||
|
||||
let votes = $ndk.storeSubscribe([merit.REQFilter(1410)], {
|
||||
subId: merit.RocketTag!.split(':')[2] + '_votes'
|
||||
let _votes = $ndk.storeSubscribe(
|
||||
{ '#a': [RocketATagFilter(rocket)], kinds: [1410 as NDKKind] },
|
||||
{
|
||||
subId: merit.RocketTag!.split(':')[2] + '_votes'
|
||||
}
|
||||
);
|
||||
|
||||
let votes = derived(_votes, ($_votes) => {
|
||||
let vMap = new Map<string, Vote>();
|
||||
for (let v of $_votes) {
|
||||
let vote = new Vote(v);
|
||||
if (vote.BasicValidation()) {
|
||||
vMap.set(vote.ID, vote);
|
||||
}
|
||||
}
|
||||
return vMap;
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
votes.unsubscribe();
|
||||
_votes.unsubscribe();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Card.Root class="sm:col-span-2">
|
||||
<Card.Header class="bg-muted/50 pb-3">
|
||||
<Card.Header class="pb-3">
|
||||
<div class="flex flex-nowrap justify-between">
|
||||
<Card.Title>Problem: {merit.Problem().substring(0, 20)}</Card.Title>{#if merit.Solution()}<a
|
||||
class="flex flex-nowrap text-orange-500 underline decoration-orange-500"
|
||||
@@ -45,7 +56,7 @@
|
||||
pubkey={merit.Pubkey}
|
||||
class="h-10 w-10 flex-none rounded-full object-cover"
|
||||
/>
|
||||
<Name ndk={$ndk} pubkey={merit.Pubkey} class="hidden max-w-32 truncate p-2 md:inline-block" />
|
||||
<Name ndk={$ndk} pubkey={merit.Pubkey} class="max-w-32 truncate p-2 inline-block" />
|
||||
</div>
|
||||
<Card.Description class="max-w-lg text-balance leading-relaxed">
|
||||
{#if merit.Problem().length > 20}{merit.Problem()}{/if}
|
||||
@@ -76,17 +87,52 @@
|
||||
<div class="grid gap-3">
|
||||
<div class="font-semibold">Analysis</div>
|
||||
<span class="grid gap-0.5 not-italic text-muted-foreground">
|
||||
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using this rate, the contributor is claiming to have spent about {merit.Sats/1000} hours working on this.
|
||||
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using
|
||||
this rate, the contributor is claiming to have spent about {merit.Sats / 1000} hours working
|
||||
on this.
|
||||
</span>
|
||||
</div>
|
||||
<div class="grid auto-rows-max gap-3">
|
||||
<div class="font-semibold">Reference Time</div>
|
||||
<div class="text-muted-foreground">{merit.Sats/1000} hours</div>
|
||||
<div class="text-muted-foreground">{merit.Sats / 1000} hours</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</Card.Content>
|
||||
<Separator class="my-4" />
|
||||
<div class="font-semibold">Votes</div>
|
||||
<Table.Root>
|
||||
<Table.Body>
|
||||
{#each $votes as [id, vote], _ (id)}
|
||||
<Table.Row
|
||||
on:click={() => {
|
||||
console.log(vote.Event.rawEvent());
|
||||
goto(`${base}/rockets/merits/${vote.ID}`);
|
||||
}}
|
||||
class="cursor-pointer {vote.VoteDirection == "ratify"?"bg-lime-600":"bg-red-700"} "
|
||||
>
|
||||
<Table.Cell>
|
||||
<div class="flex flex-nowrap">
|
||||
<Avatar
|
||||
ndk={$ndk}
|
||||
pubkey={vote.Pubkey}
|
||||
class="h-10 w-10 flex-none rounded-full object-cover"
|
||||
/>
|
||||
<Name
|
||||
ndk={$ndk}
|
||||
pubkey={vote.Pubkey}
|
||||
class="max-w-32 truncate p-2 inline-block"
|
||||
/>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell class="hidden text-left md:table-cell">{vote.VoteDirection}</Table.Cell>
|
||||
<Table.Cell class="text-right table-cell"
|
||||
>{unixToRelativeTime(vote.TimeStamp * 1000)}</Table.Cell
|
||||
>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
</div></Card.Content
|
||||
>
|
||||
</Card.Header>
|
||||
<Card.Footer class="flex flex-row items-center border-t px-6 py-3">
|
||||
<VoteOnMeritRequest {merit} {rocket} />
|
||||
|
||||
Reference in New Issue
Block a user