mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 11:43:35 +00:00
Get rid of flag reactions
This commit is contained in:
parent
ae97eed739
commit
b563a6b291
@ -10,7 +10,6 @@
|
|||||||
import {displayPerson, toHex} from "src/util/nostr"
|
import {displayPerson, toHex} from "src/util/nostr"
|
||||||
import Tabs from "src/partials/Tabs.svelte"
|
import Tabs from "src/partials/Tabs.svelte"
|
||||||
import Content from "src/partials/Content.svelte"
|
import Content from "src/partials/Content.svelte"
|
||||||
import Popover from "src/partials/Popover.svelte"
|
|
||||||
import OverflowMenu from "src/partials/OverflowMenu.svelte"
|
import OverflowMenu from "src/partials/OverflowMenu.svelte"
|
||||||
import Spinner from "src/partials/Spinner.svelte"
|
import Spinner from "src/partials/Spinner.svelte"
|
||||||
import NewNoteButton from "src/views/notes/NewNoteButton.svelte"
|
import NewNoteButton from "src/views/notes/NewNoteButton.svelte"
|
||||||
|
@ -64,18 +64,16 @@
|
|||||||
const interactive = !anchorId || !showEntire
|
const interactive = !anchorId || !showEntire
|
||||||
const person = watch("people", () => getPersonWithFallback(note.pubkey))
|
const person = watch("people", () => getPersonWithFallback(note.pubkey))
|
||||||
|
|
||||||
let likes, flags, zaps, like, flag, border, childrenContainer, noteContainer, canZap, actions
|
let likes, zaps, like, border, childrenContainer, noteContainer, canZap, actions
|
||||||
let muted = false
|
let muted = false
|
||||||
|
|
||||||
const interpolate = (a, b) => t => a + Math.round((b - a) * t)
|
const interpolate = (a, b) => t => a + Math.round((b - a) * t)
|
||||||
const likesCount = tweened(0, {interpolate})
|
const likesCount = tweened(0, {interpolate})
|
||||||
const flagsCount = tweened(0, {interpolate})
|
|
||||||
const zapsTotal = tweened(0, {interpolate})
|
const zapsTotal = tweened(0, {interpolate})
|
||||||
const repliesCount = tweened(0, {interpolate})
|
const repliesCount = tweened(0, {interpolate})
|
||||||
|
|
||||||
$: muted = find(m => m[1] === note.id, $mutes)
|
$: muted = find(m => m[1] === note.id, $mutes)
|
||||||
$: likes = note.reactions.filter(n => isLike(n.content))
|
$: likes = note.reactions.filter(n => isLike(n.content))
|
||||||
$: flags = note.reactions.filter(whereEq({content: "-"}))
|
|
||||||
$: zaps = note.zaps
|
$: zaps = note.zaps
|
||||||
.map(zap => {
|
.map(zap => {
|
||||||
const zapMeta = Tags.from(zap).asMeta()
|
const zapMeta = Tags.from(zap).asMeta()
|
||||||
@ -118,10 +116,8 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
$: like = find(whereEq({pubkey: $profile?.pubkey}), likes)
|
$: like = find(whereEq({pubkey: $profile?.pubkey}), likes)
|
||||||
$: flag = find(whereEq({pubkey: $profile?.pubkey}), flags)
|
|
||||||
$: zapped = find(z => z.request.pubkey === $profile?.pubkey, zaps)
|
$: zapped = find(z => z.request.pubkey === $profile?.pubkey, zaps)
|
||||||
$: $likesCount = likes.length
|
$: $likesCount = likes.length
|
||||||
$: $flagsCount = flags.length
|
|
||||||
$: $zapsTotal = sum(zaps.map(zap => zap.invoiceAmount)) / 1000
|
$: $zapsTotal = sum(zaps.map(zap => zap.invoiceAmount)) / 1000
|
||||||
$: $repliesCount = note.replies.length
|
$: $repliesCount = note.replies.length
|
||||||
$: visibleNotes = note.replies.filter(r => (showContext ? true : !r.isContext))
|
$: visibleNotes = note.replies.filter(r => (showContext ? true : !r.isContext))
|
||||||
@ -147,8 +143,6 @@
|
|||||||
} else {
|
} else {
|
||||||
actions.push({label: "Mute", icon: "microphone-slash", onClick: mute})
|
actions.push({label: "Mute", icon: "microphone-slash", onClick: mute})
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.push({label: "Flag", icon: "flag", onClick: () => react("-")})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClick = e => {
|
const onClick = e => {
|
||||||
@ -183,25 +177,13 @@
|
|||||||
const relays = getEventPublishRelays(note)
|
const relays = getEventPublishRelays(note)
|
||||||
const [event] = await cmd.createReaction(note, content).publish(relays)
|
const [event] = await cmd.createReaction(note, content).publish(relays)
|
||||||
|
|
||||||
if (content === "+") {
|
likes = likes.concat(event)
|
||||||
likes = likes.concat(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content === "-") {
|
|
||||||
flags = flags.concat(event)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteReaction = e => {
|
const deleteReaction = e => {
|
||||||
cmd.deleteEvent([e.id]).publish(getEventPublishRelays(note))
|
cmd.deleteEvent([e.id]).publish(getEventPublishRelays(note))
|
||||||
|
|
||||||
if (e.content === "+") {
|
likes = reject(propEq("pubkey", $profile.pubkey), likes)
|
||||||
likes = reject(propEq("pubkey", $profile.pubkey), likes)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.content === "-") {
|
|
||||||
flags = reject(propEq("pubkey", $profile.pubkey), flags)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const startReply = () => {
|
const startReply = () => {
|
||||||
@ -423,12 +405,7 @@
|
|||||||
</small>
|
</small>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if flag}
|
{#if muted}
|
||||||
<p class="border-l-2 border-solid border-gray-6 pl-4 text-gray-1">
|
|
||||||
You have flagged this content as offensive.
|
|
||||||
<Anchor on:click={() => deleteReaction(flag)}>Unflag</Anchor>
|
|
||||||
</p>
|
|
||||||
{:else if muted}
|
|
||||||
<p class="border-l-2 border-solid border-gray-6 pl-4 text-gray-1">
|
<p class="border-l-2 border-solid border-gray-6 pl-4 text-gray-1">
|
||||||
You have muted this note.
|
You have muted this note.
|
||||||
</p>
|
</p>
|
||||||
@ -438,7 +415,7 @@
|
|||||||
<div class="flex justify-between text-gray-1">
|
<div class="flex justify-between text-gray-1">
|
||||||
<div
|
<div
|
||||||
class={cx("flex", {
|
class={cx("flex", {
|
||||||
"pointer-events-none opacity-75": !$canPublish || flag || muted,
|
"pointer-events-none opacity-75": !$canPublish || muted,
|
||||||
})}>
|
})}>
|
||||||
<button class="w-16 text-left" on:click|stopPropagation={startReply}>
|
<button class="w-16 text-left" on:click|stopPropagation={startReply}>
|
||||||
<i class="fa fa-reply cursor-pointer" />
|
<i class="fa fa-reply cursor-pointer" />
|
||||||
|
Loading…
Reference in New Issue
Block a user