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

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

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

8
src/lib/wrappers/EventCard.svelte

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

Loading…
Cancel
Save