Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Disclaimer
==========

( ˶°ㅁ°) !! **This is a fork of [stephanebouget/github-security-alerts](https://github.com/stephanebouget/github-security-alerts)**

The aim of this project is to submit evolutions.
This is not the official repository of the app.
You should not submit bug reports, issues or pull requests to this fork.

Last constributions from here:
- Improve DEVELOP file with Markdown rendering, and fix Rust version command ([#25](https://github.com/stephanebouget/github-security-alerts/issues/25), [#26](https://github.com/stephanebouget/github-security-alerts/pull/26))

# GitHub Security Alerts

👉 **Developers**: See [DEVELOP](./DEVELOP) | [CONTRIBUTING](./CONTRIBUTING)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"ng": "ng",
"start": "npm run tauri:serve",
"web:serve": "ng serve -o",
"web:serve": "ng serve",
"web:build": "ng build --base-href ./",
"web:dev": "npm run web:build",
"web:prod": "npm run web:build -- -c production",
Expand Down
66 changes: 66 additions & 0 deletions src-tauri/Cargo.lock

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

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tauri-plugin-single-instance = "^2.0"
tauri-plugin-autostart = "^2.0"
urlencoding = "^2.1"

[target.'cfg(target_os = "macos")'.dependencies]
objc2-app-kit = "0.3.2"

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
Expand Down
51 changes: 14 additions & 37 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod updater;
use config::load_config;
use state::AppState;
use tray::generate_tray_icon;
use window::{position_window_near_tray, handle_window_focus_lost, handle_window_show};
use window::{position_window_near_tray, set_macos_window_level};

fn main() {
// Load environment variables from .env file
Expand Down Expand Up @@ -65,12 +65,14 @@ fn main() {
))
.manage(AppState {
alert_count: Mutex::new(0),
last_shown: Mutex::new(None),
last_focus_lost: Mutex::new(None),
auto_hide_paused: Mutex::new(false),
config: Mutex::new(config),
})
.setup(|app| {
// On macOS, use Accessory policy so the window floats over all Spaces
// and is not bound to a single Space like a regular app window.
#[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Accessory);

// Enable autostart on first run
use tauri_plugin_autostart::ManagerExt;
let autostart_manager = app.autolaunch();
Expand All @@ -96,26 +98,13 @@ fn main() {
let icon_data = generate_tray_icon(None, has_repos);
let icon = Image::from_bytes(&icon_data)?;

// Check if user is authenticated
let is_authenticated = {
let state = app.state::<AppState>();
let config = state.config.lock().unwrap();
config.access_token.as_ref()
.map(|t| !t.trim().is_empty())
.unwrap_or(false)
};

// Show window if not authenticated, hide if already logged in
// Always show the window on startup — Angular handles the correct
// view (login vs alerts) based on auth status via checkAuthStatus()
if let Some(window) = app.get_webview_window("main") {
if is_authenticated {
let _ = window.hide();
} else {
// First time - show window for login
handle_window_show(app.handle());
position_window_near_tray(&window);
let _ = window.show();
let _ = window.set_focus();
}
set_macos_window_level(&window);
position_window_near_tray(&window);
let _ = window.show();
let _ = window.set_focus();
}


Expand Down Expand Up @@ -165,7 +154,7 @@ fn main() {
if window.is_visible().unwrap_or(false) {
let _ = window.hide();
} else {
handle_window_show(&app);
set_macos_window_level(&window);
position_window_near_tray(&window);
let _ = window.show();
let _ = window.set_focus();
Expand All @@ -179,21 +168,11 @@ fn main() {
Ok(())
})
.on_window_event(|window, event| {
// Intercept close — hide instead of quit (tray app)
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
let _ = window.hide();
api.prevent_close();
}
if let tauri::WindowEvent::Focused(focused) = event {
if !*focused {
handle_window_focus_lost(window);
} else {
// Window regained focus - clear the focus lost timestamp
if let Some(state) = window.app_handle().try_state::<AppState>() {
let mut last_focus_lost = state.last_focus_lost.lock().unwrap();
*last_focus_lost = None;
}
}
}
})
.invoke_handler(tauri::generate_handler![
auth::set_token,
Expand All @@ -209,8 +188,6 @@ fn main() {
alerts::get_github_security_alerts,
tray::update_tray_icon,
system::open_taskbar_settings,
window::pause_auto_hide,
window::resume_auto_hide,
updater::check_for_updates,
updater::install_update,
updater::get_current_version,
Expand Down
4 changes: 0 additions & 4 deletions src-tauri/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
*/

use std::sync::Mutex;
use std::time::Instant;
use crate::models::AppConfig;

pub struct AppState {
pub alert_count: Mutex<usize>,
pub last_shown: Mutex<Option<Instant>>,
pub last_focus_lost: Mutex<Option<Instant>>,
pub auto_hide_paused: Mutex<bool>,
pub config: Mutex<AppConfig>,
}
Loading
Loading