-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathReactionButtons.tsx
More file actions
63 lines (54 loc) · 1.73 KB
/
ReactionButtons.tsx
File metadata and controls
63 lines (54 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { ChatBubbleOvalLeftIcon } from '@heroicons/react/24/outline';
import { memo } from 'preact/compat';
import { useEffect, useState } from 'preact/hooks';
import { route } from 'preact-router';
import Events from '../../../nostr/Events';
import Key from '../../../nostr/Key';
import ReactionsList from '../ReactionsList';
import Like from './Like';
import Repost from './Repost';
import Zap from './Zap';
import Relay from '../note/Relay';
const ReactionButtons = (props) => {
const [state, setState] = useState({
replyCount: 0,
});
const event = props.event;
useEffect(() => {
return Events.getThreadRepliesCount(event.id, handleThreadReplyCount);
}, [event]);
const handleThreadReplyCount = (threadReplyCount) => {
setState((prevState) => ({
...prevState,
replyCount: threadReplyCount,
}));
};
function replyBtnClicked() {
if (props.standalone) {
document.querySelector('textarea')?.focus();
} else {
route(`/${Key.toNostrBech32Address(props.event.id, 'note')}`);
}
}
return (
<>
{props.standalone && <ReactionsList event={props.event} />}
<div class="flex justify-between">
<div className="flex gap-4">
<a
className="btn-ghost btn-sm hover:bg-transparent hover:text-iris-blue btn content-center gap-2 rounded-none text-neutral-500"
onClick={() => replyBtnClicked()}
>
<ChatBubbleOvalLeftIcon width={18} />
<span>{state.replyCount || ''}</span>
</a>
<Repost event={props.event} />
<Like event={props.event} />
<Zap event={props.event} />
</div>
<Relay event={event} />
</div>
</>
);
};
export default memo(ReactionButtons);