From 6f29df112b44bbcb679fa220aab71e852fdb510f Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Mon, 3 Jul 2023 11:49:49 +0700
Subject: [PATCH] update settings page
---
package.json | 1 +
pnpm-lock.yaml | 11 ++
src-tauri/Cargo.lock | 51 ++++++++-
src-tauri/Cargo.toml | 7 +-
...20040005_insert_last_login_to_settings.sql | 11 +-
src-tauri/src/main.rs | 2 +
src/app.tsx | 2 -
src/app/root.tsx | 3 +-
src/app/settings/account.tsx | 81 ++++++++++++-
src/app/settings/components/autoStart.tsx | 61 ++++++++++
src/app/settings/components/cacheTime.tsx | 43 +++++++
src/app/settings/components/version.tsx | 26 +++++
src/app/settings/general.tsx | 17 ++-
src/app/settings/shortcuts.tsx | 107 +++++++++++++++++-
src/app/settings/update.tsx | 7 --
src/libs/ndk.tsx | 2 +-
src/libs/storage.tsx | 23 +++-
src/main.tsx | 5 +-
src/shared/notes/preview/video.tsx | 3 +-
src/shared/relayProvider.tsx | 6 +-
src/shared/settingsLayout.tsx | 11 --
21 files changed, 440 insertions(+), 40 deletions(-)
create mode 100644 src/app/settings/components/autoStart.tsx
create mode 100644 src/app/settings/components/cacheTime.tsx
create mode 100644 src/app/settings/components/version.tsx
delete mode 100644 src/app/settings/update.tsx
diff --git a/package.json b/package.json
index b35861db..c7ee95a9 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
"slate-history": "^0.93.0",
"slate-react": "^0.94.2",
"tailwind-merge": "^1.13.2",
+ "tauri-plugin-autostart-api": "github:tauri-apps/tauri-plugin-autostart#v1",
"tauri-plugin-sql-api": "github:tauri-apps/tauri-plugin-sql",
"zustand": "^4.3.8"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 85045271..62a9a334 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -85,6 +85,9 @@ dependencies:
tailwind-merge:
specifier: ^1.13.2
version: 1.13.2
+ tauri-plugin-autostart-api:
+ specifier: github:tauri-apps/tauri-plugin-autostart#v1
+ version: github.com/tauri-apps/tauri-plugin-autostart/b331e5700ca2a5d340563efab7398c61812c69f7
tauri-plugin-sql-api:
specifier: github:tauri-apps/tauri-plugin-sql
version: github.com/tauri-apps/tauri-plugin-sql/45b46ee428f6c13a831d237d8b602349ad6b17a6
@@ -5530,6 +5533,14 @@ packages:
use-sync-external-store: 1.2.0(react@18.2.0)
dev: false
+ github.com/tauri-apps/tauri-plugin-autostart/b331e5700ca2a5d340563efab7398c61812c69f7:
+ resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-autostart/tar.gz/b331e5700ca2a5d340563efab7398c61812c69f7}
+ name: tauri-plugin-autostart-api
+ version: 0.0.0
+ dependencies:
+ '@tauri-apps/api': 1.4.0
+ dev: false
+
github.com/tauri-apps/tauri-plugin-sql/45b46ee428f6c13a831d237d8b602349ad6b17a6:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-sql/tar.gz/45b46ee428f6c13a831d237d8b602349ad6b17a6}
name: tauri-plugin-sql-api
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 5dd0c8e2..e7bbeb07 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -244,6 +244,17 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "auto-launch"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5904a4d734f0235edf29aab320a14899f3e090446e594ff96508a6215f76f89c"
+dependencies = [
+ "dirs",
+ "thiserror",
+ "winreg 0.10.1",
+]
+
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -864,6 +875,15 @@ dependencies = [
"crypto-common",
]
+[[package]]
+name = "dirs"
+version = "4.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
+dependencies = [
+ "dirs-sys",
+]
+
[[package]]
name = "dirs-next"
version = "2.0.0"
@@ -874,6 +894,17 @@ dependencies = [
"dirs-sys-next",
]
+[[package]]
+name = "dirs-sys"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
+dependencies = [
+ "libc",
+ "redox_users",
+ "winapi",
+]
+
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
@@ -2072,6 +2103,7 @@ dependencies = [
"sqlx-cli",
"tauri",
"tauri-build",
+ "tauri-plugin-autostart",
"tauri-plugin-single-instance",
"tauri-plugin-sql",
"tauri-plugin-store",
@@ -4063,10 +4095,23 @@ dependencies = [
"tauri-utils",
]
+[[package]]
+name = "tauri-plugin-autostart"
+version = "0.0.0"
+source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#36b7296746bf8d41f0790d8ecd9b097430750a47"
+dependencies = [
+ "auto-launch",
+ "log",
+ "serde",
+ "serde_json",
+ "tauri",
+ "thiserror",
+]
+
[[package]]
name = "tauri-plugin-single-instance"
version = "0.0.0"
-source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#dce0f02bc571128308c30278cde3233f341e6a50"
+source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#36b7296746bf8d41f0790d8ecd9b097430750a47"
dependencies = [
"log",
"serde",
@@ -4080,7 +4125,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-sql"
version = "0.0.0"
-source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#dce0f02bc571128308c30278cde3233f341e6a50"
+source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#36b7296746bf8d41f0790d8ecd9b097430750a47"
dependencies = [
"futures-core",
"log",
@@ -4096,7 +4141,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-store"
version = "0.0.0"
-source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#dce0f02bc571128308c30278cde3233f341e6a50"
+source = "git+https://github.com/tauri-apps/plugins-workspace?branch=v1#36b7296746bf8d41f0790d8ecd9b097430750a47"
dependencies = [
"log",
"serde",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 7def34e0..2ec80831 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -17,13 +17,14 @@ tauri-build = { version = "1.2", features = [] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = [ "clipboard-read-text", "clipboard-write-text", "dialog-open", "fs-read-dir", "fs-read-file", "http-all", "http-multipart", "notification-all", "os-all", "process-relaunch", "shell-open", "system-tray", "updater", "window-close", "window-start-dragging"] }
-tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
-tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
+tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
+tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
+tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
sqlx-cli = {version = "0.6.3", default-features = false, features = ["sqlite"] }
[dependencies.tauri-plugin-sql]
git = "https://github.com/tauri-apps/plugins-workspace"
-branch = "dev"
+branch = "v1"
features = ["sqlite"]
[target.'cfg(target_os = "macos")'.dependencies]
diff --git a/src-tauri/migrations/20230420040005_insert_last_login_to_settings.sql b/src-tauri/migrations/20230420040005_insert_last_login_to_settings.sql
index 7a8125d8..8d97644e 100644
--- a/src-tauri/migrations/20230420040005_insert_last_login_to_settings.sql
+++ b/src-tauri/migrations/20230420040005_insert_last_login_to_settings.sql
@@ -2,4 +2,13 @@
INSERT INTO
settings (key, value)
VALUES
- ("last_login", "0");
+ ("last_login", "0"),
+ (
+ "relays",
+ '["wss://relayable.org","wss://relay.damus.io","wss://relay.nostr.band/all","wss://relay.nostrgraph.net","wss://nostr.mutinywallet.com"]'
+ ),
+ ("auto_start", "0"),
+ ("cache_time", "86400"),
+ ("compose_shortcut", "meta+n"),
+ ("add_imageblock_shortcut", "meta+i"),
+ ("add_feedblock_shortcut", "meta+f")
\ No newline at end of file
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 5504befb..da718ff7 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -9,6 +9,7 @@ extern crate objc;
use tauri::{Manager, WindowEvent};
use tauri_plugin_sql::{Migration, MigrationKind};
+use tauri_plugin_autostart::MacosLauncher;
#[cfg(target_os = "macos")]
use window_ext::WindowExt;
@@ -109,6 +110,7 @@ fn main() {
)
.build(),
)
+ .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"])))
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
println!("{}, {argv:?}, {cwd}", app.package_info().name);
app
diff --git a/src/app.tsx b/src/app.tsx
index 684e28ef..bfa4f797 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -16,7 +16,6 @@ import { Root } from "@app/root";
import { AccountSettingsScreen } from "@app/settings/account";
import { GeneralSettingsScreen } from "@app/settings/general";
import { ShortcutsSettingsScreen } from "@app/settings/shortcuts";
-import { UpdateSettingsScreen } from "@app/settings/update";
import { SpaceScreen } from "@app/space";
import { TrendingScreen } from "@app/trending";
import { UserScreen } from "@app/user";
@@ -88,7 +87,6 @@ const router = createBrowserRouter([
{ path: "general", element:
Loading...
+ ) : ( +