fix small errors

This commit is contained in:
Ren Amamiya
2023-07-22 17:35:04 +07:00
parent 20a8ce9cba
commit 6d20f84489
9 changed files with 124 additions and 135 deletions

View File

@@ -1,5 +1,3 @@
import { TauriEvent } from '@tauri-apps/api/event';
import { getCurrent } from '@tauri-apps/api/window';
import Image from '@tiptap/extension-image';
import Mention from '@tiptap/extension-mention';
import Placeholder from '@tiptap/extension-placeholder';
@@ -7,7 +5,7 @@ import { EditorContent, useEditor } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { convert } from 'html-to-text';
import { nip19 } from 'nostr-tools';
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { twMerge } from 'tailwind-merge';
import { Button } from '@shared/button';
@@ -24,11 +22,7 @@ import { sendNativeNotification } from '@utils/notification';
export function Composer() {
const [status, setStatus] = useState<null | 'loading' | 'done'>(null);
const [reply, clearReply, toggleModal] = useComposer((state) => [
state.reply,
state.clearReply,
state.toggleModal,
]);
const [reply, clearReply] = useComposer((state) => [state.reply, state.clearReply]);
const editor = useEditor({
extensions: [
@@ -110,22 +104,17 @@ export function Composer() {
// update state
setStatus('done');
// reset editor
editor.commands.clearContent();
if (reply.id) {
clearReply();
}
} catch {
setStatus(null);
console.log('failed to publish');
}
};
useEffect(() => {
getCurrent().listen(TauriEvent.WINDOW_FILE_DROP, (event) => {
const filepath: string = event.payload[0];
if (filepath.match(/\.(jpg|jpeg|png|gif)$/gi)) {
// open modal
toggleModal(true);
}
});
}, []);
return (
<div className="flex h-full flex-col px-4 pb-4">
<div className="flex h-full w-full gap-3">

View File

@@ -29,7 +29,7 @@ export function ComposerModal() {
return (
<>
<Button onClick={() => toggle(true)} preset="small">
<ComposeIcon width={14} height={14} />
<ComposeIcon className="h-4 w-4" />
Compose
</Button>
<Transition appear show={open} as={Fragment}>
@@ -68,7 +68,7 @@ export function ComposerModal() {
</span>
<div className="inline-flex h-7 w-max items-center justify-center gap-0.5 rounded bg-zinc-800 pl-3 pr-1.5 text-sm font-medium text-zinc-400">
New Post
<ChevronDownIcon width={14} height={14} />
<ChevronDownIcon className="h-4 w-4" />
</div>
</div>
<button