Skip to content

Commit

Permalink
#31 Refactor to Components (#32)
Browse files Browse the repository at this point in the history
* Add Image Deletion
* Remove most of global state
* Make functions pure
* Switch to NPM
---------

Co-authored-by: Kawsar Ahmed <[email protected]>
  • Loading branch information
alvinosh and prokawsar authored May 29, 2024
1 parent 57a69e2 commit 9bd2f77
Show file tree
Hide file tree
Showing 24 changed files with 518 additions and 439 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
pkg-config
- name: Fetch Node.js dependencies
run: yarn
run: npm install

- name: Build Release version
run: yarn tauri build
run: npm run tauri build

- name: Release AppImage
uses: ncipollo/release-action@v1
Expand Down
83 changes: 83 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ tauri-build = { version = "1.5.1", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.1", features = [
trash = "4.1.0"
tauri = { version = "1.6.1", features = [ "fs-remove-file",
"protocol-asset",
"fs-read-file",
"fs-read-dir",
"dialog-open",
"devtools"
] }

[features]
Expand Down
21 changes: 13 additions & 8 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
use std::{fs::{self}, time::{Duration, SystemTime}};
use serde::Serialize;

#[derive(Serialize)]
struct MetadataInfo {
file_type: String,
file_size: u64,
created_time: String,
modified_time: String,
accessed_time: String,
}


#[tauri::command]
fn get_file_metadata(file_path: String) -> Result<MetadataInfo, String> {
Expand Down Expand Up @@ -40,19 +49,15 @@ fn get_file_metadata(file_path: String) -> Result<MetadataInfo, String> {
}
}

#[derive(Serialize)]
struct MetadataInfo {
file_type: String,
file_size: u64,
created_time: String,
modified_time: String,
accessed_time: String,
#[tauri::command]
fn move_file_to_trash(file_path: String) -> Result<(), String> {
trash::delete(&file_path).map_err(|e| e.to_string())
}


fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![get_file_metadata])
.invoke_handler(tauri::generate_handler![get_file_metadata, move_file_to_trash])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"readDir": true,
"readFile": true,
"removeDir": false,
"removeFile": false,
"removeFile": true,
"renameFile": false,
"scope": [],
"writeFile": false
Expand Down
7 changes: 7 additions & 0 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inria+Sans:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap"
rel="stylesheet"
/>

%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
Expand Down
Loading

0 comments on commit 9bd2f77

Please sign in to comment.