Revert "feat(sync): add modules for pairing and syncing clipboard data"

This commit is contained in:
PandaDEV 2025-01-29 20:43:49 +01:00 committed by GitHub
parent 0a17a789c2
commit f7f41b1513
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 68 additions and 181 deletions

2
.gitignore vendored
View file

@ -25,4 +25,4 @@ logs
bun.lockb bun.lockb
.gitignore .gitignore
.vscode .vscode
bun.lock .aider*

View file

@ -11,10 +11,10 @@
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "2.2.0", "@tauri-apps/api": "2.2.0",
"@tauri-apps/cli": "2.2.7", "@tauri-apps/cli": "2.2.5",
"@tauri-apps/plugin-autostart": "2.2.0", "@tauri-apps/plugin-autostart": "2.2.0",
"@tauri-apps/plugin-os": "2.2.0", "@tauri-apps/plugin-os": "2.2.0",
"nuxt": "3.15.4", "nuxt": "3.15.2",
"overlayscrollbars": "2.10.1", "overlayscrollbars": "2.10.1",
"overlayscrollbars-vue": "0.5.9", "overlayscrollbars-vue": "0.5.9",
"sass-embedded": "1.83.4", "sass-embedded": "1.83.4",

189
src-tauri/Cargo.lock generated
View file

@ -1296,15 +1296,6 @@ dependencies = [
"dirs-sys 0.4.1", "dirs-sys 0.4.1",
] ]
[[package]]
name = "dirs"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
dependencies = [
"dirs-sys 0.5.0",
]
[[package]] [[package]]
name = "dirs-sys" name = "dirs-sys"
version = "0.3.7" version = "0.3.7"
@ -1312,7 +1303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [ dependencies = [
"libc", "libc",
"redox_users 0.4.5", "redox_users",
"winapi", "winapi",
] ]
@ -1324,22 +1315,10 @@ checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
dependencies = [ dependencies = [
"libc", "libc",
"option-ext", "option-ext",
"redox_users 0.4.5", "redox_users",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "dirs-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
dependencies = [
"libc",
"option-ext",
"redox_users 0.5.0",
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@ -1715,9 +1694,9 @@ dependencies = [
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -1730,9 +1709,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -1740,15 +1719,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]] [[package]]
name = "futures-executor" name = "futures-executor"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-task", "futures-task",
@ -1768,9 +1747,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-io" name = "futures-io"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]] [[package]]
name = "futures-lite" name = "futures-lite"
@ -1787,9 +1766,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1798,21 +1777,21 @@ dependencies = [
[[package]] [[package]]
name = "futures-sink" name = "futures-sink"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.31" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -1987,15 +1966,13 @@ dependencies = [
] ]
[[package]] [[package]]
name = "getrandom" name = "ghash"
version = "0.3.1" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
dependencies = [ dependencies = [
"cfg-if", "opaque-debug",
"libc", "polyval",
"wasi 0.13.3+wasi-0.2.2",
"windows-targets 0.52.6",
] ]
[[package]] [[package]]
@ -3701,9 +3678,9 @@ dependencies = [
[[package]] [[package]]
name = "os_info" name = "os_info"
version = "3.9.2" version = "3.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e6520c8cc998c5741ee68ec1dc369fc47e5f0ea5320018ecf2a1ccd6328f48b" checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",
@ -4053,7 +4030,7 @@ version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
dependencies = [ dependencies = [
"zerocopy 0.7.35", "zerocopy",
] ]
[[package]] [[package]]
@ -4174,7 +4151,7 @@ dependencies = [
"log", "log",
"meta_fetcher", "meta_fetcher",
"parking_lot", "parking_lot",
"rand 0.9.0", "rand 0.8.5",
"rdev", "rdev",
"regex", "regex",
"reqwest", "reqwest",
@ -4316,17 +4293,6 @@ dependencies = [
"rand_core 0.6.4", "rand_core 0.6.4",
] ]
[[package]]
name = "rand"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
dependencies = [
"rand_chacha 0.9.0",
"rand_core 0.9.0",
"zerocopy 0.8.14",
]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.2.2" version = "0.2.2"
@ -4347,16 +4313,6 @@ dependencies = [
"rand_core 0.6.4", "rand_core 0.6.4",
] ]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core 0.9.0",
]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.5.1" version = "0.5.1"
@ -4375,16 +4331,6 @@ dependencies = [
"getrandom 0.2.15", "getrandom 0.2.15",
] ]
[[package]]
name = "rand_core"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff"
dependencies = [
"getrandom 0.3.1",
"zerocopy 0.8.14",
]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.2.0" version = "0.2.0"
@ -4524,17 +4470,6 @@ dependencies = [
"thiserror 1.0.63", "thiserror 1.0.63",
] ]
[[package]]
name = "redox_users"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
dependencies = [
"getrandom 0.2.15",
"libredox",
"thiserror 2.0.3",
]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.11.1" version = "1.11.1"
@ -4944,9 +4879,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.138" version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b"
dependencies = [ dependencies = [
"itoa 1.0.11", "itoa 1.0.11",
"memchr", "memchr",
@ -5546,9 +5481,9 @@ dependencies = [
[[package]] [[package]]
name = "sys-locale" name = "sys-locale"
version = "0.3.2" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" checksum = "e801cf239ecd6ccd71f03d270d67dd53d13e90aab208bf4b8fe4ad957ea949b0"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -5655,13 +5590,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.2.5" version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a998b6be84104ca05c7e9a21f2180ddec020c8b84ea59a8fc8530a2a19588d" checksum = "78f6efc261c7905839b4914889a5b25df07f0ff89c63fb4afd6ff8c96af15e4d"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
"dirs 6.0.0", "dirs 5.0.1",
"dunce", "dunce",
"embed_plist", "embed_plist",
"futures-util", "futures-util",
@ -5779,9 +5714,9 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin" name = "tauri-plugin"
version = "2.0.4" version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5841b9a0200e954ef7457f8d327091424328891e267a97b641dc246cc54d0dec" checksum = "b2e6660a409963e4d57b9bfab4addd141eeff41bd3a7fb14e13004a832cf7ef6"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"glob", "glob",
@ -5797,12 +5732,12 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-aptabase" name = "tauri-plugin-aptabase"
version = "0.5.1" version = "0.5.1"
source = "git+https://github.com/0PandaDEV/tauri-plugin-aptabase?branch=v2#c843c6b5b814fcc9daeb3f7fe4c67276c38bc6dd" source = "git+https://github.com/aptabase/tauri-plugin-aptabase?branch=v2#373abe1954bf20152082e506d36be07727259bb5"
dependencies = [ dependencies = [
"futures", "futures",
"log", "log",
"os_info", "os_info",
"rand 0.9.0", "rand 0.8.5",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
@ -5952,9 +5887,9 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-updater" name = "tauri-plugin-updater"
version = "2.4.0" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad3de2b9203bb00b9765e637a9878aaace34df40ae484878b8cea7a5bd5f9188" checksum = "ce2d39224390c41ba544f02b4f1721f42256320b3fb8c371e9425cbddeb4a68c"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"dirs 5.0.1", "dirs 5.0.1",
@ -6717,15 +6652,6 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.13.3+wasi-0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
dependencies = [
"wit-bindgen-rt",
]
[[package]] [[package]]
name = "wasite" name = "wasite"
version = "0.1.0" version = "0.1.0"
@ -7411,15 +7337,6 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "wit-bindgen-rt"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
dependencies = [
"bitflags 2.8.0",
]
[[package]] [[package]]
name = "write16" name = "write16"
version = "1.0.0" version = "1.0.0"
@ -7646,16 +7563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"zerocopy-derive 0.7.35", "zerocopy-derive",
]
[[package]]
name = "zerocopy"
version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468"
dependencies = [
"zerocopy-derive 0.8.14",
] ]
[[package]] [[package]]
@ -7669,17 +7577,6 @@ dependencies = [
"syn 2.0.87", "syn 2.0.87",
] ]
[[package]]
name = "zerocopy-derive"
version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]] [[package]]
name = "zerofrom" name = "zerofrom"
version = "0.1.4" version = "0.1.4"

View file

@ -10,31 +10,27 @@ rust-version = "1.70"
tauri-build = { version = "2.0.5", features = [] } tauri-build = { version = "2.0.5", features = [] }
[dependencies] [dependencies]
tauri = { version = "2.2.5", features = [ tauri = { version = "2.2.3", features = [
"macos-private-api", "macos-private-api",
"tray-icon", "tray-icon",
"image-png", "image-png"
] } ] }
tauri-plugin-sql = { version = "2.2.0", features = ["sqlite"] } tauri-plugin-sql = { version = "2.2.0", features = ["sqlite"] }
tauri-plugin-autostart = "2.2.0" tauri-plugin-autostart = "2.2.0"
tauri-plugin-os = "2.2.0" tauri-plugin-os = "2.2.0"
tauri-plugin-updater = "2.4.0" tauri-plugin-updater = "2.3.1"
tauri-plugin-dialog = "2.2.0" tauri-plugin-dialog = "2.2.0"
tauri-plugin-fs = "2.2.0" tauri-plugin-fs = "2.2.0"
tauri-plugin-clipboard = "2.1.11" tauri-plugin-clipboard = "2.1.11"
tauri-plugin-prevent-default = "1.0.2" tauri-plugin-prevent-default = "1.0.2"
tauri-plugin-global-shortcut = "2.2.0" tauri-plugin-global-shortcut = "2.2.0"
tauri-plugin-aptabase = { git = "https://github.com/0PandaDEV/tauri-plugin-aptabase", branch = "v2" } tauri-plugin-aptabase = { git = "https://github.com/aptabase/tauri-plugin-aptabase", branch = "v2" }
sqlx = { version = "0.8.3", features = [ sqlx = { version = "0.8.3", features = ["runtime-tokio-native-tls", "sqlite", "chrono"] }
"runtime-tokio-native-tls",
"sqlite",
"chrono",
] }
serde = { version = "1.0.217", features = ["derive"] } serde = { version = "1.0.217", features = ["derive"] }
tokio = { version = "1.43.0", features = ["full"] } tokio = { version = "1.43.0", features = ["full"] }
serde_json = "1.0.138" serde_json = "1.0.137"
rdev = "0.5.3" rdev = "0.5.3"
rand = "0.9.0" rand = "0.8.5"
base64 = "0.22.1" base64 = "0.22.1"
image = "0.25.5" image = "0.25.5"
reqwest = { version = "0.12.12", features = ["json", "blocking"] } reqwest = { version = "0.12.12", features = ["json", "blocking"] }

View file

@ -33,8 +33,6 @@ pub async fn write_and_paste(
match content_type.as_str() { match content_type.as_str() {
"text" => clipboard.write_text(content).map_err(|e| e.to_string())?, "text" => clipboard.write_text(content).map_err(|e| e.to_string())?,
"link" => clipboard.write_text(content).map_err(|e| e.to_string())?,
"color" => clipboard.write_text(content).map_err(|e| e.to_string())?,
"image" => { "image" => {
clipboard.write_image_base64(content).map_err(|e| e.to_string())?; clipboard.write_image_base64(content).map_err(|e| e.to_string())?;
} }

View file

@ -18,10 +18,9 @@ struct HotkeyState {
registered_hotkey: Option<HotKey>, registered_hotkey: Option<HotKey>,
} }
unsafe impl Send for HotkeyState {}
pub fn setup(app_handle: tauri::AppHandle) { pub fn setup(app_handle: tauri::AppHandle) {
let state = Arc::new(Mutex::new(HotkeyState::default())); let state = Arc::new(Mutex::new(HotkeyState::default()));
let manager = match GlobalHotKeyManager::new() { let manager = match GlobalHotKeyManager::new() {
Ok(manager) => manager, Ok(manager) => manager,
Err(err) => { Err(err) => {
@ -44,7 +43,7 @@ pub fn setup(app_handle: tauri::AppHandle) {
eprintln!("Error registering initial shortcut: {:?}", e); eprintln!("Error registering initial shortcut: {:?}", e);
} }
let state_clone = Arc::clone(&state); let state_clone = state.clone();
app_handle.listen("update-shortcut", move |event| { app_handle.listen("update-shortcut", move |event| {
let payload_str = event.payload().replace("\\\"", "\""); let payload_str = event.payload().replace("\\\"", "\"");
let trimmed_str = payload_str.trim_matches('"'); let trimmed_str = payload_str.trim_matches('"');
@ -56,7 +55,7 @@ pub fn setup(app_handle: tauri::AppHandle) {
} }
}); });
let state_clone = Arc::clone(&state); let state_clone = state.clone();
app_handle.listen("save_keybind", move |event| { app_handle.listen("save_keybind", move |event| {
let payload_str = event.payload().to_string(); let payload_str = event.payload().to_string();
unregister_current_hotkey(&state_clone); unregister_current_hotkey(&state_clone);

View file

@ -1,19 +1,16 @@
use crate::utils::types::{ ContentType, HistoryItem }; use crate::utils::types::{ ContentType, HistoryItem };
use base64::{ engine::general_purpose::STANDARD, Engine }; use base64::{ engine::general_purpose::STANDARD, Engine };
use rand::{ rng, Rng }; use rand::distributions::Alphanumeric;
use rand::distr::Alphanumeric; use rand::{ thread_rng, Rng };
use sqlx::{ Row, SqlitePool }; use sqlx::{ Row, SqlitePool };
use std::fs; use std::fs;
use tauri_plugin_aptabase::EventTracker; use tauri_plugin_aptabase::EventTracker;
pub async fn initialize_history(pool: &SqlitePool) -> Result<(), Box<dyn std::error::Error>> { pub async fn initialize_history(pool: &SqlitePool) -> Result<(), Box<dyn std::error::Error>> {
let id: String = rng() let id: String = thread_rng().sample_iter(&Alphanumeric).take(16).map(char::from).collect();
.sample_iter(&Alphanumeric)
.take(16)
.map(char::from)
.collect();
sqlx::query( sqlx
::query(
"INSERT INTO history (id, source, content_type, content, timestamp) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)" "INSERT INTO history (id, source, content_type, content, timestamp) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)"
) )
.bind(id) .bind(id)