-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from opeolluwa/master
app-v0.6.19
- Loading branch information
Showing
19 changed files
with
452 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. | ||
|
||
export interface CommandData<T> { | ||
data: T | null; | ||
message: string; | ||
status: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. | ||
|
||
export interface TransferHistoryBuilder { fileName: string, fileSize: string, transactionType: string, recipient: string, } | ||
export interface TransferHistoryBuilder { | ||
fileName: string; | ||
fileSize: string; | ||
transactionType: string; | ||
recipient: string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* the audion module is responsible for parsing audio relater commands */ | ||
use super::*; | ||
static ACCEPTABLE_SUFFIXES: &[&str] = &[ | ||
"3gp", "aa", "aac", "aax", "act", "aiff", "alac", "amr", "ape", "au", "awb", "dss", "dvf", | ||
"flac", "gsm", "iklax", "ivs", "m4a", "m4b", "m4p", "mmf", "movpkg", "mp3", "mpc", "msv", | ||
"nmf", "ogg", "oga", "mogg", "opus", "ra", "rm", "raw", "rf64", "sln", "tta", "voc", "vox", | ||
"wav", "wma", "wv", "webm", "8svx", "cda", | ||
]; | ||
|
||
// get the audio file from the default audio dir of the OS | ||
// return an instance of the CommandData and vector of the path if any | ||
#[tauri::command] | ||
pub fn fetch_audio() -> Result<CommandData<Vec<File>>, CommandData<()>> { | ||
// if there is an error getting the audio path, fire an error | ||
let audio_dir = dirs::audio_dir(); | ||
let Some(audio_dir) = audio_dir else { | ||
return Err(CommandData::err("error getting the audio dir", ())); | ||
}; | ||
|
||
let entries = search_files("*", &audio_dir) | ||
.into_iter() | ||
.filter(|f| ACCEPTABLE_SUFFIXES.contains(&f.file_format.as_str())) | ||
.collect(); | ||
|
||
Ok(CommandData::ok("retrieved all audio files", entries)) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::{fetch_audio, ACCEPTABLE_SUFFIXES}; | ||
#[test] // see if there are files in the audio directory path | ||
fn _fetch_audio_files_() { | ||
let aud_files = fetch_audio().ok(); | ||
assert!(aud_files.is_some()); | ||
|
||
let aud_files = aud_files.unwrap().data.unwrap(); | ||
for file in aud_files { | ||
let file_format = file.file_format; | ||
assert!(ACCEPTABLE_SUFFIXES.contains(&file_format.as_str())); | ||
} | ||
} | ||
} |
Oops, something went wrong.