Skip to content

Commit

Permalink
Added some things and fixed some things
Browse files Browse the repository at this point in the history
  • Loading branch information
gianzellweger committed Feb 5, 2024
1 parent 692d129 commit 29f91ea
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 50 deletions.
35 changes: 17 additions & 18 deletions Cargo.lock

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

58 changes: 26 additions & 32 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,25 +335,14 @@ struct Account {
google_auth_secret: String,
}

#[derive(Savefile, Clone, Debug)]
#[derive(Savefile, Clone, Debug, Default)]
struct SaveData {
account: Option<Account>,
runs_so_far: usize,
last_update: u64, // This is in seconds since UNIX_EPOCH
dialogs_displayed: bool, // It makes sense to display them only once per device, as this is how it works in serious applications.
}

impl Default for SaveData {
fn default() -> Self {
Self {
account: None,
runs_so_far: 0,
last_update: SystemTime::now().duration_since(UNIX_EPOCH).expect("Damn bro what kinda system you running").as_secs(),
dialogs_displayed: false,
}
}
}

// These files are used to measure download speed. There are multiple
// because there are actual server outages and I don't want people to miss
// out on this one just because of such a tiny problem
Expand Down Expand Up @@ -467,20 +456,19 @@ fn sillyness(save_data: &mut SaveData) {
// }
// }
#[cfg(any(target_os = "linux", target_os = "windows"))]
{
jod_thread::spawn(|| {
tauri::Builder::default()
.any_thread()
.invoke_handler(tauri::generate_handler!(tauri_handler))
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|_app_handle, event| {
if let tauri::RunEvent::ExitRequested { api, .. } = event {
api.prevent_exit();
}
});
});
}
jod_thread::spawn(|| {
tauri::Builder::default()
.any_thread()
.invoke_handler(tauri::generate_handler!(tauri_handler))
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|_app_handle, event| {
if let tauri::RunEvent::ExitRequested { api, .. } = event {
api.prevent_exit();
}
});
})
.detach();

let has_internet = reqwest::blocking::get("https://google.com").is_ok(); // Googles servers are always up so I'm using them
if !has_internet {
Expand All @@ -496,27 +484,33 @@ fn sillyness(save_data: &mut SaveData) {
if !save_data_clone.dialogs_displayed {
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to access your contacts. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to access your contacts. Allow?"#)
.show_confirm();
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to access your location. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to access your location. Allow?"#)
.show_confirm();
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to make and receive phone calls on your behalf. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to make and receive phone calls on your behalf. Allow?"#)
.show_confirm();
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to manage incoming network connections. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to manage incoming network connections. Allow?"#)
.show_confirm();
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to access your passwords. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to access your passwords. Allow?"#)
.show_confirm();
let _ = native_dialog::MessageDialog::new()
.set_type(native_dialog::MessageType::Warning)
.set_title(r#""BadLang™" wants to access your liver. Allow?"#)
.set_title("BadLang™")
.set_text(r#""BadLang™" wants to access your liver. Allow?"#)
.show_confirm();
}
})
Expand Down

0 comments on commit 29f91ea

Please sign in to comment.