update composer

This commit is contained in:
Ren Amamiya 2023-09-02 08:50:54 +07:00
parent 28939d1733
commit 1931373515
11 changed files with 475 additions and 318 deletions

View File

@ -34,7 +34,7 @@
"@tauri-apps/plugin-app": "github:tauri-apps/tauri-plugin-app#v2",
"@tauri-apps/plugin-autostart": "github:tauri-apps/tauri-plugin-autostart#v2",
"@tauri-apps/plugin-clipboard-manager": "github:tauri-apps/tauri-plugin-clipboard-manager#v2",
"@tauri-apps/plugin-dialog": "github:tauri-apps/tauri-plugin-dialog#v2",
"@tauri-apps/plugin-dialog": "2.0.0-alpha.0",
"@tauri-apps/plugin-fs": "github:tauri-apps/tauri-plugin-fs#v2",
"@tauri-apps/plugin-notification": "github:tauri-apps/tauri-plugin-notification#v2",
"@tauri-apps/plugin-os": "github:tauri-apps/tauri-plugin-os#v2",
@ -60,7 +60,7 @@
"light-bolt11-decoder": "^3.0.0",
"lru-cache": "^10.0.1",
"minidenticons": "^4.2.0",
"nostr-fetch": "^0.12.2",
"nostr-fetch": "^0.13.0",
"nostr-tools": "^1.14.2",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
@ -80,12 +80,12 @@
"@tailwindcss/typography": "^0.5.9",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/html-to-text": "^9.0.1",
"@types/node": "^20.5.6",
"@types/node": "^20.5.8",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/youtube-player": "^5.5.7",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.15",
"clsx": "^2.0.0",
@ -99,9 +99,9 @@
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"postcss": "^8.4.28",
"prettier": "^3.0.2",
"prettier-plugin-tailwindcss": "^0.5.3",
"postcss": "^8.4.29",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.4",
"prop-types": "^15.8.1",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",

File diff suppressed because it is too large Load Diff

108
src-tauri/Cargo.lock generated
View File

@ -88,9 +88,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783"
dependencies = [
"memchr",
]
@ -187,9 +187,9 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "arboard"
version = "3.2.0"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854"
checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc"
dependencies = [
"clipboard-win",
"core-graphics 0.22.3",
@ -198,7 +198,6 @@ dependencies = [
"objc",
"objc-foundation",
"objc_id",
"once_cell",
"parking_lot",
"thiserror",
"winapi",
@ -313,9 +312,9 @@ dependencies = [
[[package]]
name = "async-recursion"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba"
checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
dependencies = [
"proc-macro2",
"quote",
@ -730,15 +729,15 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.26"
version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f"
dependencies = [
"android-tzdata",
"iana-time-zone",
"num-traits",
"serde",
"winapi",
"windows-targets 0.48.5",
]
[[package]]
@ -762,20 +761,19 @@ dependencies = [
[[package]]
name = "clap"
version = "4.4.0"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d"
checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6"
dependencies = [
"clap_builder",
"clap_derive",
"once_cell",
]
[[package]]
name = "clap_builder"
version = "4.4.0"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6"
checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08"
dependencies = [
"anstream",
"anstyle",
@ -785,9 +783,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.4.0"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a"
checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
dependencies = [
"heck",
"proc-macro2",
@ -1407,9 +1405,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
@ -1475,7 +1473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5"
dependencies = [
"cfg-if",
"rustix 0.38.9",
"rustix 0.38.11",
"windows-sys 0.48.0",
]
@ -2084,9 +2082,9 @@ dependencies = [
[[package]]
name = "hashlink"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [
"hashbrown 0.14.0",
]
@ -2772,9 +2770,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e"
[[package]]
name = "memoffset"
@ -2844,9 +2842,9 @@ dependencies = [
[[package]]
name = "muda"
version = "0.8.5"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb28807bbe07d97a5bc148a79c730cb7a8dc373f354969e5b442c711adf61ccf"
checksum = "41fe753ec4d3e8137a1d3ecb1aee1192b8f7661fe1247641968f5bf5f2e6ebbe"
dependencies = [
"cocoa 0.25.0",
"crossbeam-channel",
@ -2932,11 +2930,11 @@ dependencies = [
[[package]]
name = "nix"
version = "0.26.3"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abbbc55ad7b13aac85f9401c796dcda1b864e07fcad40ad47792eaa8932ea502"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags 2.4.0",
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset 0.7.1",
@ -3971,9 +3969,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.9"
version = "0.38.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49"
checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453"
dependencies = [
"bitflags 2.4.0",
"errno",
@ -3984,9 +3982,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.21.6"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb"
checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8"
dependencies = [
"ring",
"rustls-webpki",
@ -5053,7 +5051,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-app"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"tauri",
]
@ -5061,7 +5059,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-autostart"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"auto-launch",
"log",
@ -5074,7 +5072,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-clipboard-manager"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"arboard",
"log",
@ -5088,7 +5086,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-dialog"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"glib",
"log",
@ -5105,7 +5103,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-fs"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"anyhow",
"glob",
@ -5118,7 +5116,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-http"
version = "2.0.0-alpha.2"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"data-url",
"glob",
@ -5135,7 +5133,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-notification"
version = "2.0.0-alpha.2"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"log",
"notify-rust",
@ -5153,7 +5151,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-os"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"gethostname 0.4.3",
"log",
@ -5169,7 +5167,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-process"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"tauri",
]
@ -5177,7 +5175,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-shell"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"encoding_rs",
"log",
@ -5194,7 +5192,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-single-instance"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"log",
"serde",
@ -5208,7 +5206,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-sql"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"futures-core",
"log",
@ -5224,7 +5222,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-store"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"log",
"serde",
@ -5236,7 +5234,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-stronghold"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"hex",
"iota-crypto 0.23.0",
@ -5252,7 +5250,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-updater"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"base64 0.21.3",
"dirs-next",
@ -5277,7 +5275,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-upload"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"futures-util",
"log",
@ -5294,7 +5292,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-window"
version = "2.0.0-alpha.1"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#ef1ce3f62a2811d30f15c4333afcddd57b3aca84"
source = "git+https://github.com/luminous-devs/plugins-workspace?branch=v2#69a5c1370b027b3246435348a592e2f1a7b931f2"
dependencies = [
"serde",
"tauri",
@ -5426,7 +5424,7 @@ dependencies = [
"cfg-if",
"fastrand 2.0.0",
"redox_syscall 0.3.5",
"rustix 0.38.9",
"rustix 0.38.11",
"windows-sys 0.48.0",
]
@ -5794,9 +5792,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "url"
version = "2.4.0"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5"
dependencies = [
"form_urlencoded",
"idna",
@ -6567,7 +6565,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd"
dependencies = [
"nix 0.26.3",
"nix 0.26.4",
"winapi",
]
@ -6595,7 +6593,7 @@ dependencies = [
"futures-sink",
"futures-util",
"hex",
"nix 0.26.3",
"nix 0.26.4",
"once_cell",
"ordered-stream",
"rand 0.8.5",

View File

@ -11,7 +11,7 @@ import { useNostr } from '@utils/hooks/useNostr';
export function SplashScreen() {
const { db } = useStorage();
const { ndk, relayUrls } = useNDK();
const { ndk } = useNDK();
const { fetchUserData, prefetchEvents } = useNostr();
const [isLoading, setIsLoading] = useState<boolean>(true);
@ -68,9 +68,7 @@ export function SplashScreen() {
{isLoading ? (
<div className="flex flex-col gap-1 text-center">
<h3 className="text-lg font-semibold leading-none text-white">
{!ndk
? 'Connecting to relay...'
: `Connected to ${relayUrls.length} relays`}
{!ndk ? 'Connecting to relay...' : 'Fetching events from the last login.'}
</h3>
<p className="text-sm text-white/50">
This may take a few seconds, please don&apos;t close app.

View File

@ -1,3 +1,4 @@
import { message } from '@tauri-apps/plugin-dialog';
import Image from '@tiptap/extension-image';
import Mention from '@tiptap/extension-mention';
import Placeholder from '@tiptap/extension-placeholder';
@ -9,24 +10,21 @@ import { useState } from 'react';
import { twMerge } from 'tailwind-merge';
import { Suggestion } from '@shared/composer';
import { CancelIcon, LoaderIcon, PlusCircleIcon } from '@shared/icons';
import { CancelIcon, LoaderIcon, MediaIcon, MentionIcon } from '@shared/icons';
import { MentionNote } from '@shared/notes';
import { useComposer } from '@stores/composer';
import { useNostr } from '@utils/hooks/useNostr';
import { useImageUploader } from '@utils/hooks/useUploader';
import { sendNativeNotification } from '@utils/notification';
export function Composer() {
const { publish } = useNostr();
const [status, setStatus] = useState<null | 'loading' | 'done'>(null);
const [loading, setLoading] = useState<boolean>(false);
const [reply, clearReply] = useComposer((state) => [state.reply, state.clearReply]);
const expand = useComposer((state) => state.expand)
const upload = useImageUploader();
const { publish, upload } = useNostr();
const expand = useComposer((state) => state.expand);
const editor = useEditor({
extensions: [
StarterKit.configure({
@ -65,9 +63,9 @@ export function Composer() {
};
const submit = async () => {
setStatus('loading');
try {
setLoading(true);
// get plaintext content
const html = editor.getHTML();
const serializedContent = convert(html, {
@ -108,18 +106,19 @@ export function Composer() {
await publish({ content: serializedContent, kind: 1, tags });
// send native notifiation
await sendNativeNotification('Publish post successfully');
await sendNativeNotification('Post has been published successfully.');
// update state
setStatus('done');
setLoading(false);
// reset editor
editor.commands.clearContent();
// reset reply
if (reply.id) {
clearReply();
}
} catch {
setStatus(null);
console.log('failed to publish');
setLoading(false);
await message('Publishing post failed.', { title: 'Lume', type: 'error' });
}
};
@ -136,7 +135,10 @@ export function Composer() {
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
className={twMerge('scrollbar-hide markdown break-all max-h-[500px] overflow-y-auto outline-none pr-2', expand ? 'min-h-[500px]' : 'min-h-[120px]')}
className={twMerge(
'scrollbar-hide markdown max-h-[500px] overflow-y-auto break-all pr-2 outline-none',
expand ? 'min-h-[500px]' : 'min-h-[120px]'
)}
/>
{reply.id && (
<div className="relative">
@ -152,17 +154,31 @@ export function Composer() {
)}
</div>
</div>
<div className="flex items-center justify-between bg-white/5 rounded-b-xl p-2 border-t border-white/10">
<div className="flex items-center justify-between rounded-b-xl border-t border-white/10 bg-white/5 p-2">
<div className="inline-flex items-center gap-1">
<button
type="button"
onClick={() => uploadImage()}
className="ml-2 inline-flex h-10 w-max items-center justify-center gap-1.5 rounded-lg px-2 text-sm font-medium text-white/80 hover:bg-white/10 hover:backdrop-blur-xl"
>
<MediaIcon className="h-5 w-5 text-white/80" />
Add media
</button>
<button
type="button"
onClick={() => uploadImage()}
className="inline-flex h-10 w-10 items-center justify-center rounded-lg hover:bg-white/10 hover:backdrop-blur-xl"
>
<MentionIcon className="h-5 w-5 text-white/80" />
</button>
</div>
<button
type="button"
onClick={() => uploadImage()}
className="ml-2 inline-flex h-10 w-10 items-center justify-center rounded-lg backdrop-blur-xl hover:bg-white/10"
onClick={() => submit()}
disabled={editor && editor.isEmpty}
className="inline-flex h-10 w-20 items-center justify-center rounded-lg bg-fuchsia-500 px-2 font-semibold hover:bg-fuchsia-600 disabled:opacity-50"
>
<PlusCircleIcon className="h-5 w-5 text-white" />
</button>
<button onClick={() => submit()} className="inline-flex items-center justify-center w-max px-8 rounded-lg font-bold h-10 bg-fuchsia-500 hover:bg-fuchsia-600">
{status === 'loading' ? (
<LoaderIcon className="h-4 w-4 animate-spin text-white" />
{loading === true ? (
<LoaderIcon className="h-5 w-5 animate-spin text-white" />
) : (
'Post'
)}

View File

@ -0,0 +1,7 @@
export function MentionPopup() {
return (
<div>
<p>TODO</p>
</div>
);
}

View File

@ -57,3 +57,4 @@ export * from './focus';
export * from './chevronUp';
export * from './secure';
export * from './verified';
export * from './mention';

View File

@ -0,0 +1,22 @@
import { SVGProps } from 'react';
export function MentionIcon(props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="none"
viewBox="0 0 24 24"
{...props}
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
d="M11.85 13.251c-3.719.065-6.427 2.567-7.18 5.915-.13.575.338 1.084.927 1.084h6.901m-.647-6.999l.147-.001c.353 0 .696.022 1.03.064m-1.177-.063a7.889 7.889 0 00-1.852.249m3.028-.186c.334.042.658.104.972.186m-.972-.186a7.475 7.475 0 011.972.524m3.25 1.412v3m0 0v3m0-3h-3m3 0h3m-5.5-11.75a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"
></path>
</svg>
);
}

View File

@ -28,7 +28,7 @@ export function LocalNetworkWidget() {
useInfiniteQuery({
queryKey: ['local-network-widget'],
queryFn: async ({ pageParam = 0 }) => {
return await db.getAllEvents(30, pageParam);
return await db.getAllEvents(20, pageParam);
},
getNextPageParam: (lastPage) => lastPage.nextCursor,
});

View File

@ -1,3 +1,4 @@
import { magnetDecode } from '@ctrl/magnet-link';
import {
NDKEvent,
NDKFilter,
@ -7,6 +8,8 @@ import {
NDKUser,
} from '@nostr-dev-kit/ndk';
import { ndkAdapter } from '@nostr-fetch/adapter-ndk';
import { message, open } from '@tauri-apps/plugin-dialog';
import { VoidApi } from '@void-cat/api';
import { LRUCache } from 'lru-cache';
import { NostrFetcher } from 'nostr-fetch';
import { nip19 } from 'nostr-tools';
@ -17,6 +20,7 @@ import { useStorage } from '@libs/storage/provider';
import { useStronghold } from '@stores/stronghold';
import { createBlobFromFile } from '@utils/createBlobFromFile';
import { nHoursAgo } from '@utils/date';
import { NDKEventWithReplies } from '@utils/types';
@ -324,6 +328,91 @@ export function useNostr() {
return res;
};
const upload = async (file: null | string, nip94?: boolean) => {
try {
const voidcat = new VoidApi('https://void.cat');
let filepath = file;
if (!file) {
const selected = await open({
multiple: false,
filters: [
{
name: 'Media',
extensions: [
'png',
'jpeg',
'jpg',
'gif',
'mp4',
'mp3',
'webm',
'mkv',
'avi',
'mov',
],
},
],
});
if (Array.isArray(selected)) {
// user selected multiple files
} else if (selected === null) {
return {
url: null,
error: 'Cancelled',
};
} else {
filepath = selected.path;
}
}
const filename = filepath.split('/').pop();
const filetype = filename.split('.').pop();
const blob = await createBlobFromFile(filepath);
const uploader = voidcat.getUploader(blob);
// upload file
const res = await uploader.upload();
if (res.ok) {
const url =
res.file?.metadata?.url ?? `https://void.cat/d/${res.file?.id}.${filetype}`;
if (nip94) {
const tags = [
['url', url],
['x', res.file?.metadata?.digest ?? ''],
['m', res.file?.metadata?.mimeType ?? 'application/octet-stream'],
['size', res.file?.metadata?.size.toString() ?? '0'],
];
if (res.file?.metadata?.magnetLink) {
tags.push(['magnet', res.file.metadata.magnetLink]);
const parsedMagnet = magnetDecode(res.file.metadata.magnetLink);
if (parsedMagnet?.infoHash) {
tags.push(['i', parsedMagnet?.infoHash]);
}
}
await publish({ content: '', kind: 1063, tags: tags });
}
return {
url: url,
error: null,
};
}
return {
url: null,
error: 'Upload failed',
};
} catch (e) {
await message(e, { title: 'Lume', type: 'error' });
}
};
return {
sub,
fetchUserData,
@ -336,5 +425,6 @@ export function useNostr() {
fetchAllReplies,
publish,
createZap,
upload,
};
}

View File

@ -18,7 +18,18 @@ export function useImageUploader() {
filters: [
{
name: 'Image',
extensions: ['png', 'jpeg', 'jpg', 'gif'],
extensions: [
'png',
'jpeg',
'jpg',
'gif',
'mp4',
'mp3',
'webm',
'mkv',
'avi',
'mov',
],
},
],
});