Browse Source

fix: status errors

these changes should have been included in
a9ae256ec0
master
DanConwayDev 2 years ago
parent
commit
09154c48b0
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 23
      src/lib/components/events/content/Kind19851985.svelte
  2. 13
      src/lib/components/events/content/Status.svelte
  3. 19
      src/lib/components/proposals/ProposalsListItem.svelte
  4. 19
      src/lib/components/proposals/vectors.ts
  5. 8
      src/lib/wrappers/EventCard.svelte

23
src/lib/components/events/content/Kind19851985.svelte

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
<script lang="ts">
import type { NDKTag } from '@nostr-dev-kit/ndk'
import Status from '$lib/components/proposals/Status.svelte'
export let tags: NDKTag[] = []
function extractTagContent(name: string): string | undefined {
let tag = tags.find((tag) => tag[0] === name)
return tag ? tag[1] : undefined
}
let status: string | undefined
$: {
status = extractTagContent('l')
}
</script>
<div class="">
{#if status}
set status to <Status {status} />
{:else}
set status incorrectly
{/if}
</div>

13
src/lib/components/events/content/Status.svelte

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
<script lang="ts">
import Status from '$lib/components/proposals/Status.svelte'
export let status: number | undefined
</script>
<div class="">
{#if status}
set status to <Status {status} />
{:else}
set status incorrectly
{/if}
</div>

19
src/lib/components/proposals/ProposalsListItem.svelte

@ -5,9 +5,14 @@ @@ -5,9 +5,14 @@
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { summary_defaults } from './type'
import { getName } from '../users/type'
import { proposal_icon_path } from './icons'
import UserHeader from '../users/UserHeader.svelte'
import {
proposal_status_applied,
proposal_status_closed,
proposal_status_draft,
proposal_status_open,
} from '$lib/kinds'
dayjs.extend(relativeTime)
export let {
@ -22,10 +27,6 @@ @@ -22,10 +27,6 @@
} = summary_defaults
let short_title: string
let created_at_ago: string
let author_name = ''
$: {
author_name = getName(author)
}
$: {
if (title.length > 70) short_title = title.slice(0, 65) + '...'
else if (title.length == 0) short_title = 'Untitled'
@ -41,28 +42,28 @@ @@ -41,28 +42,28 @@
<!-- http://icon-sets.iconify.design/octicon/git-pull-request-16/ -->
{#if loading || !status}
<div class="skeleton h-5 w-5 flex-none pt-1"></div>
{:else if status === 'Open'}
{:else if status === proposal_status_open}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
class="h-5 w-5 flex-none fill-success pt-1"
><path d={proposal_icon_path.open} /></svg
>
{:else if status === 'Closed'}
{:else if status === proposal_status_closed}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
class="h-5 w-5 flex-none fill-neutral-content pt-1"
><path d={proposal_icon_path.close} /></svg
>
{:else if status === 'Draft'}
{:else if status === proposal_status_draft}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
class="h-5 w-5 flex-none fill-neutral-content pt-1"
><path d={proposal_icon_path.draft} /></svg
>
{:else if status === 'Merged'}
{:else if status === proposal_status_applied}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"

19
src/lib/components/proposals/vectors.ts

@ -2,6 +2,11 @@ import dayjs from 'dayjs' @@ -2,6 +2,11 @@ import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import type { ProposalSummary } from './type'
import { UserVectors } from '../users/vectors'
import {
proposal_status_applied,
proposal_status_draft,
proposal_status_open,
} from '$lib/kinds'
dayjs.extend(relativeTime)
@ -10,7 +15,7 @@ const Short = { @@ -10,7 +15,7 @@ const Short = {
author: { ...UserVectors.default },
created_at: dayjs().subtract(7, 'days').unix(),
comments: 2,
status: 'Open',
status: proposal_status_open,
loading: false,
} as ProposalSummary
@ -22,7 +27,7 @@ export const ProposalsListItemArgsVectors = { @@ -22,7 +27,7 @@ export const ProposalsListItemArgsVectors = {
author: { ...UserVectors.default },
created_at: dayjs().subtract(1, 'minute').unix(),
comments: 0,
status: 'Open',
status: proposal_status_open,
loading: false,
} as ProposalSummary,
LongNoSpaces: {
@ -31,7 +36,7 @@ export const ProposalsListItemArgsVectors = { @@ -31,7 +36,7 @@ export const ProposalsListItemArgsVectors = {
author: { ...UserVectors.default },
created_at: dayjs().subtract(3, 'month').subtract(3, 'days').unix(),
comments: 1,
status: 'Open',
status: proposal_status_open,
loading: false,
} as ProposalSummary,
AuthorLoading: {
@ -39,7 +44,7 @@ export const ProposalsListItemArgsVectors = { @@ -39,7 +44,7 @@ export const ProposalsListItemArgsVectors = {
author: { ...UserVectors.loading },
created_at: dayjs().subtract(3, 'month').subtract(3, 'days').unix(),
comments: 1,
status: 'Open',
status: proposal_status_open,
loading: false,
} as ProposalSummary,
StatusLoading: {
@ -48,14 +53,14 @@ export const ProposalsListItemArgsVectors = { @@ -48,14 +53,14 @@ export const ProposalsListItemArgsVectors = {
} as ProposalSummary,
StatusDraft: {
...Short,
status: 'Draft',
status: proposal_status_draft,
} as ProposalSummary,
StatusClosed: {
...Short,
status: 'Closed',
status: proposal_status_draft,
} as ProposalSummary,
StatusMerged: {
...Short,
status: 'Merged',
status: proposal_status_applied,
} as ProposalSummary,
}

8
src/lib/wrappers/EventCard.svelte

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
<script lang="ts">
import EventWrapper from '$lib/components/events/EventWrapper.svelte'
import Kind19851985 from '$lib/components/events/content/Kind19851985.svelte'
import Status from '$lib/components/events/content/Status.svelte'
import Patch from '$lib/components/events/content/Patch.svelte'
import ParsedContent from '$lib/components/events/content/ParsedContent.svelte'
import { defaults as user_defaults } from '$lib/components/users/type'
import { patch_kind, proposal_status_kind } from '$lib/kinds'
import { patch_kind, proposal_status_kinds } from '$lib/kinds'
import { ensureUser } from '$lib/stores/users'
import type { NDKEvent } from '@nostr-dev-kit/ndk'
import { onDestroy } from 'svelte'
@ -33,8 +33,8 @@ @@ -33,8 +33,8 @@
>
{#if event.kind == patch_kind}
<Patch content={event.content} tags={event.tags} />
{:else if event.kind === proposal_status_kind}
<Kind19851985 tags={event.tags} />
{:else if event.kind && proposal_status_kinds.includes(event.kind)}
<Status status={event.kind} />
{:else}
<ParsedContent content={event.content} tags={event.tags} />
{/if}

Loading…
Cancel
Save