Minimize note creator

This commit is contained in:
Kieran 2023-01-08 21:59:33 +00:00
parent a697751f03
commit 194668317f
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 14 additions and 8 deletions

View File

@ -2,6 +2,7 @@
margin-bottom: 10px;
background-color: #333;
border-radius: 10px;
overflow: hidden;
}
.note-creator textarea {

View File

@ -14,6 +14,7 @@ export function NoteCreator(props) {
const publisher = useEventPublisher();
const [note, setNote] = useState("");
const [error, setError] = useState("");
const [active, setActive] = useState(false);
async function sendNote() {
let ev = replyTo ?
@ -47,16 +48,16 @@ export function NoteCreator(props) {
return (
<>
{replyTo ? <small>{`Reply to: ${replyTo.Id.substring(0, 8)}`}</small> : null}
<div className="flex note-creator">
<div className="flex note-creator" onClick={() => setActive(true)}>
<div className="textarea flex f-col mr10 f-grow">
<textarea className="textarea" placeholder="Say something!" value={note} onChange={(e) => setNote(e.target.value)} />
<div className="actions flex f-row">
{active ? <div className="actions flex f-row">
<div className="attachment flex f-row">
{error.length > 0 ? <b className="error">{error}</b> : null}
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
</div>
<div className="btn" onClick={() => sendNote()}>Send</div>
</div>
</div> : null}
</div>
</div>
</>

View File

@ -20,8 +20,8 @@ export default function NoteFooter(props) {
const isMine = ev.RootPubKey === login;
const groupReactions = useMemo(() => {
return reactions?.reduce((acc, { content }) => {
let r = normalizeReaction(content ?? "");
return reactions?.reduce((acc, { Content }) => {
let r = normalizeReaction(Content ?? "");
const amount = acc[r] || 0
return { ...acc, [r]: amount + 1 }
}, {

View File

@ -1,4 +1,5 @@
import Event from "./Event";
import EventKind from "./EventKind";
export default class Thread {
constructor() {
@ -22,19 +23,22 @@ export default class Thread {
return null;
}
let shouldWriteMarkers = ev.Kind === EventKind.TextNote;
let ret = new Thread();
let eTags = ev.Tags.filter(a => a.Key === "e");
let marked = eTags.some(a => a.Marker !== null);
if (!marked) {
ret.Root = eTags[0];
ret.Root.Marker = "root";
ret.Root.Marker = shouldWriteMarkers ? "root" : null;
if (eTags.length > 1) {
ret.ReplyTo = eTags[1];
ret.ReplyTo.Marker = "reply";
ret.ReplyTo.Marker = shouldWriteMarkers ? "reply" : null;
}
if (eTags.length > 2) {
ret.Mentions = eTags.slice(2);
ret.Mentions.forEach(a => a.Marker = "mention");
if (shouldWriteMarkers) {
ret.Mentions.forEach(a => a.Marker = "mention");
}
}
} else {
let root = eTags.find(a => a.Marker === "root");