Fix bugs, add timehash

This commit is contained in:
Jon Staab
2025-02-05 10:47:56 -08:00
parent f0b2b7c8b3
commit 5909b593ab
7 changed files with 72 additions and 41 deletions
+1 -5
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import {onMount, onDestroy} from "svelte"
import {onMount} from "svelte"
import {writable} from "svelte/store"
import {isMobile, preventDefault} from "@lib/html"
import Icon from "@lib/components/Icon.svelte"
@@ -40,10 +40,6 @@
onMount(() => {
editor.chain().setContent(content).run()
})
onDestroy(() => {
editor.destroy()
})
</script>
<form class="relative z-feature flex gap-2 p-2" onsubmit={preventDefault(submit)}>
+9 -4
View File
@@ -4,6 +4,7 @@
import {createEvent, EVENT_TIME} from "@welshman/util"
import {publishThunk, dateToSeconds} from "@welshman/app"
import {preventDefault} from "@lib/html"
import {timeHashesBetween} from "@lib/util"
import Icon from "@lib/components/Icon.svelte"
import Field from "@lib/components/Field.svelte"
import Button from "@lib/components/Button.svelte"
@@ -38,14 +39,18 @@
})
}
const startTs = dateToSeconds(start)
const endTs = dateToSeconds(end)
const event = createEvent(EVENT_TIME, {
content: editor.getText({blockSeparator: "\n"}).trim(),
tags: [
["d", randomId()],
["title", title],
["location", location],
["start", dateToSeconds(start).toString()],
["end", dateToSeconds(end).toString()],
["start", startTs.toString()],
["end", endTs.toString()],
...timeHashesBetween(startTs, endTs).map(T => ["T", T]),
...editor.storage.nostr.getEditorTags(),
PROTECTED,
],
@@ -106,7 +111,7 @@
</Field>
<Field>
{#snippet label()}
Start
Start*
{/snippet}
{#snippet input()}
<DateTimeInput bind:value={start} />
@@ -114,7 +119,7 @@
</Field>
<Field>
{#snippet label()}
End
End*
{/snippet}
{#snippet input()}
<DateTimeInput bind:value={end} />