mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-07 22:03:35 +00:00
Fix edits showing as deletes
This commit is contained in:
parent
05d4a84522
commit
7a4eeaf4b7
@ -4,9 +4,10 @@
|
||||
|
||||
export let event
|
||||
|
||||
const date = secondsToDate(Tags.fromEvent(event).get("start")?.value())
|
||||
const monthFmt = new Intl.DateTimeFormat(getLocale(), {month: "short"})
|
||||
const dayFmt = new Intl.DateTimeFormat(getLocale(), {day: "numeric"})
|
||||
|
||||
$: date = secondsToDate(Tags.fromEvent(event).get("start")?.value())
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 px-12">
|
||||
|
@ -10,29 +10,30 @@
|
||||
import EventActions from "src/app/shared/EventActions.svelte"
|
||||
import NoteContentKind1 from "src/app/shared/NoteContentKind1.svelte"
|
||||
import {router} from "src/app/util/router"
|
||||
import {deriveIsDeleted, getSetting, pubkey} from "src/engine"
|
||||
import {deriveIsDeletedByAddress, getSetting, pubkey} from "src/engine"
|
||||
|
||||
export let event
|
||||
export let showDate = false
|
||||
export let actionsInline = false
|
||||
|
||||
const address = getAddress(event)
|
||||
const timeFmt = new Intl.DateTimeFormat(getLocale(), {timeStyle: "short"})
|
||||
const datetimeFmt = new Intl.DateTimeFormat(getLocale(), {dateStyle: "short", timeStyle: "short"})
|
||||
const tags = Tags.fromEvent(event)
|
||||
const groupAddrs = tags.context().values().valueOf()
|
||||
const {name, title, location} = fromPairs(event.tags)
|
||||
const end = parseInt(tags.get("end")?.value())
|
||||
const start = parseInt(tags.get("start")?.value())
|
||||
const startDate = secondsToDate(start)
|
||||
const endDate = secondsToDate(end)
|
||||
const startDateDisplay = formatTimestampAsDate(start)
|
||||
const endDateDisplay = formatTimestampAsDate(end)
|
||||
const isSingleDay = startDateDisplay === endDateDisplay
|
||||
const address = getAddress(event)
|
||||
const detailPath = router.at("events").of(address).toString()
|
||||
const editLink = router.at("events").of(address).at("edit").toString()
|
||||
const deleteLink = router.at("events").of(address).at("delete").toString()
|
||||
const deleted = deriveIsDeleted(event)
|
||||
const deleted = deriveIsDeletedByAddress(event)
|
||||
|
||||
$: tags = Tags.fromEvent(event)
|
||||
$: groupAddrs = tags.context().values().valueOf()
|
||||
$: ({name, title, location} = fromPairs(event.tags))
|
||||
$: end = parseInt(tags.get("end")?.value())
|
||||
$: start = parseInt(tags.get("start")?.value())
|
||||
$: startDate = secondsToDate(start)
|
||||
$: endDate = secondsToDate(end)
|
||||
$: startDateDisplay = formatTimestampAsDate(start)
|
||||
$: endDateDisplay = formatTimestampAsDate(end)
|
||||
$: isSingleDay = startDateDisplay === endDateDisplay
|
||||
</script>
|
||||
|
||||
<div class="flex flex-grow flex-col gap-2">
|
||||
|
@ -11,7 +11,7 @@
|
||||
import NoteContentTopics from "src/app/shared/NoteContentTopics.svelte"
|
||||
import NoteContentKind1 from "src/app/shared/NoteContentKind1.svelte"
|
||||
import {router} from "src/app/util/router"
|
||||
import {hints, pubkey, deriveIsDeleted} from "src/engine"
|
||||
import {hints, pubkey, deriveIsDeletedByAddress} from "src/engine"
|
||||
|
||||
export let note
|
||||
export let showMedia = false
|
||||
@ -24,7 +24,7 @@
|
||||
const address = Address.fromEvent(note, hints.Event(note).redundancy(3).getUrls())
|
||||
const editLink = router.at("listings").of(address.toString()).at("edit").toString()
|
||||
const deleteLink = router.at("listings").of(address.toString()).at("delete").toString()
|
||||
const deleted = deriveIsDeleted(note)
|
||||
const deleted = deriveIsDeletedByAddress(note)
|
||||
|
||||
const sendMessage = () => {
|
||||
const naddr = address.toNaddr()
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {getIdOrAddress, Address} from "@welshman/util"
|
||||
import {getIdOrAddress, getIdFilters, Address} from "@welshman/util"
|
||||
import {feedFromFilter} from "@welshman/feeds"
|
||||
import {fly} from "src/util/transition"
|
||||
import FlexColumn from "src/partials/FlexColumn.svelte"
|
||||
@ -9,34 +9,36 @@
|
||||
import EventDate from "src/app/shared/EventDate.svelte"
|
||||
import EventInfo from "src/app/shared/EventInfo.svelte"
|
||||
import NoteCreateInline from "src/app/shared/NoteCreateInline.svelte"
|
||||
import {loadOne, deriveEvent} from "src/engine"
|
||||
import {makeFeed} from "src/domain"
|
||||
import {dereferenceNote} from "src/engine"
|
||||
|
||||
export let address
|
||||
export let relays = []
|
||||
export let event = null
|
||||
|
||||
const event = deriveEvent(address)
|
||||
|
||||
const feed = makeFeed({definition: feedFromFilter({"#a": [address]})})
|
||||
|
||||
let loading = true
|
||||
|
||||
onMount(async () => {
|
||||
event = event || (await dereferenceNote(Address.from(address, relays)))
|
||||
await loadOne({relays, filters: getIdFilters([address]), forcePlatform: false})
|
||||
|
||||
loading = false
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if loading}
|
||||
<Spinner />
|
||||
{:else if event}
|
||||
{:else if $event}
|
||||
<div in:fly={{y: 20}}>
|
||||
<FlexColumn>
|
||||
<div class="flex gap-4">
|
||||
<EventDate {event} />
|
||||
<EventInfo {event} />
|
||||
<EventDate event={$event} />
|
||||
<EventInfo event={$event} />
|
||||
</div>
|
||||
<NoteCreateInline parent={event} />
|
||||
<Feed {feed} hideSpinner shouldListen anchor={getIdOrAddress(event)} />
|
||||
<NoteCreateInline parent={$event} />
|
||||
<Feed {feed} hideSpinner shouldListen anchor={getIdOrAddress($event)} />
|
||||
</FlexColumn>
|
||||
</div>
|
||||
{:else}
|
||||
|
@ -121,11 +121,11 @@ export const deriveEvents = (opts: {filters: Filter[]; includeDeleted?: boolean}
|
||||
export const deriveEvent = (idOrAddress: string) =>
|
||||
derived(deriveEvents({filters: getIdFilters([idOrAddress]), includeDeleted: true}), first)
|
||||
|
||||
export const deriveIsDeleted = (event: TrustedEvent) =>
|
||||
export const deriveIsDeletedByAddress = (event: TrustedEvent) =>
|
||||
custom<boolean>(setter => {
|
||||
setter(repository.isDeleted(event))
|
||||
setter(repository.isDeletedByAddress(event))
|
||||
|
||||
const onUpdate = batch(300, () => setter(repository.isDeleted(event)))
|
||||
const onUpdate = batch(300, () => setter(repository.isDeletedByAddress(event)))
|
||||
|
||||
repository.on("update", onUpdate)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user