Fix thread disappearing bug, improve article editor UX

Move selectedNote guard after hooks in ThreadView to fix React rules
of hooks violation that caused thread content to blank out. Article
editor gets inline image previews, readable toolbar labels, and
drag-and-drop image support. Thread reply textareas now auto-expand.
This commit is contained in:
Jure
2026-03-25 12:01:47 +01:00
parent 5b94162ce1
commit ef21667d9f
4 changed files with 74 additions and 17 deletions

View File

@@ -16,8 +16,6 @@ export function ThreadView() {
const { selectedNote, goBack } = useUIStore();
const { loggedIn } = useUserStore();
const { mutedPubkeys, contentMatchesMutedKeyword } = useMuteStore();
if (!selectedNote) { goBack(); return null; }
const focusedEvent = selectedNote;
const [rootEvent, setRootEvent] = useState<NDKEvent | null>(null);
const [ancestors, setAncestors] = useState<NDKEvent[]>([]);
@@ -32,9 +30,12 @@ export function ThreadView() {
const autoResize = useAutoResize(2, 8);
const replyRef = useRef<HTMLTextAreaElement>(null);
const scrollRef = useRef<HTMLDivElement>(null);
const [retryCount, setRetryCount] = useState(0);
// Guard AFTER all hooks to satisfy React rules of hooks
if (!selectedNote) { goBack(); return null; }
const focusedEvent = selectedNote;
useEffect(() => {
let cancelled = false;