bring back delete (#377)

bring back delete
This commit is contained in:
Sam Samskies 2024-07-15 09:17:47 -07:00 committed by GitHub
parent a2f68c0c74
commit 70331bfb81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 52 additions and 0 deletions

View File

@ -231,6 +231,12 @@
entity: asNote,
},
})
router.register("/notes/:entity/delete", import("src/app/views/NoteDelete.svelte"), {
serializers: {
entity: asNote,
kind: asString("kind"),
},
})
router.register("/notifications", import("src/app/views/Notifications.svelte"), {
requireUser: true,

View File

@ -111,6 +111,8 @@
const report = () => router.at("notes").of(note.id).at("report").open()
const deleteNote = () => router.at("notes").of(note.id).at("delete").qp({kind: note.kind}).open()
const react = async content => {
if (isSignedEvent(note)) {
publish({event: note, relays: hints.PublishEvent(note).getUrls()})
@ -259,6 +261,14 @@
icon: "info",
onClick: () => setView("info"),
})
if (note.pubkey === $session?.pubkey) {
actions.push({
label: "Delete",
icon: "trash",
onClick: deleteNote,
})
}
}
onMount(() => {

View File

@ -0,0 +1,30 @@
<script lang="ts">
import Anchor from "src/partials/Anchor.svelte"
import FlexColumn from "src/partials/FlexColumn.svelte"
import {router} from "src/app/util/router"
import {deleteEventById} from "src/engine"
export let eid
export let kind
const onCancel = () => router.pop()
const onConfirm = () => {
deleteEventById({kind, id: eid})
router.pop()
}
</script>
<FlexColumn>
<p class="flex items-center gap-4 text-xl">
<i class="fa fa-triangle-exclamation" /> Are you sure you want to delete this event?
</p>
<p>
This will send a request to the network to delete this event. Be aware that relays may not honor
this request.
</p>
<div class="flex gap-2">
<Anchor button on:click={onCancel}>Cancel</Anchor>
<Anchor button danger on:click={onConfirm}>Confirm</Anchor>
</div>
</FlexColumn>

View File

@ -669,6 +669,12 @@ export const publishDeletion = ({kind, address = null, id = null}) => {
export const deleteEvent = event =>
publishDeletion({id: event.id, address: getAddress(event), kind: event.kind})
export const deleteEventById = ({kind, id}) =>
publishDeletion({
kind,
id,
})
export const deleteEventByAddress = address =>
publishDeletion({address, kind: Address.from(address).kind})