mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Fix reactions
This commit is contained in:
parent
452c3d8725
commit
7b7fb2cdcb
@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import cx from 'classnames'
|
||||
import extractUrls from 'extract-urls'
|
||||
import {whereEq, find} from 'ramda'
|
||||
import {whereEq, reject, propEq, find} from 'ramda'
|
||||
import {slide} from 'svelte/transition'
|
||||
import {navigate} from 'svelte-routing'
|
||||
import {quantify} from 'hurdak/lib/hurdak'
|
||||
@ -31,10 +31,11 @@
|
||||
$: {
|
||||
likes = note.reactions.filter(n => ['', '+'].includes(n.content))
|
||||
flags = note.reactions.filter(whereEq({content: '-'}))
|
||||
like = find(whereEq({pubkey: $user?.pubkey}), likes)
|
||||
flag = find(whereEq({pubkey: $user?.pubkey}), flags)
|
||||
}
|
||||
|
||||
$: like = find(whereEq({pubkey: $user?.pubkey}), likes)
|
||||
$: flag = find(whereEq({pubkey: $user?.pubkey}), flags)
|
||||
|
||||
const onClick = e => {
|
||||
if (!['I'].includes(e.target.tagName) && !hasParent('a', e.target)) {
|
||||
modal.set({note})
|
||||
@ -45,21 +46,19 @@
|
||||
modal.set({note: {id: findReply(note)}})
|
||||
}
|
||||
|
||||
const react = content => {
|
||||
if ($user) {
|
||||
relay.cmd.createReaction(content, note)
|
||||
} else {
|
||||
navigate('/login')
|
||||
const react = async content => {
|
||||
if (!$user) {
|
||||
return navigate('/login')
|
||||
}
|
||||
|
||||
const event = await relay.cmd.createReaction(content, note)
|
||||
|
||||
if (content === '+') {
|
||||
like = true
|
||||
likes += 1
|
||||
likes = likes.concat(event)
|
||||
}
|
||||
|
||||
if (content === '-') {
|
||||
flag = true
|
||||
flags += 1
|
||||
flags = flags.concat(event)
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,13 +66,11 @@
|
||||
relay.cmd.deleteEvent([e.id])
|
||||
|
||||
if (e.content === '+') {
|
||||
like = false
|
||||
likes -= 1
|
||||
likes = reject(propEq('pubkey', $user.pubkey), likes)
|
||||
}
|
||||
|
||||
if (e.content === '-') {
|
||||
flag = false
|
||||
flags -= 1
|
||||
flags = reject(propEq('pubkey', $user.pubkey), flags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,8 @@ const renderNote = async (note, {showEntire = false}) => {
|
||||
$a.href = url
|
||||
$a.target = "_blank noopener"
|
||||
$a.className = "underline"
|
||||
|
||||
/* eslint no-useless-escape: 0 */
|
||||
$a.innerText = first(url.replace(/https?:\/\/(www\.)?/, '').split(/[\/\?#]/))
|
||||
|
||||
// If the url is on its own line, remove it entirely. Otherwise, replace it with the link
|
||||
|
@ -3,7 +3,7 @@
|
||||
import {onMount, onDestroy} from 'svelte'
|
||||
import {fly} from 'svelte/transition'
|
||||
import {navigate} from 'svelte-routing'
|
||||
import {now, timedelta} from 'src/util/misc'
|
||||
import {now} from 'src/util/misc'
|
||||
import Tabs from "src/partials/Tabs.svelte"
|
||||
import Button from "src/partials/Button.svelte"
|
||||
import Notes from "src/views/person/Notes.svelte"
|
||||
|
Loading…
Reference in New Issue
Block a user