diff --git a/package.json b/package.json index b45805a9..f2bd4946 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@tanstack/react-query": "^4.29.15", "@tanstack/react-virtual": "3.0.0-beta.54", "@tauri-apps/api": "^1.4.0", + "cheerio": "1.0.0-rc.12", "dayjs": "^1.11.8", "destr": "^1.2.2", "framer-motion": "^10.12.17", @@ -30,6 +31,7 @@ "react-dom": "^18.2.0", "react-hook-form": "^7.45.0", "react-hotkeys-hook": "^4.4.0", + "react-player": "^2.12.0", "react-resizable-panels": "^0.0.48", "react-router-dom": "^6.14.0", "react-string-replace": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 692ef724..8652de15 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,9 @@ dependencies: '@tauri-apps/api': specifier: ^1.4.0 version: 1.4.0 + cheerio: + specifier: 1.0.0-rc.12 + version: 1.0.0-rc.12 dayjs: specifier: ^1.11.8 version: 1.11.8 @@ -52,6 +55,9 @@ dependencies: react-hotkeys-hook: specifier: ^4.4.0 version: 4.4.0(react-dom@18.2.0)(react@18.2.0) + react-player: + specifier: ^2.12.0 + version: 2.12.0(react@18.2.0) react-resizable-panels: specifier: ^0.0.48 version: 0.0.48(react-dom@18.2.0)(react@18.2.0) @@ -1399,6 +1405,10 @@ packages: engines: {node: '>=8'} dev: true + /boolbase@1.0.0: + resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} + dev: false + /brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} dependencies: @@ -1511,6 +1521,30 @@ packages: engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} dev: true + /cheerio-select@2.1.0: + resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} + dependencies: + boolbase: 1.0.0 + css-select: 5.1.0 + css-what: 6.1.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + dev: false + + /cheerio@1.0.0-rc.12: + resolution: {integrity: sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==} + engines: {node: '>= 6'} + dependencies: + cheerio-select: 2.1.0 + dom-serializer: 2.0.0 + domhandler: 5.0.3 + domutils: 3.1.0 + htmlparser2: 8.0.2 + parse5: 7.1.2 + parse5-htmlparser2-tree-adapter: 7.0.0 + dev: false + /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -1645,6 +1679,21 @@ packages: shebang-command: 2.0.0 which: 2.0.2 + /css-select@5.1.0: + resolution: {integrity: sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==} + dependencies: + boolbase: 1.0.0 + css-what: 6.1.0 + domhandler: 5.0.3 + domutils: 3.1.0 + nth-check: 2.1.1 + dev: false + + /css-what@6.1.0: + resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} + engines: {node: '>= 6'} + dev: false + /cssesc@3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} engines: {node: '>=4'} @@ -1721,6 +1770,11 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: false + /deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + dev: false + /define-properties@1.2.0: resolution: {integrity: sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==} engines: {node: '>= 0.4'} @@ -1781,6 +1835,33 @@ packages: esutils: 2.0.3 dev: false + /dom-serializer@2.0.0: + resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==} + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + entities: 4.5.0 + dev: false + + /domelementtype@2.3.0: + resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==} + dev: false + + /domhandler@5.0.3: + resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} + engines: {node: '>= 4'} + dependencies: + domelementtype: 2.3.0 + dev: false + + /domutils@3.1.0: + resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==} + dependencies: + dom-serializer: 2.0.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + dev: false + /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} @@ -1799,6 +1880,11 @@ packages: dependencies: iconv-lite: 0.6.3 + /entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} + dev: false + /env-paths@2.2.1: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} engines: {node: '>=6'} @@ -2560,6 +2646,15 @@ packages: lru-cache: 6.0.0 dev: false + /htmlparser2@8.0.2: + resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.1.0 + entities: 4.5.0 + dev: false + /http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} dev: false @@ -2986,6 +3081,10 @@ packages: strip-bom: 3.0.0 dev: false + /load-script@1.0.0: + resolution: {integrity: sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA==} + dev: false + /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -3107,6 +3206,10 @@ packages: engines: {node: '>=16'} dev: false + /memoize-one@5.2.1: + resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==} + dev: false + /memorystream@0.3.1: resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} engines: {node: '>= 0.10.0'} @@ -3428,10 +3531,15 @@ packages: set-blocking: 2.0.0 dev: false + /nth-check@2.1.1: + resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} + dependencies: + boolbase: 1.0.0 + dev: false + /object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} - dev: true /object-hash@3.0.0: resolution: {integrity: sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==} @@ -3560,6 +3668,19 @@ packages: lines-and-columns: 1.2.4 dev: false + /parse5-htmlparser2-tree-adapter@7.0.0: + resolution: {integrity: sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==} + dependencies: + domhandler: 5.0.3 + parse5: 7.1.2 + dev: false + + /parse5@7.1.2: + resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} + dependencies: + entities: 4.5.0 + dev: false + /path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -3754,7 +3875,6 @@ packages: loose-envify: 1.4.0 object-assign: 4.1.1 react-is: 16.13.1 - dev: true /punycode@2.3.0: resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} @@ -3790,6 +3910,10 @@ packages: scheduler: 0.23.0 dev: false + /react-fast-compare@3.2.2: + resolution: {integrity: sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==} + dev: false + /react-hook-form@7.45.0(react@18.2.0): resolution: {integrity: sha512-AbHeZ4ad+0dEIknSW9dBgIwcvRDfZ1O97sgj75WaMdOX0eg8TBiUf9wxzVkIjZbk76BBIE9lmFOzyD4PN80ZQg==} engines: {node: '>=12.22.0'} @@ -3811,12 +3935,24 @@ packages: /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} - dev: true /react-is@18.2.0: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: false + /react-player@2.12.0(react@18.2.0): + resolution: {integrity: sha512-rymLRz/2GJJD+Wc01S7S+i9pGMFYnNmQibR2gVE3KmHJCBNN8BhPAlOPTGZtn1uKpJ6p4RPLlzPQ1OLreXd8gw==} + peerDependencies: + react: '>=16.6.0' + dependencies: + deepmerge: 4.3.1 + load-script: 1.0.0 + memoize-one: 5.2.1 + prop-types: 15.8.1 + react: 18.2.0 + react-fast-compare: 3.2.2 + dev: false + /react-resizable-panels@0.0.48(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-fJa3itmJ3HLLmVG7y8tka80wFW63N6ai76q7MGwU8nSXeA0qkX36vnmPyXm34lvtsGjn1Cgi5IPhPQnf42SVpA==} peerDependencies: @@ -3981,8 +4117,8 @@ packages: glob: 7.2.3 dev: false - /rollup@3.25.1: - resolution: {integrity: sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==} + /rollup@3.25.2: + resolution: {integrity: sha512-VLnkxZMDr3jpxgtmS8pQZ0UvhslmF4ADq/9w4erkctbgjCqLW9oa89fJuXEs4ZmgyoF7Dm8rMDKSS5b5u2hHUg==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -4753,7 +4889,7 @@ packages: '@types/node': 18.16.18 esbuild: 0.17.19 postcss: 8.4.24 - rollup: 3.25.1 + rollup: 3.25.2 optionalDependencies: fsevents: 2.3.2 dev: true diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5ffdbd74..a324e39b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -22,11 +22,7 @@ "http": { "all": true, "request": true, - "scope": [ - "https://void.cat/*", - "https://skrape.dev/*", - "https://lume.nu/*" - ] + "scope": ["http://**", "https://**"] }, "fs": { "all": false, diff --git a/src/app/auth/create/step-1.tsx b/src/app/auth/create/step-1.tsx index 7660929a..cecbab7f 100644 --- a/src/app/auth/create/step-1.tsx +++ b/src/app/auth/create/step-1.tsx @@ -1,4 +1,4 @@ -import { createAccount } from "@libs/storage"; +import { createAccount, createBlock } from "@libs/storage"; import { Button } from "@shared/button"; import { EyeOffIcon, EyeOnIcon } from "@shared/icons"; import { useMutation, useQueryClient } from "@tanstack/react-query"; @@ -30,6 +30,11 @@ export function CreateStep1Screen() { mutationFn: (data: any) => createAccount(data.npub, data.pubkey, data.privkey, null, 1), onSuccess: () => { + createBlock( + 0, + "Preserve your freedom", + "https://void.cat/d/949GNg7ZjSLHm2eTR3jZqv", + ); queryClient.invalidateQueries({ queryKey: ["currentAccount"] }); // redirect to next step navigate("/auth/create/step-2", { replace: true }); diff --git a/src/app/auth/create/step-3.tsx b/src/app/auth/create/step-3.tsx index ba5ab392..e811f879 100644 --- a/src/app/auth/create/step-3.tsx +++ b/src/app/auth/create/step-3.tsx @@ -6,10 +6,13 @@ import { useOnboarding } from "@stores/onboarding"; import { Body, fetch } from "@tauri-apps/api/http"; import { useAccount } from "@utils/hooks/useAccount"; import { useContext, useState } from "react"; +import { useNavigate } from "react-router-dom"; export function CreateStep3Screen() { const ndk = useContext(RelayContext); const profile = useOnboarding((state: any) => state.profile); + const navigate = useNavigate(); + const { account } = useAccount(); const [username, setUsername] = useState(""); @@ -48,6 +51,7 @@ export function CreateStep3Screen() { event.publish(); // redirect to step 4 + navigate("/auth/create/step-4", { replace: true }); } } catch (error) { setLoading(false); diff --git a/src/app/auth/create/step-4.tsx b/src/app/auth/create/step-4.tsx index d45cefb9..fde3aa3e 100644 --- a/src/app/auth/create/step-4.tsx +++ b/src/app/auth/create/step-4.tsx @@ -131,8 +131,6 @@ export function CreateStep4Screen() { updateAccount("follows", follows, account.pubkey), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["currentAccount"] }); - // redirect to next step - navigate("/auth/onboarding", { replace: true }); }, }); @@ -156,6 +154,9 @@ export function CreateStep4Screen() { // update update.mutate(follows); + + // redirect to next step + setTimeout(() => navigate("/auth/onboarding", { replace: true }), 1200); } catch { console.log("error"); } diff --git a/src/app/auth/import/step-1.tsx b/src/app/auth/import/step-1.tsx index ac0eb2cb..b3c5a955 100644 --- a/src/app/auth/import/step-1.tsx +++ b/src/app/auth/import/step-1.tsx @@ -1,4 +1,4 @@ -import { createAccount } from "@libs/storage"; +import { createAccount, createBlock } from "@libs/storage"; import { LoaderIcon } from "@shared/icons"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { getPublicKey, nip19 } from "nostr-tools"; @@ -31,6 +31,11 @@ export function ImportStep1Screen() { mutationFn: (data: any) => createAccount(data.npub, data.pubkey, data.privkey, null, 1), onSuccess: () => { + createBlock( + 0, + "Preserve your freedom", + "https://void.cat/d/949GNg7ZjSLHm2eTR3jZqv", + ); queryClient.invalidateQueries({ queryKey: ["currentAccount"] }); // redirect to next step navigate("/auth/import/step-2", { replace: true }); diff --git a/src/app/auth/onboarding.tsx b/src/app/auth/onboarding.tsx index 357e8835..f4805c6b 100644 --- a/src/app/auth/onboarding.tsx +++ b/src/app/auth/onboarding.tsx @@ -1,10 +1,11 @@ import { NDKEvent, NDKPrivateKeySigner } from "@nostr-dev-kit/ndk"; +import { LoaderIcon } from "@shared/icons"; import { ArrowRightCircleIcon } from "@shared/icons/arrowRightCircle"; import { RelayContext } from "@shared/relayProvider"; import { User } from "@shared/user"; import { dateToUnix } from "@utils/date"; import { useAccount } from "@utils/hooks/useAccount"; -import { useContext } from "react"; +import { useContext, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; export function OnboardingScreen() { @@ -12,9 +13,12 @@ export function OnboardingScreen() { const navigate = useNavigate(); const { status, account } = useAccount(); + const [loading, setLoading] = useState(false); const publish = async () => { try { + setLoading(true); + const event = new NDKEvent(ndk); const signer = new NDKPrivateKeySigner(account.privkey); ndk.signer = signer; @@ -30,7 +34,7 @@ export function OnboardingScreen() { event.publish(); // redirect to home - navigate("/", { replace: true }); + setTimeout(() => navigate("/", { replace: true }), 1200); } catch (error) { console.log(error); } @@ -80,9 +84,15 @@ export function OnboardingScreen() { onClick={() => publish()} className="inline-flex h-12 w-full items-center justify-between gap-2 rounded-lg px-6 font-medium text-zinc-100 bg-fuchsia-500 hover:bg-fuchsia-600" > - - Publish - + {loading ? ( + + ) : ( + <> + + Publish + + + )}
twMerge( "inline-flex h-9 items-center gap-2.5 rounded-md px-2.5", diff --git a/src/app/channel/components/messages/hideButton.tsx b/src/app/channel/components/messages/hideButton.tsx index 24481f94..601b7cc9 100644 --- a/src/app/channel/components/messages/hideButton.tsx +++ b/src/app/channel/components/messages/hideButton.tsx @@ -3,18 +3,19 @@ import { NDKEvent, NDKPrivateKeySigner } from "@nostr-dev-kit/ndk"; import { CancelIcon, HideIcon } from "@shared/icons"; import { RelayContext } from "@shared/relayProvider"; import { Tooltip } from "@shared/tooltip"; -import { useActiveAccount } from "@stores/accounts"; import { useChannelMessages } from "@stores/channels"; import { dateToUnix } from "@utils/date"; +import { useAccount } from "@utils/hooks/useAccount"; import { Fragment, useContext, useState } from "react"; export function MessageHideButton({ id }: { id: string }) { const ndk = useContext(RelayContext); - const account = useActiveAccount((state: any) => state.account); const hide = useChannelMessages((state: any) => state.hideMessage); const [isOpen, setIsOpen] = useState(false); + const { account } = useAccount(); + const closeModal = () => { setIsOpen(false); }; diff --git a/src/app/channel/components/messages/item.tsx b/src/app/channel/components/messages/item.tsx index a8d4fb7d..0d1c321c 100644 --- a/src/app/channel/components/messages/item.tsx +++ b/src/app/channel/components/messages/item.tsx @@ -15,7 +15,7 @@ export function ChannelMessageItem({ data }: { data: LumeEvent }) { return (
- +

{content.parsed} diff --git a/src/app/channel/components/messages/muteButton.tsx b/src/app/channel/components/messages/muteButton.tsx index 1eea6659..625cdb52 100644 --- a/src/app/channel/components/messages/muteButton.tsx +++ b/src/app/channel/components/messages/muteButton.tsx @@ -3,18 +3,19 @@ import { NDKEvent, NDKPrivateKeySigner } from "@nostr-dev-kit/ndk"; import { CancelIcon, MuteIcon } from "@shared/icons"; import { RelayContext } from "@shared/relayProvider"; import { Tooltip } from "@shared/tooltip"; -import { useActiveAccount } from "@stores/accounts"; import { useChannelMessages } from "@stores/channels"; import { dateToUnix } from "@utils/date"; +import { useAccount } from "@utils/hooks/useAccount"; import { Fragment, useContext, useState } from "react"; export function MessageMuteButton({ pubkey }: { pubkey: string }) { const ndk = useContext(RelayContext); - const account = useActiveAccount((state: any) => state.account); const mute = useChannelMessages((state: any) => state.muteUser); const [isOpen, setIsOpen] = useState(false); + const { account } = useAccount(); + const closeModal = () => { setIsOpen(false); }; diff --git a/src/app/channel/index.tsx b/src/app/channel/index.tsx index e2e6699f..85d5e598 100644 --- a/src/app/channel/index.tsx +++ b/src/app/channel/index.tsx @@ -109,29 +109,31 @@ export function ChannelScreen() { >

Public Channel

-
-
- {!messages ? ( -

Loading...

- ) : ( - Header, - EmptyPlaceholder: () => Empty, - }} - /> - )} -
+
+
+
+ {!messages ? ( +

Loading...

+ ) : ( + Header, + EmptyPlaceholder: () => Empty, + }} + /> + )} +
+
diff --git a/src/app/chat/components/item.tsx b/src/app/chat/components/item.tsx index 227fc330..f6022844 100644 --- a/src/app/chat/components/item.tsx +++ b/src/app/chat/components/item.tsx @@ -20,6 +20,7 @@ export function ChatsListItem({ data }: { data: any }) { ) : ( twMerge( "inline-flex h-9 items-center gap-2.5 rounded-md px-2.5", diff --git a/src/app/chat/components/messages/item.tsx b/src/app/chat/components/messages/item.tsx index 28486635..e99a4c64 100644 --- a/src/app/chat/components/messages/item.tsx +++ b/src/app/chat/components/messages/item.tsx @@ -26,7 +26,11 @@ export function ChatMessageItem({ return (
- +

{content.parsed} diff --git a/src/app/chat/components/modal.tsx b/src/app/chat/components/modal.tsx index 1aac7b76..ee4fcfa8 100644 --- a/src/app/chat/components/modal.tsx +++ b/src/app/chat/components/modal.tsx @@ -94,7 +94,7 @@ export function NewMessageModal() {

-
+
{status === "loading" || isFetching ? (

Loading...

) : ( diff --git a/src/app/chat/components/self.tsx b/src/app/chat/components/self.tsx index 2aff0685..480855c5 100644 --- a/src/app/chat/components/self.tsx +++ b/src/app/chat/components/self.tsx @@ -20,6 +20,7 @@ export function ChatsListSelfItem({ data }: { data: any }) { ) : ( twMerge( "inline-flex h-9 items-center gap-2.5 rounded-md px-2.5", diff --git a/src/app/chat/index.tsx b/src/app/chat/index.tsx index f01d2318..f54358a2 100644 --- a/src/app/chat/index.tsx +++ b/src/app/chat/index.tsx @@ -52,39 +52,37 @@ export function ChatScreen() { >

Encrypted Chat

-
- {account && ( -
+
+
+
{status === "loading" ? (

Loading...

) : ( -
- Empty, - }} - /> -
- )} -
- Empty, + }} /> -
+ )}
- )} +
+ +
+
@@ -92,18 +90,16 @@ export function ChatScreen() { data-tauri-drag-region className="h-11 w-full shrink-0 inline-flex items-center justify-center border-b border-zinc-900" /> - {pubkey && } +
); } const Empty = ( -
-

- Nothing to see here yet -

-

+

+

🙌

+

You two didn't talk yet, let's send first message

diff --git a/src/app/root.tsx b/src/app/root.tsx index 2ddc0ca9..ebc57200 100644 --- a/src/app/root.tsx +++ b/src/app/root.tsx @@ -8,7 +8,7 @@ import { getLastLogin, } from "@libs/storage"; import { NDKFilter } from "@nostr-dev-kit/ndk"; -import { LumeIcon } from "@shared/icons"; +import { LoaderIcon, LumeIcon } from "@shared/icons"; import { RelayContext } from "@shared/relayProvider"; import { dateToUnix, getHourAgo } from "@utils/date"; import { useAccount } from "@utils/hooks/useAccount"; @@ -177,27 +177,7 @@ export function Root() {
- - Loading - - - +
diff --git a/src/app/space/components/addFeed.tsx b/src/app/space/components/addFeed.tsx index adfd7589..6ed79538 100644 --- a/src/app/space/components/addFeed.tsx +++ b/src/app/space/components/addFeed.tsx @@ -1,12 +1,15 @@ import { Dialog, Transition } from "@headlessui/react"; +import { createBlock } from "@libs/storage"; import { CancelIcon } from "@shared/icons"; -import { useActiveAccount } from "@stores/accounts"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { useAccount } from "@utils/hooks/useAccount"; import { nip19 } from "nostr-tools"; import { Fragment, useState } from "react"; import { useForm } from "react-hook-form"; export function AddFeedBlock({ parentState }: { parentState: any }) { - const addBlock = useActiveAccount((state: any) => state.addBlock); + const queryClient = useQueryClient(); + const { account } = useAccount(); const [loading, setLoading] = useState(false); const [isOpen, setIsOpen] = useState(true); @@ -18,6 +21,13 @@ export function AddFeedBlock({ parentState }: { parentState: any }) { parentState(false); }; + const block = useMutation({ + mutationFn: (data: any) => createBlock(data.kind, data.title, data.content), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["blocks"] }); + }, + }); + const { register, handleSubmit, @@ -35,7 +45,7 @@ export function AddFeedBlock({ parentState }: { parentState: any }) { } // insert to database - addBlock(1, data.title, pubkey); + block.mutate({ kind: 1, title: data.title, content: pubkey }); setTimeout(() => { setLoading(false); @@ -43,7 +53,7 @@ export function AddFeedBlock({ parentState }: { parentState: any }) { reset(); // close modal closeModal(); - }, 1000); + }, 1200); }; return ( @@ -70,7 +80,7 @@ export function AddFeedBlock({ parentState }: { parentState: any }) { leaveFrom="opacity-100 scale-100" leaveTo="opacity-0 scale-95" > - +
@@ -102,7 +112,7 @@ export function AddFeedBlock({ parentState }: { parentState: any }) {