mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-16 18:23:43 +00:00
parent
a2f68c0c74
commit
70331bfb81
@ -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,
|
||||
|
@ -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(() => {
|
||||
|
30
src/app/views/NoteDelete.svelte
Normal file
30
src/app/views/NoteDelete.svelte
Normal 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>
|
@ -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})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user