mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-18 03:03:31 +00:00
wip: refactor
This commit is contained in:
parent
2d53019c10
commit
c05bb54976
30
package.json
30
package.json
@ -19,8 +19,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/magnet-link": "^3.1.2",
|
"@ctrl/magnet-link": "^3.1.2",
|
||||||
"@headlessui/react": "^1.7.16",
|
"@headlessui/react": "^1.7.16",
|
||||||
"@nostr-dev-kit/ndk": "^0.8.14",
|
"@nostr-dev-kit/ndk": "^0.8.17",
|
||||||
"@nostr-fetch/adapter-ndk": "^0.11.0",
|
"@nostr-fetch/adapter-ndk": "^0.12.2",
|
||||||
"@radix-ui/react-alert-dialog": "^1.0.4",
|
"@radix-ui/react-alert-dialog": "^1.0.4",
|
||||||
"@radix-ui/react-collapsible": "^1.0.3",
|
"@radix-ui/react-collapsible": "^1.0.3",
|
||||||
"@radix-ui/react-dialog": "^1.0.4",
|
"@radix-ui/react-dialog": "^1.0.4",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"@tanstack/react-query-devtools": "^4.32.6",
|
"@tanstack/react-query-devtools": "^4.32.6",
|
||||||
"@tanstack/react-virtual": "3.0.0-beta.54",
|
"@tanstack/react-virtual": "3.0.0-beta.54",
|
||||||
"@tauri-apps/api": "2.0.0-alpha.6",
|
"@tauri-apps/api": "2.0.0-alpha.6",
|
||||||
|
"@tauri-apps/cli": "2.0.0-alpha.11",
|
||||||
"@tauri-apps/plugin-app": "github:tauri-apps/tauri-plugin-app#v2",
|
"@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-autostart": "github:tauri-apps/tauri-plugin-autostart#v2",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "github:tauri-apps/tauri-plugin-clipboard-manager#v2",
|
"@tauri-apps/plugin-clipboard-manager": "github:tauri-apps/tauri-plugin-clipboard-manager#v2",
|
||||||
@ -44,7 +45,7 @@
|
|||||||
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
|
||||||
"@tauri-apps/plugin-stronghold": "github:tauri-apps/tauri-plugin-stronghold#v2",
|
"@tauri-apps/plugin-stronghold": "github:tauri-apps/tauri-plugin-stronghold#v2",
|
||||||
"@tauri-apps/plugin-upload": "github:tauri-apps/tauri-plugin-upload#v2",
|
"@tauri-apps/plugin-upload": "github:tauri-apps/tauri-plugin-upload#v2",
|
||||||
"@tauri-apps/plugin-window": "2.0.0-alpha.0",
|
"@tauri-apps/plugin-window": "github:tauri-apps/tauri-plugin-window#v2",
|
||||||
"@tiptap/extension-image": "^2.0.4",
|
"@tiptap/extension-image": "^2.0.4",
|
||||||
"@tiptap/extension-mention": "^2.0.4",
|
"@tiptap/extension-mention": "^2.0.4",
|
||||||
"@tiptap/extension-placeholder": "^2.0.4",
|
"@tiptap/extension-placeholder": "^2.0.4",
|
||||||
@ -54,8 +55,8 @@
|
|||||||
"@tiptap/suggestion": "^2.0.4",
|
"@tiptap/suggestion": "^2.0.4",
|
||||||
"@void-cat/api": "^1.0.7",
|
"@void-cat/api": "^1.0.7",
|
||||||
"dayjs": "^1.11.9",
|
"dayjs": "^1.11.9",
|
||||||
"destr": "^1.2.2",
|
"destr": "^2.0.1",
|
||||||
"get-urls": "^11.0.0",
|
"get-urls": "^12.1.0",
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"immer": "^10.0.2",
|
"immer": "^10.0.2",
|
||||||
"light-bolt11-decoder": "^3.0.0",
|
"light-bolt11-decoder": "^3.0.0",
|
||||||
@ -78,15 +79,14 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/typography": "^0.5.9",
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
"@tauri-apps/cli": "2.0.0-alpha.10",
|
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
||||||
"@types/html-to-text": "^9.0.1",
|
"@types/html-to-text": "^9.0.1",
|
||||||
"@types/node": "^18.17.5",
|
"@types/node": "^20.5.0",
|
||||||
"@types/react": "^18.2.20",
|
"@types/react": "^18.2.20",
|
||||||
"@types/react-dom": "^18.2.7",
|
"@types/react-dom": "^18.2.7",
|
||||||
"@types/youtube-player": "^5.5.7",
|
"@types/youtube-player": "^5.5.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^6.4.0",
|
||||||
"@vitejs/plugin-react-swc": "^3.3.2",
|
"@vitejs/plugin-react-swc": "^3.3.2",
|
||||||
"autoprefixer": "^10.4.15",
|
"autoprefixer": "^10.4.15",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
@ -94,19 +94,19 @@
|
|||||||
"csstype": "^3.1.2",
|
"csstype": "^3.1.2",
|
||||||
"encoding": "^0.1.13",
|
"encoding": "^0.1.13",
|
||||||
"eslint": "^8.47.0",
|
"eslint": "^8.47.0",
|
||||||
"eslint-config-prettier": "^8.10.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||||
"eslint-plugin-react": "^7.33.1",
|
"eslint-plugin-react": "^7.33.1",
|
||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^13.3.0",
|
"lint-staged": "^14.0.0",
|
||||||
"postcss": "^8.4.27",
|
"postcss": "^8.4.28",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.2",
|
||||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
"prettier-plugin-tailwindcss": "^0.5.3",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"tailwind-merge": "^1.14.0",
|
"tailwind-merge": "^1.14.0",
|
||||||
"tailwindcss": "^3.3.3",
|
"tailwindcss": "^3.3.3",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^5.1.6",
|
||||||
"vite": "^4.4.9",
|
"vite": "^4.4.9",
|
||||||
"vite-plugin-top-level-await": "^1.3.1",
|
"vite-plugin-top-level-await": "^1.3.1",
|
||||||
"vite-tsconfig-paths": "^4.2.0"
|
"vite-tsconfig-paths": "^4.2.0"
|
||||||
|
1115
pnpm-lock.yaml
1115
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
44
src-tauri/Cargo.lock
generated
44
src-tauri/Cargo.lock
generated
@ -182,9 +182,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.73"
|
version = "1.0.74"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f768393e7fabd388fe8409b13faa4d93ab0fef35db1508438dfdb066918bcf38"
|
checksum = "8c6f84b74db2535ebae81eede2f39b947dcbf01d093ae5f791e5dd414a1bf289"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arboard"
|
name = "arboard"
|
||||||
@ -2758,7 +2758,6 @@ dependencies = [
|
|||||||
"tauri-plugin-upload",
|
"tauri-plugin-upload",
|
||||||
"tauri-plugin-window",
|
"tauri-plugin-window",
|
||||||
"webpage",
|
"webpage",
|
||||||
"window-vibrancy",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2913,9 +2912,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "muda"
|
name = "muda"
|
||||||
version = "0.8.2"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "47e33f46fb20f85553edb85e30a6a5231567f4103276ccdb5a2050613d253b1d"
|
checksum = "a5381209b232fae437a2dd8054c9fe4953fb7a4b05e6e437f64aacdd01f97859"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa 0.25.0",
|
"cocoa 0.25.0",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
@ -4233,9 +4232,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.104"
|
version = "1.0.105"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
|
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa 1.0.9",
|
"itoa 1.0.9",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -4948,9 +4947,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tao"
|
name = "tao"
|
||||||
version = "0.22.0"
|
version = "0.22.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60279ecb16c33a6cef45cd37a9602455c190942d20e360bd8499bff49f2a48f3"
|
checksum = "c561b4a9a3787c78ec0fbbd5c719aa84a6572bb6ff3ddfce4db4c46d3a8070a5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"cairo-rs",
|
"cairo-rs",
|
||||||
@ -5506,18 +5505,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.45"
|
version = "1.0.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dedd246497092a89beedfe2c9f176d44c1b672ea6090edc20544ade01fbb7ea0"
|
checksum = "d9207952ae1a003f42d3d5e892dac3c6ba42aa6ac0c79a6a91a2b5cb4253e75c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.45"
|
version = "1.0.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d7b1fadccbbc7e19ea64708629f9d8dccd007c260d66485f20a6d41bc1cf4b3"
|
checksum = "f1728216d3244de4f14f14f8c15c79be1a7c67867d28d69b719690e2a19fb445"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -5746,9 +5745,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tray-icon"
|
name = "tray-icon"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e3b0e5bec13da15e62330e9bcf8b9fd42489b5acfe29ac8fec7ed659dbee21d9"
|
checksum = "672bc5a19944bfd51e5a874e9fcb7f129b76e5dd448fe295fa25411f3f800637"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa 0.25.0",
|
"cocoa 0.25.0",
|
||||||
"core-graphics 0.23.1",
|
"core-graphics 0.23.1",
|
||||||
@ -6209,17 +6208,6 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "window-vibrancy"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "git+https://github.com/tauri-apps/window-vibrancy?branch=dev#98dc472a7f96bfba595c74b009073bd2c7b28339"
|
|
||||||
dependencies = [
|
|
||||||
"cocoa 0.25.0",
|
|
||||||
"objc",
|
|
||||||
"raw-window-handle",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.36.1"
|
version = "0.36.1"
|
||||||
@ -6504,9 +6492,9 @@ checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.5.10"
|
version = "0.5.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d"
|
checksum = "1e461589e194280efaa97236b73623445efa195aa633fd7004f39805707a9d53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -33,7 +33,6 @@ tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", bra
|
|||||||
tauri-plugin-window = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-window = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
window-vibrancy = { git = "https://github.com/tauri-apps/window-vibrancy", branch = "dev" }
|
|
||||||
sqlx-cli = { version = "0.7.0", default-features = false, features = [
|
sqlx-cli = { version = "0.7.0", default-features = false, features = [
|
||||||
"sqlite",
|
"sqlite",
|
||||||
] }
|
] }
|
||||||
|
@ -9,7 +9,6 @@ use opg::opengraph;
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_autostart::MacosLauncher;
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
use tauri_plugin_sql::{Migration, MigrationKind};
|
use tauri_plugin_sql::{Migration, MigrationKind};
|
||||||
use window_vibrancy::{apply_mica, apply_vibrancy, NSVisualEffectMaterial};
|
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize)]
|
#[derive(Clone, serde::Serialize)]
|
||||||
struct Payload {
|
struct Payload {
|
||||||
@ -174,19 +173,6 @@ fn main() {
|
|||||||
.plugin(tauri_plugin_window::init())
|
.plugin(tauri_plugin_window::init())
|
||||||
.plugin(tauri_plugin_store::Builder::default().build())
|
.plugin(tauri_plugin_store::Builder::default().build())
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.setup(|app| {
|
|
||||||
let window = app.get_window("main").unwrap();
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None)
|
|
||||||
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
apply_mica(&window, Some(true))
|
|
||||||
.expect("Unsupported platform! 'apply_mica' is only supported on Windows");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.invoke_handler(tauri::generate_handler![close_splashscreen, opengraph])
|
.invoke_handler(tauri::generate_handler![close_splashscreen, opengraph])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
@ -73,13 +73,6 @@
|
|||||||
"resources": [],
|
"resources": [],
|
||||||
"shortDescription": "",
|
"shortDescription": "",
|
||||||
"targets": "all",
|
"targets": "all",
|
||||||
"updater": {
|
|
||||||
"active": true,
|
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU4RjAzODFBREQ4MkM3RTEKUldUaHg0TGRHamp3NkI5bnhoOEVjanlHWFNzQ2Q3NDhubFFLUmJpSHJ1L2FqNnB3alF1Y2R3U3gK",
|
|
||||||
"windows": {
|
|
||||||
"installMode": "passive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"windows": {
|
"windows": {
|
||||||
"certificateThumbprint": null,
|
"certificateThumbprint": null,
|
||||||
"digestAlgorithm": "sha256",
|
"digestAlgorithm": "sha256",
|
||||||
@ -103,7 +96,12 @@
|
|||||||
"center": true,
|
"center": true,
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"hiddenTitle": true,
|
"hiddenTitle": true,
|
||||||
"visible": false
|
"visible": false,
|
||||||
|
"fileDropEnabled": true,
|
||||||
|
"windowEffects": {
|
||||||
|
"effects": ["mica", "hudWindow"],
|
||||||
|
"state": "followsWindowActiveState"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"width": 400,
|
"width": 400,
|
||||||
@ -114,7 +112,11 @@
|
|||||||
"resizable": false,
|
"resizable": false,
|
||||||
"titleBarStyle": "Overlay",
|
"titleBarStyle": "Overlay",
|
||||||
"label": "splashscreen",
|
"label": "splashscreen",
|
||||||
"url": "splashscreen"
|
"url": "splashscreen",
|
||||||
|
"windowEffects": {
|
||||||
|
"effects": ["mica", "hudWindow"],
|
||||||
|
"state": "followsWindowActiveState"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"macOSPrivateApi": true
|
"macOSPrivateApi": true
|
||||||
|
@ -58,40 +58,28 @@ export function ImportStep3Screen() {
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full rounded-xl bg-white/10 p-4">
|
<div className="w-full rounded-xl bg-white/10 p-4">
|
||||||
{status === 'loading' ? (
|
<div className="flex flex-col gap-3">
|
||||||
<div className="w-full">
|
<User pubkey={db.account.pubkey} />
|
||||||
<div className="flex items-center gap-2">
|
<button
|
||||||
<div className="h-11 w-11 animate-pulse rounded-lg bg-white/10" />
|
type="button"
|
||||||
<div>
|
className="inline-flex h-11 w-full items-center justify-between gap-2 rounded-lg bg-fuchsia-500 px-6 font-medium leading-none text-white hover:bg-fuchsia-600 focus:outline-none"
|
||||||
<div className="mb-1 h-4 w-16 animate-pulse rounded bg-white/10" />
|
onClick={() => submit()}
|
||||||
<div className="h-3 w-36 animate-pulse rounded bg-white/10" />
|
>
|
||||||
</div>
|
{loading ? (
|
||||||
</div>
|
<>
|
||||||
</div>
|
<span className="w-5" />
|
||||||
) : (
|
<span>It might take a bit, please patient...</span>
|
||||||
<div className="flex flex-col gap-3">
|
<LoaderIcon className="h-5 w-5 animate-spin text-white" />
|
||||||
<User pubkey={db.account.pubkey} />
|
</>
|
||||||
<button
|
) : (
|
||||||
type="button"
|
<>
|
||||||
className="inline-flex h-11 w-full items-center justify-between gap-2 rounded-lg bg-fuchsia-500 px-6 font-medium leading-none text-white hover:bg-fuchsia-600 focus:outline-none"
|
<span className="w-5" />
|
||||||
onClick={() => submit()}
|
<span>Continue</span>
|
||||||
>
|
<ArrowRightCircleIcon className="h-5 w-5" />
|
||||||
{loading ? (
|
</>
|
||||||
<>
|
)}
|
||||||
<span className="w-5" />
|
</button>
|
||||||
<span>It might take a bit, please patient...</span>
|
</div>
|
||||||
<LoaderIcon className="h-5 w-5 animate-spin text-white" />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<span className="w-5" />
|
|
||||||
<span>Continue</span>
|
|
||||||
<ArrowRightCircleIcon className="h-5 w-5" />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -5,15 +5,12 @@ import { useState } from 'react';
|
|||||||
import { Resolver, useForm } from 'react-hook-form';
|
import { Resolver, useForm } from 'react-hook-form';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { removePrivkey } from '@libs/storage';
|
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons';
|
import { EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useStronghold } from '@stores/stronghold';
|
import { useStronghold } from '@stores/stronghold';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
password: string;
|
password: string;
|
||||||
};
|
};
|
||||||
@ -73,7 +70,7 @@ export function MigrateScreen() {
|
|||||||
// add privkey to state
|
// add privkey to state
|
||||||
setPrivkey(db.account.privkey);
|
setPrivkey(db.account.privkey);
|
||||||
// remove privkey in db
|
// remove privkey in db
|
||||||
await removePrivkey();
|
await db.removePrivkey();
|
||||||
// clear cache
|
// clear cache
|
||||||
await queryClient.invalidateQueries(['account']);
|
await queryClient.invalidateQueries(['account']);
|
||||||
// redirect to home
|
// redirect to home
|
||||||
|
@ -4,9 +4,11 @@ import { useState } from 'react';
|
|||||||
import { Resolver, useForm } from 'react-hook-form';
|
import { Resolver, useForm } from 'react-hook-form';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { User } from '@app/auth/components/user';
|
||||||
|
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons';
|
import { ArrowRightCircleIcon, EyeOffIcon, EyeOnIcon, LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useStronghold } from '@stores/stronghold';
|
import { useStronghold } from '@stores/stronghold';
|
||||||
|
|
||||||
@ -36,7 +38,6 @@ export function UnlockScreen() {
|
|||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
setError,
|
setError,
|
||||||
@ -79,13 +80,17 @@ export function UnlockScreen() {
|
|||||||
<div className="mb-6 text-center">
|
<div className="mb-6 text-center">
|
||||||
<h1 className="text-2xl font-semibold text-white">Enter password to unlock</h1>
|
<h1 className="text-2xl font-semibold text-white">Enter password to unlock</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mb-4 w-full rounded-xl bg-white/5 p-4">
|
||||||
|
<User pubkey={db.account.pubkey} />
|
||||||
|
</div>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="mb-0 flex flex-col gap-3">
|
<form onSubmit={handleSubmit(onSubmit)} className="mb-0 flex flex-col gap-3">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<input
|
<input
|
||||||
{...register('password', { required: true })}
|
{...register('password', { required: true })}
|
||||||
type={showPassword ? 'text' : 'password'}
|
type={showPassword ? 'text' : 'password'}
|
||||||
className="relative h-12 w-full rounded-lg bg-white/10 py-1 text-center text-white !outline-none placeholder:text-white/10"
|
placeholder="Password"
|
||||||
|
className="relative h-12 w-full rounded-lg bg-white/10 py-1 text-center text-white !outline-none placeholder:text-white/50"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@ -107,12 +112,20 @@ export function UnlockScreen() {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!isDirty || !isValid}
|
disabled={!isDirty || !isValid}
|
||||||
className="inline-flex h-12 w-full items-center justify-center rounded-md bg-fuchsia-500 font-medium text-white hover:bg-fuchsia-600"
|
className="inline-flex h-11 w-full items-center justify-between gap-2 rounded-lg bg-fuchsia-500 px-6 font-medium leading-none text-white hover:bg-fuchsia-600 focus:outline-none"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<LoaderIcon className="h-4 w-4 animate-spin text-white" />
|
<>
|
||||||
|
<span className="w-5" />
|
||||||
|
<span>Decryting...</span>
|
||||||
|
<LoaderIcon className="h-5 w-5" />
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
'Continue →'
|
<>
|
||||||
|
<span className="w-5" />
|
||||||
|
<span>Continue</span>
|
||||||
|
<ArrowRightCircleIcon className="h-5 w-5" />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<Link
|
<Link
|
||||||
|
@ -3,30 +3,25 @@ import * as Dialog from '@radix-ui/react-dialog';
|
|||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
|
||||||
|
|
||||||
import { User } from '@app/auth/components/user';
|
import { User } from '@app/auth/components/user';
|
||||||
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { CancelIcon, CheckCircleIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
import { CancelIcon, CheckCircleIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { BLOCK_KINDS, DEFAULT_AVATAR } from '@stores/constants';
|
import { BLOCK_KINDS, DEFAULT_AVATAR } from '@stores/constants';
|
||||||
import { ADD_FEEDBLOCK_SHORTCUT } from '@stores/shortcuts';
|
|
||||||
import { useWidgets } from '@stores/widgets';
|
import { useWidgets } from '@stores/widgets';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
|
|
||||||
export function FeedModal() {
|
export function FeedModal() {
|
||||||
|
const setWidget = useWidgets((state) => state.setWidget);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [selected, setSelected] = useState([]);
|
const [selected, setSelected] = useState([]);
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
|
|
||||||
const { status, account } = useAccount();
|
const { db } = useStorage();
|
||||||
|
|
||||||
const setWidget = useWidgets((state) => state.setWidget);
|
|
||||||
|
|
||||||
useHotkeys(ADD_FEEDBLOCK_SHORTCUT, () => setOpen(true));
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -43,8 +38,8 @@ export function FeedModal() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// insert to database
|
// update state
|
||||||
setWidget({
|
setWidget(db, {
|
||||||
kind: BLOCK_KINDS.feed,
|
kind: BLOCK_KINDS.feed,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
content: JSON.stringify(selected),
|
content: JSON.stringify(selected),
|
||||||
@ -155,26 +150,22 @@ export function FeedModal() {
|
|||||||
)}
|
)}
|
||||||
</Combobox.Option>
|
</Combobox.Option>
|
||||||
)}
|
)}
|
||||||
{status === 'loading' ? (
|
{db.account?.follows?.map((follow) => (
|
||||||
<p>Loading...</p>
|
<Combobox.Option
|
||||||
) : (
|
key={follow}
|
||||||
account?.follows?.map((follow) => (
|
value={follow}
|
||||||
<Combobox.Option
|
className="group flex w-full items-center justify-between rounded-md px-2 py-2 hover:bg-white/10"
|
||||||
key={follow}
|
>
|
||||||
value={follow}
|
{({ selected }) => (
|
||||||
className="group flex w-full items-center justify-between rounded-md px-2 py-2 hover:bg-white/10"
|
<>
|
||||||
>
|
<User pubkey={follow} />
|
||||||
{({ selected }) => (
|
{selected && (
|
||||||
<>
|
<CheckCircleIcon className="h-4 w-4 text-green-500" />
|
||||||
<User pubkey={follow} />
|
)}
|
||||||
{selected && (
|
</>
|
||||||
<CheckCircleIcon className="h-4 w-4 text-green-500" />
|
)}
|
||||||
)}
|
</Combobox.Option>
|
||||||
</>
|
))}
|
||||||
)}
|
|
||||||
</Combobox.Option>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</Combobox.Options>
|
</Combobox.Options>
|
||||||
</Combobox>
|
</Combobox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
import * as Dialog from '@radix-ui/react-dialog';
|
import * as Dialog from '@radix-ui/react-dialog';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { CancelIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
import { CancelIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { BLOCK_KINDS } from '@stores/constants';
|
import { BLOCK_KINDS } from '@stores/constants';
|
||||||
import { ADD_HASHTAGBLOCK_SHORTCUT } from '@stores/shortcuts';
|
|
||||||
import { useWidgets } from '@stores/widgets';
|
import { useWidgets } from '@stores/widgets';
|
||||||
|
|
||||||
export function HashtagModal() {
|
export function HashtagModal() {
|
||||||
|
const setWidget = useWidgets((state) => state.setWidget);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const setWidget = useWidgets((state) => state.setWidget);
|
const { db } = useStorage();
|
||||||
|
|
||||||
useHotkeys(ADD_HASHTAGBLOCK_SHORTCUT, () => setOpen(false));
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -27,8 +26,8 @@ export function HashtagModal() {
|
|||||||
const onSubmit = async (data: { hashtag: string }) => {
|
const onSubmit = async (data: { hashtag: string }) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
// mutate
|
// update state
|
||||||
setWidget({
|
setWidget(db, {
|
||||||
kind: BLOCK_KINDS.hashtag,
|
kind: BLOCK_KINDS.hashtag,
|
||||||
title: data.hashtag,
|
title: data.hashtag,
|
||||||
content: data.hashtag.replace('#', ''),
|
content: data.hashtag.replace('#', ''),
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import * as Dialog from '@radix-ui/react-dialog';
|
import * as Dialog from '@radix-ui/react-dialog';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { CancelIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
import { CancelIcon, CommandIcon, LoaderIcon } from '@shared/icons';
|
||||||
import { Image } from '@shared/image';
|
import { Image } from '@shared/image';
|
||||||
|
|
||||||
import { BLOCK_KINDS, DEFAULT_AVATAR } from '@stores/constants';
|
import { BLOCK_KINDS, DEFAULT_AVATAR } from '@stores/constants';
|
||||||
import { ADD_IMAGEBLOCK_SHORTCUT } from '@stores/shortcuts';
|
|
||||||
import { useWidgets } from '@stores/widgets';
|
import { useWidgets } from '@stores/widgets';
|
||||||
|
|
||||||
import { useImageUploader } from '@utils/hooks/useUploader';
|
import { useImageUploader } from '@utils/hooks/useUploader';
|
||||||
@ -20,8 +20,7 @@ export function ImageModal() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [image, setImage] = useState('');
|
const [image, setImage] = useState('');
|
||||||
|
|
||||||
useHotkeys(ADD_IMAGEBLOCK_SHORTCUT, () => setOpen(false));
|
const { db } = useStorage();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -41,7 +40,7 @@ export function ImageModal() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
// mutate
|
// mutate
|
||||||
setWidget({ kind: BLOCK_KINDS.image, title: data.title, content: data.content });
|
setWidget(db, { kind: BLOCK_KINDS.image, title: data.title, content: data.content });
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
// reset form
|
// reset form
|
||||||
|
@ -58,21 +58,13 @@ export function FeedBlock({ params }: { params: Widget }) {
|
|||||||
const reply = note.tags.find((el) => el[3] === 'reply')?.[1];
|
const reply = note.tags.find((el) => el[3] === 'reply')?.[1];
|
||||||
if (root || reply) {
|
if (root || reply) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={note.id} data-index={index} ref={rowVirtualizer.measureElement}>
|
||||||
key={note.event_id || note.id}
|
|
||||||
data-index={index}
|
|
||||||
ref={rowVirtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<NoteThread event={note} root={root} reply={reply} />
|
<NoteThread event={note} root={root} reply={reply} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={note.id} data-index={index} ref={rowVirtualizer.measureElement}>
|
||||||
key={note.event_id || note.id}
|
|
||||||
data-index={index}
|
|
||||||
ref={rowVirtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<NoteKind_1 event={note} skipMetadata={false} />
|
<NoteKind_1 event={note} skipMetadata={false} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -80,32 +72,20 @@ export function FeedBlock({ params }: { params: Widget }) {
|
|||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={note.id} data-index={index} ref={rowVirtualizer.measureElement}>
|
||||||
key={note.event_id || note.id}
|
<Repost key={note.id} event={note} />
|
||||||
data-index={index}
|
|
||||||
ref={rowVirtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<Repost key={note.event_id} event={note} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 1063:
|
case 1063:
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={note.id} data-index={index} ref={rowVirtualizer.measureElement}>
|
||||||
key={note.event_id || note.id}
|
<NoteKind_1063 key={note.id} event={note} />
|
||||||
data-index={index}
|
|
||||||
ref={rowVirtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<NoteKind_1063 key={note.event_id} event={note} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={note.id} data-index={index} ref={rowVirtualizer.measureElement}>
|
||||||
key={note.event_id || note.id}
|
<NoteKindUnsupport key={note.id} event={note} />
|
||||||
data-index={index}
|
|
||||||
ref={rowVirtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<NoteKindUnsupport key={note.event_id} event={note} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||||
import { NostrEvent } from 'nostr-fetch';
|
import { NostrEvent } from 'nostr-fetch';
|
||||||
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
import { useCallback, useMemo, useRef } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { NoteKind_1, NoteKind_1063, NoteThread, Repost } from '@shared/notes';
|
import { NoteKind_1, NoteKind_1063, NoteThread, Repost } from '@shared/notes';
|
||||||
@ -14,14 +14,15 @@ import { LumeEvent } from '@utils/types';
|
|||||||
|
|
||||||
export function NetworkBlock() {
|
export function NetworkBlock() {
|
||||||
const { fetchNotes } = useNostr();
|
const { fetchNotes } = useNostr();
|
||||||
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
const { status, data, hasNextPage, isFetchingNextPage } = useInfiniteQuery({
|
||||||
useInfiniteQuery({
|
queryKey: ['network-widget'],
|
||||||
queryKey: ['network-widget'],
|
queryFn: async ({ pageParam = 24 }) => {
|
||||||
queryFn: async ({ pageParam = 24 }) => {
|
return await fetchNotes(pageParam);
|
||||||
return await fetchNotes(pageParam);
|
},
|
||||||
},
|
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
refetchOnWindowFocus: false,
|
||||||
});
|
refetchOnReconnect: false,
|
||||||
|
});
|
||||||
|
|
||||||
const parentRef = useRef();
|
const parentRef = useRef();
|
||||||
const notes = useMemo(
|
const notes = useMemo(
|
||||||
@ -40,18 +41,6 @@ export function NetworkBlock() {
|
|||||||
const itemsVirtualizer = rowVirtualizer.getVirtualItems();
|
const itemsVirtualizer = rowVirtualizer.getVirtualItems();
|
||||||
const totalSize = rowVirtualizer.getTotalSize();
|
const totalSize = rowVirtualizer.getTotalSize();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const [lastItem] = [...itemsVirtualizer].reverse();
|
|
||||||
|
|
||||||
if (!lastItem) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastItem.index >= notes.length - 1 && hasNextPage && !isFetchingNextPage) {
|
|
||||||
fetchNextPage();
|
|
||||||
}
|
|
||||||
}, [notes.length, fetchNextPage, itemsVirtualizer]);
|
|
||||||
|
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
(index: string | number) => {
|
(index: string | number) => {
|
||||||
const note: LumeEvent = notes[index];
|
const note: LumeEvent = notes[index];
|
||||||
@ -69,7 +58,7 @@ export function NetworkBlock() {
|
|||||||
if (root || reply) {
|
if (root || reply) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={(root || reply) + (note.event_id || note.id) + index}
|
key={(root || reply) + note.id + index}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
@ -79,7 +68,7 @@ export function NetworkBlock() {
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={(note.event_id || note.id) + index}
|
key={note.id + index}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
@ -91,31 +80,31 @@ export function NetworkBlock() {
|
|||||||
case 6:
|
case 6:
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={(note.event_id || note.id) + index}
|
key={note.id + index}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Repost key={note.event_id} event={note} />
|
<Repost key={note.id} event={note} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 1063:
|
case 1063:
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={(note.event_id || note.id) + index}
|
key={note.id + index}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<NoteKind_1063 key={note.event_id} event={note} />
|
<NoteKind_1063 key={note.id} event={note} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={(note.event_id || note.id) + index}
|
key={note.id + index}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<NoteKindUnsupport key={note.event_id} event={note} />
|
<NoteKindUnsupport key={note.id} event={note} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// import { useLiveThread } from '@app/space/hooks/useLiveThread';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NoteActions,
|
NoteActions,
|
||||||
NoteContent,
|
NoteContent,
|
||||||
@ -10,16 +11,12 @@ import { RepliesList } from '@shared/notes/replies/list';
|
|||||||
import { NoteSkeleton } from '@shared/notes/skeleton';
|
import { NoteSkeleton } from '@shared/notes/skeleton';
|
||||||
import { TitleBar } from '@shared/titleBar';
|
import { TitleBar } from '@shared/titleBar';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
import { useEvent } from '@utils/hooks/useEvent';
|
import { useEvent } from '@utils/hooks/useEvent';
|
||||||
import { Widget } from '@utils/types';
|
import { Widget } from '@utils/types';
|
||||||
|
|
||||||
export function ThreadBlock({ params }: { params: Widget }) {
|
export function ThreadBlock({ params }: { params: Widget }) {
|
||||||
const { status, data } = useEvent(params.content);
|
const { status, data } = useEvent(params.content);
|
||||||
const { account } = useAccount();
|
const { db } = useStorage();
|
||||||
|
|
||||||
// subscribe to live reply
|
|
||||||
// useLiveThread(params.content);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="scrollbar-hide h-full w-[400px] shrink-0 overflow-y-auto bg-white/10 pb-20">
|
<div className="scrollbar-hide h-full w-[400px] shrink-0 overflow-y-auto bg-white/10 pb-20">
|
||||||
@ -50,7 +47,7 @@ export function ThreadBlock({ params }: { params: Widget }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="px-3">
|
<div className="px-3">
|
||||||
{account && <NoteReplyForm id={params.content} pubkey={account.pubkey} />}
|
<NoteReplyForm id={params.content} pubkey={db.account.pubkey} />
|
||||||
<RepliesList id={params.content} />
|
<RepliesList id={params.content} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,8 @@ import { NetworkBlock } from '@app/space/components/widgets/network';
|
|||||||
import { ThreadBlock } from '@app/space/components/widgets/thread';
|
import { ThreadBlock } from '@app/space/components/widgets/thread';
|
||||||
import { UserBlock } from '@app/space/components/widgets/user';
|
import { UserBlock } from '@app/space/components/widgets/user';
|
||||||
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { LoaderIcon } from '@shared/icons';
|
import { LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useWidgets } from '@stores/widgets';
|
import { useWidgets } from '@stores/widgets';
|
||||||
@ -22,6 +24,8 @@ export function SpaceScreen() {
|
|||||||
state.fetchWidgets,
|
state.fetchWidgets,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const { db } = useStorage();
|
||||||
|
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
(widget: Widget) => {
|
(widget: Widget) => {
|
||||||
switch (widget.kind) {
|
switch (widget.kind) {
|
||||||
@ -43,7 +47,7 @@ export function SpaceScreen() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchWidgets();
|
fetchWidgets(db);
|
||||||
}, [fetchWidgets]);
|
}, [fetchWidgets]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -30,7 +30,7 @@ export function SplashScreen() {
|
|||||||
if (user.status === 'ok') {
|
if (user.status === 'ok') {
|
||||||
const now = Math.floor(Date.now() / 1000);
|
const now = Math.floor(Date.now() / 1000);
|
||||||
await db.updateLastLogin(now);
|
await db.updateLastLogin(now);
|
||||||
invoke('close_splashscreen');
|
await invoke('close_splashscreen');
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setErrorMessage(user.message);
|
setErrorMessage(user.message);
|
||||||
@ -55,7 +55,7 @@ export function SplashScreen() {
|
|||||||
}, [ndk, db.account]);
|
}, [ndk, db.account]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex h-screen w-screen items-center justify-center bg-black">
|
<div className="relative flex h-screen w-screen items-center justify-center bg-black/90">
|
||||||
<div data-tauri-drag-region className="absolute left-0 top-0 z-10 h-11 w-full" />
|
<div data-tauri-drag-region className="absolute left-0 top-0 z-10 h-11 w-full" />
|
||||||
<div className="flex min-h-0 w-full flex-1 items-center justify-center">
|
<div className="flex min-h-0 w-full flex-1 items-center justify-center">
|
||||||
<div className="flex flex-col items-center justify-center gap-4">
|
<div className="flex flex-col items-center justify-center gap-4">
|
||||||
|
@ -3,19 +3,20 @@ import { Link } from 'react-router-dom';
|
|||||||
|
|
||||||
import { UserMetadata } from '@app/users/components/metadata';
|
import { UserMetadata } from '@app/users/components/metadata';
|
||||||
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { EditProfileModal } from '@shared/editProfileModal';
|
import { EditProfileModal } from '@shared/editProfileModal';
|
||||||
import { Image } from '@shared/image';
|
import { Image } from '@shared/image';
|
||||||
|
|
||||||
import { DEFAULT_AVATAR } from '@stores/constants';
|
import { DEFAULT_AVATAR } from '@stores/constants';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
import { useProfile } from '@utils/hooks/useProfile';
|
import { useProfile } from '@utils/hooks/useProfile';
|
||||||
import { useSocial } from '@utils/hooks/useSocial';
|
import { useSocial } from '@utils/hooks/useSocial';
|
||||||
import { shortenKey } from '@utils/shortenKey';
|
import { shortenKey } from '@utils/shortenKey';
|
||||||
|
|
||||||
export function UserProfile({ pubkey }: { pubkey: string }) {
|
export function UserProfile({ pubkey }: { pubkey: string }) {
|
||||||
|
const { db } = useStorage();
|
||||||
const { user } = useProfile(pubkey);
|
const { user } = useProfile(pubkey);
|
||||||
const { account } = useAccount();
|
|
||||||
const { status, userFollows, follow, unfollow } = useSocial();
|
const { status, userFollows, follow, unfollow } = useSocial();
|
||||||
|
|
||||||
const [followed, setFollowed] = useState(false);
|
const [followed, setFollowed] = useState(false);
|
||||||
@ -109,7 +110,7 @@ export function UserProfile({ pubkey }: { pubkey: string }) {
|
|||||||
Message
|
Message
|
||||||
</Link>
|
</Link>
|
||||||
<span className="mx-2 inline-flex h-4 w-px bg-white/10" />
|
<span className="mx-2 inline-flex h-4 w-px bg-white/10" />
|
||||||
{account && account.pubkey === pubkey && <EditProfileModal />}
|
{db.account.pubkey === pubkey && <EditProfileModal />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-8">
|
<div className="flex flex-col gap-8">
|
||||||
|
@ -3,7 +3,6 @@ import NDK from '@nostr-dev-kit/ndk';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import TauriAdapter from '@libs/ndk/cache';
|
import TauriAdapter from '@libs/ndk/cache';
|
||||||
import { getExplicitRelayUrls } from '@libs/storage';
|
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { FULL_RELAYS } from '@stores/constants';
|
import { FULL_RELAYS } from '@stores/constants';
|
||||||
@ -56,7 +55,7 @@ export const NDKInstance = () => {
|
|||||||
|
|
||||||
async function initNDK() {
|
async function initNDK() {
|
||||||
let explicitRelayUrls: string[];
|
let explicitRelayUrls: string[];
|
||||||
const explicitRelayUrlsFromDB = await getExplicitRelayUrls();
|
const explicitRelayUrlsFromDB = await db.getExplicitRelayUrls();
|
||||||
|
|
||||||
if (explicitRelayUrlsFromDB) {
|
if (explicitRelayUrlsFromDB) {
|
||||||
explicitRelayUrls = await verifyRelays(explicitRelayUrlsFromDB);
|
explicitRelayUrls = await verifyRelays(explicitRelayUrlsFromDB);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Database from '@tauri-apps/plugin-sql';
|
import Database from '@tauri-apps/plugin-sql';
|
||||||
import destr from 'destr';
|
import { destr } from 'destr';
|
||||||
|
|
||||||
import { parser } from '@utils/parser';
|
import { parser } from '@utils/parser';
|
||||||
import { getParentID } from '@utils/transform';
|
import { getParentID } from '@utils/transform';
|
||||||
|
@ -184,6 +184,12 @@ export class LumeStorage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async removePrivkey() {
|
||||||
|
return await this.db.execute(
|
||||||
|
`UPDATE accounts SET privkey = "privkey is stored in secure storage" WHERE id = "${this.account.id}";`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public async close() {
|
public async close() {
|
||||||
return this.db.close();
|
return this.db.close();
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,6 @@ const StorageProvider = ({ children }: PropsWithChildren<object>) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!db) initLumeStorage();
|
if (!db) initLumeStorage();
|
||||||
|
|
||||||
return () => {
|
|
||||||
db.close();
|
|
||||||
};
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
|
11
src/main.tsx
11
src/main.tsx
@ -2,20 +2,11 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
|
|
||||||
import { NDKProvider } from '@libs/ndk/provider';
|
import { NDKProvider } from '@libs/ndk/provider';
|
||||||
import { getSetting } from '@libs/storage';
|
|
||||||
import { StorageProvider } from '@libs/storage/provider';
|
import { StorageProvider } from '@libs/storage/provider';
|
||||||
|
|
||||||
import App from './app';
|
import App from './app';
|
||||||
|
|
||||||
const cacheTime = await getSetting('cache_time');
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
|
||||||
defaultOptions: {
|
|
||||||
queries: {
|
|
||||||
cacheTime: parseInt(cacheTime),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const container = document.getElementById('root');
|
const container = document.getElementById('root');
|
||||||
const root = createRoot(container);
|
const root = createRoot(container);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import * as Dialog from '@radix-ui/react-dialog';
|
import * as Dialog from '@radix-ui/react-dialog';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { Composer, ComposerUser } from '@shared/composer';
|
import { Composer, ComposerUser } from '@shared/composer';
|
||||||
import {
|
import {
|
||||||
CancelIcon,
|
CancelIcon,
|
||||||
@ -12,10 +14,8 @@ import {
|
|||||||
import { useComposer } from '@stores/composer';
|
import { useComposer } from '@stores/composer';
|
||||||
import { COMPOSE_SHORTCUT } from '@stores/shortcuts';
|
import { COMPOSE_SHORTCUT } from '@stores/shortcuts';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
|
|
||||||
export function ComposerModal() {
|
export function ComposerModal() {
|
||||||
const { account } = useAccount();
|
const { db } = useStorage();
|
||||||
const [toggle, open] = useComposer((state) => [state.toggleModal, state.open]);
|
const [toggle, open] = useComposer((state) => [state.toggleModal, state.open]);
|
||||||
|
|
||||||
useHotkeys(COMPOSE_SHORTCUT, () => toggle(true));
|
useHotkeys(COMPOSE_SHORTCUT, () => toggle(true));
|
||||||
@ -25,7 +25,7 @@ export function ComposerModal() {
|
|||||||
<Dialog.Trigger asChild>
|
<Dialog.Trigger asChild>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="inline-flex h-9 w-min items-center justify-center gap-1 rounded-md bg-white/10 px-4 text-sm font-medium text-white hover:bg-fuchsia-500 focus:outline-none active:translate-y-1 disabled:pointer-events-none disabled:opacity-50"
|
className="inline-flex h-9 w-min items-center justify-center gap-1 rounded-md bg-white/10 px-8 text-sm font-medium text-white hover:bg-fuchsia-500 focus:outline-none active:translate-y-1 disabled:pointer-events-none disabled:opacity-50"
|
||||||
>
|
>
|
||||||
<ComposeIcon className="h-4 w-4" />
|
<ComposeIcon className="h-4 w-4" />
|
||||||
Postr
|
Postr
|
||||||
@ -37,7 +37,7 @@ export function ComposerModal() {
|
|||||||
<div className="relative h-min w-full max-w-2xl rounded-xl bg-white/10">
|
<div className="relative h-min w-full max-w-2xl rounded-xl bg-white/10">
|
||||||
<div className="flex items-center justify-between px-4 py-4">
|
<div className="flex items-center justify-between px-4 py-4">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{account && <ComposerUser pubkey={account.pubkey} />}
|
<ComposerUser pubkey={db.account.pubkey} />
|
||||||
<span>
|
<span>
|
||||||
<ChevronRightIcon className="h-4 w-4 text-white/50" />
|
<ChevronRightIcon className="h-4 w-4 text-white/50" />
|
||||||
</span>
|
</span>
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { createJSONStorage, persist } from 'zustand/middleware';
|
import { createJSONStorage, persist } from 'zustand/middleware';
|
||||||
|
|
||||||
import { createWidget, getWidgets, removeWidget } from '@libs/storage';
|
import { LumeStorage } from '@libs/storage/instance';
|
||||||
|
|
||||||
import { Widget } from '@utils/types';
|
import { Widget } from '@utils/types';
|
||||||
|
|
||||||
interface WidgetState {
|
interface WidgetState {
|
||||||
widgets: null | Array<Widget>;
|
widgets: null | Array<Widget>;
|
||||||
fetchWidgets: () => void;
|
fetchWidgets: (db: LumeStorage) => void;
|
||||||
setWidget: ({ kind, title, content }: Widget) => void;
|
setWidget: (db: LumeStorage, { kind, title, content }: Widget) => void;
|
||||||
removeWidget: (id: string) => void;
|
removeWidget: (db: LumeStorage, id: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWidgets = create<WidgetState>()(
|
export const useWidgets = create<WidgetState>()(
|
||||||
persist(
|
persist(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
widgets: null,
|
widgets: null,
|
||||||
fetchWidgets: async () => {
|
fetchWidgets: async (db: LumeStorage) => {
|
||||||
const widgets = await getWidgets();
|
const widgets = await db.getWidgets();
|
||||||
set({ widgets: widgets });
|
set({ widgets: widgets });
|
||||||
},
|
},
|
||||||
setWidget: async ({ kind, title, content }: Widget) => {
|
setWidget: async (db: LumeStorage, { kind, title, content }: Widget) => {
|
||||||
const widget: Widget = await createWidget(kind, title, content);
|
const widget: Widget = await db.createWidget(kind, title, content);
|
||||||
set((state) => ({ widgets: [...state.widgets, widget] }));
|
set((state) => ({ widgets: [...state.widgets, widget] }));
|
||||||
},
|
},
|
||||||
removeWidget: async (id: string) => {
|
removeWidget: async (db: LumeStorage, id: string) => {
|
||||||
await removeWidget(id);
|
await db.removeWidget(id);
|
||||||
set((state) => ({ widgets: state.widgets.filter((widget) => widget.id !== id) }));
|
set((state) => ({ widgets: state.widgets.filter((widget) => widget.id !== id) }));
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -2,32 +2,27 @@ import Database from '@tauri-apps/plugin-sql';
|
|||||||
|
|
||||||
import { Account } from '@utils/types';
|
import { Account } from '@utils/types';
|
||||||
|
|
||||||
let db: null | Database = null;
|
|
||||||
|
|
||||||
async function connect(): Promise<Database> {
|
async function connect(): Promise<Database> {
|
||||||
|
let db: null | Database = null;
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db = await Database.load('sqlite:lume.db');
|
db = await Database.load('sqlite:lume.db');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Failed to connect to database, error: ', e);
|
throw new Error('Failed to connect to database, error: ', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkActiveAccount() {
|
export async function checkActiveAccount() {
|
||||||
const tempDB = await connect();
|
const db = await connect();
|
||||||
const result: Array<Account> = await db.select(
|
const result: Array<Account> = await db.select(
|
||||||
'SELECT * FROM accounts WHERE is_active = 1;'
|
'SELECT * FROM accounts WHERE is_active = 1;'
|
||||||
);
|
);
|
||||||
|
|
||||||
// close temp db
|
return result.length > 0;
|
||||||
tempDB.close();
|
|
||||||
|
|
||||||
if (result.length > 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,12 @@ export function useEvent(id: string, embed?: string) {
|
|||||||
if (embed) {
|
if (embed) {
|
||||||
const event: LumeEvent = JSON.parse(embed);
|
const event: LumeEvent = JSON.parse(embed);
|
||||||
if (event.kind === 1) embed['content'] = parser(event);
|
if (event.kind === 1) embed['content'] = parser(event);
|
||||||
return embed;
|
return embed as unknown as LumeEvent;
|
||||||
} else {
|
} else {
|
||||||
const event = (await ndk.fetchEvent(id)) as unknown as LumeEvent;
|
const event = (await ndk.fetchEvent(id)) as LumeEvent;
|
||||||
if (!event) throw new Error('Event not found');
|
if (!event) return null;
|
||||||
if (event.kind === 1) event['content'] = parser(event);
|
if (event.kind === 1) event['content'] = parser(event) as unknown as string;
|
||||||
return event as unknown as LumeEvent;
|
return event as LumeEvent;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,8 @@ import {
|
|||||||
NDKSubscription,
|
NDKSubscription,
|
||||||
NDKUser,
|
NDKUser,
|
||||||
} from '@nostr-dev-kit/ndk';
|
} from '@nostr-dev-kit/ndk';
|
||||||
import { ndkAdapter } from '@nostr-fetch/adapter-ndk';
|
import { destr } from 'destr';
|
||||||
import destr from 'destr';
|
|
||||||
import { LRUCache } from 'lru-cache';
|
import { LRUCache } from 'lru-cache';
|
||||||
import { NostrFetcher } from 'nostr-fetch';
|
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
@ -21,11 +19,10 @@ import { useStronghold } from '@stores/stronghold';
|
|||||||
import { nHoursAgo } from '@utils/date';
|
import { nHoursAgo } from '@utils/date';
|
||||||
|
|
||||||
export function useNostr() {
|
export function useNostr() {
|
||||||
const { ndk, relayUrls } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
|
|
||||||
const privkey = useStronghold((state) => state.privkey);
|
const privkey = useStronghold((state) => state.privkey);
|
||||||
const fetcher = useMemo(() => NostrFetcher.withCustomPool(ndkAdapter(ndk)), [ndk]);
|
|
||||||
const subManager = useMemo(
|
const subManager = useMemo(
|
||||||
() =>
|
() =>
|
||||||
new LRUCache<string, NDKSubscription, void>({
|
new LRUCache<string, NDKSubscription, void>({
|
||||||
@ -85,20 +82,13 @@ export function useNostr() {
|
|||||||
try {
|
try {
|
||||||
if (!ndk) return { status: 'failed', message: 'NDK instance not found' };
|
if (!ndk) return { status: 'failed', message: 'NDK instance not found' };
|
||||||
|
|
||||||
const until = since === 24 ? Math.floor(Date.now() / 1000) : nHoursAgo(since / 2);
|
|
||||||
|
|
||||||
console.log('fetch events since: ', since);
|
|
||||||
console.log('fetch events until: ', until);
|
|
||||||
/*
|
|
||||||
const events = await ndk.fetchEvents({
|
const events = await ndk.fetchEvents({
|
||||||
kinds: [1],
|
kinds: [1],
|
||||||
authors: db.account.network ?? db.account.follows,
|
authors: db.account.network ?? db.account.follows,
|
||||||
since: since,
|
since: nHoursAgo(since),
|
||||||
until: until,
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
return { status: 'ok', data: [], nextCursor: since * 2 };
|
return { status: 'ok', data: [...events], nextCursor: since * 2 };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('failed get notes, error: ', e);
|
console.error('failed get notes, error: ', e);
|
||||||
return { status: 'failed', data: [], message: e };
|
return { status: 'failed', data: [], message: e };
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useNDK } from '@libs/ndk/provider';
|
import { useNDK } from '@libs/ndk/provider';
|
||||||
import { createMetadata } from '@libs/storage';
|
|
||||||
|
|
||||||
export function useProfile(pubkey: string, fallback?: string) {
|
export function useProfile(pubkey: string, fallback?: string) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
@ -18,7 +17,6 @@ export function useProfile(pubkey: string, fallback?: string) {
|
|||||||
await user.fetchProfile();
|
await user.fetchProfile();
|
||||||
if (user.profile) {
|
if (user.profile) {
|
||||||
user.profile.display_name = user.profile.displayName;
|
user.profile.display_name = user.profile.displayName;
|
||||||
await createMetadata(user.npub, pubkey, JSON.stringify(user.profile));
|
|
||||||
return user.profile;
|
return user.profile;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('User not found');
|
throw new Error('User not found');
|
||||||
@ -29,6 +27,7 @@ export function useProfile(pubkey: string, fallback?: string) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
enabled: !!ndk,
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useNDK } from '@libs/ndk/provider';
|
import { useNDK } from '@libs/ndk/provider';
|
||||||
import { createNote } from '@libs/storage';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { nHoursAgo } from '@utils/date';
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
|
||||||
import { useNostr } from '@utils/hooks/useNostr';
|
import { useNostr } from '@utils/hooks/useNostr';
|
||||||
|
|
||||||
export function useSocial() {
|
export function useSocial() {
|
||||||
@ -12,12 +10,12 @@ export function useSocial() {
|
|||||||
|
|
||||||
const { publish } = useNostr();
|
const { publish } = useNostr();
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { account } = useAccount();
|
const { db } = useStorage();
|
||||||
const { status, data: userFollows } = useQuery(
|
const { status, data: userFollows } = useQuery(
|
||||||
['userFollows', account.pubkey],
|
['userFollows', db.account.pubkey],
|
||||||
async () => {
|
async () => {
|
||||||
const keys = [];
|
const keys = [];
|
||||||
const user = ndk.getUser({ hexpubkey: account.pubkey });
|
const user = ndk.getUser({ hexpubkey: db.account.pubkey });
|
||||||
const follows = await user.follows();
|
const follows = await user.follows();
|
||||||
|
|
||||||
follows.forEach((item) => {
|
follows.forEach((item) => {
|
||||||
@ -27,7 +25,6 @@ export function useSocial() {
|
|||||||
return keys;
|
return keys;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: account ? true : false,
|
|
||||||
refetchOnReconnect: false,
|
refetchOnReconnect: false,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
@ -47,7 +44,7 @@ export function useSocial() {
|
|||||||
publish({ content: '', kind: 3, tags: tags });
|
publish({ content: '', kind: 3, tags: tags });
|
||||||
// invalid cache
|
// invalid cache
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ['userFollows', account.pubkey],
|
queryKey: ['userFollows', db.account.pubkey],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,26 +61,8 @@ export function useSocial() {
|
|||||||
publish({ content: '', kind: 3, tags: tags });
|
publish({ content: '', kind: 3, tags: tags });
|
||||||
// invalid cache
|
// invalid cache
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ['userFollows', account.pubkey],
|
queryKey: ['userFollows', db.account.pubkey],
|
||||||
});
|
});
|
||||||
|
|
||||||
// fetch events
|
|
||||||
const events = await ndk.fetchEvents({
|
|
||||||
authors: [pubkey],
|
|
||||||
kinds: [1, 6],
|
|
||||||
since: nHoursAgo(24),
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const event of events) {
|
|
||||||
await createNote(
|
|
||||||
event.id,
|
|
||||||
event.pubkey,
|
|
||||||
event.kind,
|
|
||||||
event.tags,
|
|
||||||
event.content,
|
|
||||||
event.created_at
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return { status, userFollows, follow, unfollow };
|
return { status, userFollows, follow, unfollow };
|
||||||
|
@ -2,7 +2,7 @@ import getUrls from 'get-urls';
|
|||||||
import { Event, parseReferences } from 'nostr-tools';
|
import { Event, parseReferences } from 'nostr-tools';
|
||||||
import ReactPlayer from 'react-player';
|
import ReactPlayer from 'react-player';
|
||||||
|
|
||||||
import { Content, LumeEvent } from '@utils/types';
|
import { LumeEvent, RichContent } from '@utils/types';
|
||||||
|
|
||||||
export function parser(event: LumeEvent) {
|
export function parser(event: LumeEvent) {
|
||||||
if (event.kind !== 1) return;
|
if (event.kind !== 1) return;
|
||||||
@ -10,8 +10,7 @@ export function parser(event: LumeEvent) {
|
|||||||
const references = parseReferences(event as unknown as Event);
|
const references = parseReferences(event as unknown as Event);
|
||||||
const urls = getUrls(event.content as unknown as string);
|
const urls = getUrls(event.content as unknown as string);
|
||||||
|
|
||||||
const content: Content = {
|
const content: RichContent = {
|
||||||
original: event.content as unknown as string,
|
|
||||||
parsed: event.content as unknown as string,
|
parsed: event.content as unknown as string,
|
||||||
notes: [],
|
notes: [],
|
||||||
images: [],
|
images: [],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { NDKTag } from '@nostr-dev-kit/ndk';
|
import { NDKTag } from '@nostr-dev-kit/ndk';
|
||||||
import destr from 'destr';
|
import { destr } from 'destr';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
export function truncateContent(str, n) {
|
export function truncateContent(str, n) {
|
||||||
|
8
src/utils/types.d.ts
vendored
8
src/utils/types.d.ts
vendored
@ -1,7 +1,6 @@
|
|||||||
import { NDKEvent, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
import { NDKEvent, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
||||||
|
|
||||||
export interface Content {
|
export interface RichContent {
|
||||||
original: string;
|
|
||||||
parsed: string;
|
parsed: string;
|
||||||
notes: string[];
|
notes: string[];
|
||||||
images: string[];
|
images: string[];
|
||||||
@ -10,10 +9,7 @@ export interface Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LumeEvent extends NDKEvent {
|
export interface LumeEvent extends NDKEvent {
|
||||||
event_id?: string;
|
richContent: RichContent;
|
||||||
parent_id?: string;
|
|
||||||
replies?: LumeEvent[];
|
|
||||||
content: Content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Account extends NDKUserProfile {
|
export interface Account extends NDKUserProfile {
|
||||||
|
Loading…
Reference in New Issue
Block a user