diff --git a/src/app/chats/components/unknowns.tsx b/src/app/chats/components/unknowns.tsx index f51ced55..25d9e934 100644 --- a/src/app/chats/components/unknowns.tsx +++ b/src/app/chats/components/unknowns.tsx @@ -91,7 +91,7 @@ export function UnknownsModal({ data }: { data: Chats[] }) {
{data.map((user) => (
diff --git a/src/app/space/components/add.tsx b/src/app/space/components/add.tsx index 861bbc78..557e3628 100644 --- a/src/app/space/components/add.tsx +++ b/src/app/space/components/add.tsx @@ -1,4 +1,5 @@ import { AddFeedBlock } from '@app/space/components/addFeed'; +import { AddHashTagBlock } from '@app/space/components/addHashtag'; import { AddImageBlock } from '@app/space/components/addImage'; export function AddBlock() { @@ -6,6 +7,7 @@ export function AddBlock() {
+
); } diff --git a/src/app/space/components/addFeed.tsx b/src/app/space/components/addFeed.tsx index aa221100..62073538 100644 --- a/src/app/space/components/addFeed.tsx +++ b/src/app/space/components/addFeed.tsx @@ -81,7 +81,7 @@ export function AddFeedBlock() { + + + +
+ +
+ + +
+
+
+ + Create hashtag block + + +
+ + Pin the hashtag you want to keep follow up + +
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + ); +} diff --git a/src/app/space/components/addImage.tsx b/src/app/space/components/addImage.tsx index 4a25931b..06967381 100644 --- a/src/app/space/components/addImage.tsx +++ b/src/app/space/components/addImage.tsx @@ -1,24 +1,24 @@ import { Dialog, Transition } from '@headlessui/react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { open } from '@tauri-apps/api/dialog'; -import { Body, fetch } from '@tauri-apps/api/http'; import { Fragment, useEffect, useRef, useState } from 'react'; import { useForm } from 'react-hook-form'; import { useHotkeys } from 'react-hotkeys-hook'; import { createBlock } from '@libs/storage'; -import { CancelIcon, CommandIcon } from '@shared/icons'; +import { CancelIcon, CommandIcon, LoaderIcon } from '@shared/icons'; import { Image } from '@shared/image'; import { BLOCK_KINDS, DEFAULT_AVATAR } from '@stores/constants'; import { ADD_IMAGEBLOCK_SHORTCUT } from '@stores/shortcuts'; -import { createBlobFromFile } from '@utils/createBlobFromFile'; import { usePublish } from '@utils/hooks/usePublish'; +import { useImageUploader } from '@utils/hooks/useUploader'; export function AddImageBlock() { const queryClient = useQueryClient(); + const upload = useImageUploader(); + const { publish } = usePublish(); const [loading, setLoading] = useState(false); @@ -45,54 +45,6 @@ export function AddImageBlock() { formState: { isDirty, isValid }, } = useForm(); - const openFileDialog = async () => { - const selected: any = await open({ - multiple: false, - filters: [ - { - name: 'Image', - extensions: ['png', 'jpeg', 'jpg'], - }, - ], - }); - - if (Array.isArray(selected)) { - // user selected multiple files - } else if (selected === null) { - // user cancelled the selection - } else { - const filename = selected.split('/').pop(); - const file = await createBlobFromFile(selected); - const buf = await file.arrayBuffer(); - - const res: any = await fetch('https://void.cat/upload?cli=false', { - method: 'POST', - timeout: 5, - headers: { - accept: '*/*', - 'Content-Type': 'application/octet-stream', - 'V-Filename': filename, - 'V-Description': 'Upload from https://lume.nu', - 'V-Strip-Metadata': 'true', - }, - body: Body.bytes(buf), - }); - - if (res.ok) { - const imageURL = `https://void.cat/d/${res.data.file.id}.webp`; - tags.current = [ - ['url', imageURL], - ['m', res.data.file.metadata.mimeType], - ['x', res.data.file.metadata.digest], - ['size', res.data.file.metadata.size], - ['magnet', res.data.file.metadata.magnetLink], - ]; - - setImage(imageURL); - } - } - }; - const block = useMutation({ mutationFn: (data: { kind: number; title: string; content: string }) => { return createBlock(data.kind, data.title, data.content); @@ -102,6 +54,13 @@ export function AddImageBlock() { }, }); + const uploadImage = async () => { + const image = await upload(null); + if (image.url) { + setImage(image.url); + } + }; + const onSubmit = async (data: { kind: number; title: string; content: string }) => { setLoading(true); @@ -127,7 +86,7 @@ export function AddImageBlock() {