diff --git a/package.json b/package.json index 14399053..c34c012f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@tauri-apps/plugin-notification": "github:tauri-apps/tauri-plugin-notification#v2", "@tauri-apps/plugin-os": "github:tauri-apps/tauri-plugin-os#v2", "@tauri-apps/plugin-process": "github:tauri-apps/tauri-plugin-process#v2", + "@tauri-apps/plugin-shell": "github:tauri-apps/tauri-plugin-shell#v2", "@tauri-apps/plugin-sql": "github:tauri-apps/tauri-plugin-sql#v2", "@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2", "@tauri-apps/plugin-stronghold": "github:tauri-apps/tauri-plugin-stronghold#v2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d68aff6..a52326b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,6 +61,9 @@ dependencies: '@tauri-apps/plugin-process': specifier: github:tauri-apps/tauri-plugin-process#v2 version: github.com/tauri-apps/tauri-plugin-process/ed3f8f78ddecc72c926239f5a10ec6ce1b8c353e + '@tauri-apps/plugin-shell': + specifier: github:tauri-apps/tauri-plugin-shell#v2 + version: github.com/tauri-apps/tauri-plugin-shell/ecff26b9c9c4084374dd12ddbe24fc77fe382990 '@tauri-apps/plugin-sql': specifier: github:tauri-apps/tauri-plugin-sql#v2 version: github.com/tauri-apps/tauri-plugin-sql/0591e9f63e0f86be79c209f4bcb564ccce4bd05c @@ -7743,6 +7746,14 @@ packages: '@tauri-apps/api': 2.0.0-alpha.5 dev: false + github.com/tauri-apps/tauri-plugin-shell/ecff26b9c9c4084374dd12ddbe24fc77fe382990: + resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-shell/tar.gz/ecff26b9c9c4084374dd12ddbe24fc77fe382990} + name: '@tauri-apps/plugin-shell' + version: 2.0.0-alpha.0 + dependencies: + '@tauri-apps/api': 2.0.0-alpha.5 + dev: false + github.com/tauri-apps/tauri-plugin-sql/0591e9f63e0f86be79c209f4bcb564ccce4bd05c: resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-sql/tar.gz/0591e9f63e0f86be79c209f4bcb564ccce4bd05c} name: '@tauri-apps/plugin-sql' diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1977e15f..a52027b8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2382,6 +2382,15 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + [[package]] name = "is-terminal" version = "0.4.9" @@ -2393,6 +2402,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "itertools" version = "0.10.5" @@ -2648,6 +2667,7 @@ dependencies = [ "tauri-plugin-notification", "tauri-plugin-os", "tauri-plugin-process", + "tauri-plugin-shell", "tauri-plugin-single-instance", "tauri-plugin-sql", "tauri-plugin-store", @@ -3067,6 +3087,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "open" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a083c0c7e5e4a8ec4176346cf61f67ac674e8bfb059d9226e1c54a96b377c12" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -3088,6 +3119,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "os_pipe" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "overload" version = "0.1.1" @@ -3155,6 +3196,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -4166,6 +4213,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shared_child" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "signal-hook" version = "0.3.17" @@ -5022,6 +5079,23 @@ dependencies = [ "tauri", ] +[[package]] +name = "tauri-plugin-shell" +version = "2.0.0-alpha.0" +source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v2#7f2e2dd5b8af2c8e7e224bed132e2b76da983818" +dependencies = [ + "encoding_rs", + "log", + "open", + "os_pipe", + "regex", + "serde", + "serde_json", + "shared_child", + "tauri", + "thiserror", +] + [[package]] name = "tauri-plugin-single-instance" version = "2.0.0-alpha.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 3bfae52b..00fc7de1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -16,7 +16,10 @@ tauri-build = { version = "2.0.0-alpha.6", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "2.0.0-alpha.10", features = [ "macos-private-api", "system-tray"] } +tauri = { version = "2.0.0-alpha.10", features = [ + "macos-private-api", + "system-tray", +] } tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } @@ -32,6 +35,7 @@ tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace" tauri-plugin-os = { 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-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } window-shadows = { git = "https://github.com/tauri-apps/window-shadows", branch = "dev" } window-vibrancy = { git = "https://github.com/tauri-apps/window-vibrancy", branch = "dev" } sqlx-cli = { version = "0.7.0", default-features = false, features = [ diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 928ce2e7..4052417b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -138,6 +138,7 @@ fn main() { .plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_window::init()) .plugin(tauri_plugin_store::Builder::default().build()) + .plugin(tauri_plugin_shell::init()) .setup(|app| { let window = app.get_window("main").unwrap(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e0210877..a4831bde 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -95,16 +95,16 @@ "windows": [ { "fullscreen": false, - "height": 800, "hiddenTitle": true, - "minHeight": 720, - "minWidth": 1080, + "minHeight": 400, + "minWidth": 500, "resizable": true, "theme": "Dark", "title": "Lume", "titleBarStyle": "Overlay", "transparent": true, - "width": 1080, + "width": 400, + "height": 500, "center": true } ], diff --git a/src/app/trending/components/profile.tsx b/src/app/trending/components/profile.tsx index bfe84f0e..390b7576 100644 --- a/src/app/trending/components/profile.tsx +++ b/src/app/trending/components/profile.tsx @@ -11,14 +11,23 @@ import { compactNumber } from '@utils/number'; import { shortenKey } from '@utils/shortenKey'; export function Profile({ data }: { data: any }) { - const { status, data: userStats } = useQuery(['user-stats', data.pubkey], async () => { - const res = await fetch(`https://api.nostr.band/v0/stats/profile/${data.pubkey}`); - return res.json(); - }); + const { status: socialStatus, userFollows, follow, unfollow } = useSocial(); + const { status, data: userStats } = useQuery( + ['user-stats', data.pubkey], + async () => { + const res = await fetch(`https://api.nostr.band/v0/stats/profile/${data.pubkey}`); + return res.json(); + }, + { + refetchOnMount: false, + refetchOnReconnect: false, + refetchOnWindowFocus: false, + staleTime: Infinity, + } + ); const embedProfile = data.profile ? JSON.parse(data.profile.content) : null; const profile = embedProfile; - const { status: socialStatus, userFollows, follow, unfollow } = useSocial(); const [followed, setFollowed] = useState(false); @@ -50,12 +59,13 @@ export function Profile({ data }: { data: any }) { } }, [status]); - if (!profile) + if (!profile) { return ( -
Can't fetch profile
Failed to fetch
} {status === 'loading' ? (Failed to fetch
} {status === 'loading' ? (