Minimize note creator
This commit is contained in:
parent
a697751f03
commit
194668317f
@ -2,6 +2,7 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.note-creator textarea {
|
.note-creator textarea {
|
||||||
|
@ -14,6 +14,7 @@ export function NoteCreator(props) {
|
|||||||
const publisher = useEventPublisher();
|
const publisher = useEventPublisher();
|
||||||
const [note, setNote] = useState("");
|
const [note, setNote] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
const [active, setActive] = useState(false);
|
||||||
|
|
||||||
async function sendNote() {
|
async function sendNote() {
|
||||||
let ev = replyTo ?
|
let ev = replyTo ?
|
||||||
@ -47,16 +48,16 @@ export function NoteCreator(props) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{replyTo ? <small>{`Reply to: ${replyTo.Id.substring(0, 8)}`}</small> : null}
|
{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">
|
<div className="textarea flex f-col mr10 f-grow">
|
||||||
<textarea className="textarea" placeholder="Say something!" value={note} onChange={(e) => setNote(e.target.value)} />
|
<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">
|
<div className="attachment flex f-row">
|
||||||
{error.length > 0 ? <b className="error">{error}</b> : null}
|
{error.length > 0 ? <b className="error">{error}</b> : null}
|
||||||
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
|
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
|
||||||
</div>
|
</div>
|
||||||
<div className="btn" onClick={() => sendNote()}>Send</div>
|
<div className="btn" onClick={() => sendNote()}>Send</div>
|
||||||
</div>
|
</div> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -20,8 +20,8 @@ export default function NoteFooter(props) {
|
|||||||
const isMine = ev.RootPubKey === login;
|
const isMine = ev.RootPubKey === login;
|
||||||
|
|
||||||
const groupReactions = useMemo(() => {
|
const groupReactions = useMemo(() => {
|
||||||
return reactions?.reduce((acc, { content }) => {
|
return reactions?.reduce((acc, { Content }) => {
|
||||||
let r = normalizeReaction(content ?? "");
|
let r = normalizeReaction(Content ?? "");
|
||||||
const amount = acc[r] || 0
|
const amount = acc[r] || 0
|
||||||
return { ...acc, [r]: amount + 1 }
|
return { ...acc, [r]: amount + 1 }
|
||||||
}, {
|
}, {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Event from "./Event";
|
import Event from "./Event";
|
||||||
|
import EventKind from "./EventKind";
|
||||||
|
|
||||||
export default class Thread {
|
export default class Thread {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -22,20 +23,23 @@ export default class Thread {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let shouldWriteMarkers = ev.Kind === EventKind.TextNote;
|
||||||
let ret = new Thread();
|
let ret = new Thread();
|
||||||
let eTags = ev.Tags.filter(a => a.Key === "e");
|
let eTags = ev.Tags.filter(a => a.Key === "e");
|
||||||
let marked = eTags.some(a => a.Marker !== null);
|
let marked = eTags.some(a => a.Marker !== null);
|
||||||
if (!marked) {
|
if (!marked) {
|
||||||
ret.Root = eTags[0];
|
ret.Root = eTags[0];
|
||||||
ret.Root.Marker = "root";
|
ret.Root.Marker = shouldWriteMarkers ? "root" : null;
|
||||||
if (eTags.length > 1) {
|
if (eTags.length > 1) {
|
||||||
ret.ReplyTo = eTags[1];
|
ret.ReplyTo = eTags[1];
|
||||||
ret.ReplyTo.Marker = "reply";
|
ret.ReplyTo.Marker = shouldWriteMarkers ? "reply" : null;
|
||||||
}
|
}
|
||||||
if (eTags.length > 2) {
|
if (eTags.length > 2) {
|
||||||
ret.Mentions = eTags.slice(2);
|
ret.Mentions = eTags.slice(2);
|
||||||
|
if (shouldWriteMarkers) {
|
||||||
ret.Mentions.forEach(a => a.Marker = "mention");
|
ret.Mentions.forEach(a => a.Marker = "mention");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let root = eTags.find(a => a.Marker === "root");
|
let root = eTags.find(a => a.Marker === "root");
|
||||||
let reply = eTags.find(a => a.Marker === "reply");
|
let reply = eTags.find(a => a.Marker === "reply");
|
||||||
|
Loading…
Reference in New Issue
Block a user