Skip to content

Commit b61bf40

Browse files
feat: Update tray icons and enhance icon generation logic based on repository configuration
1 parent d4a4957 commit b61bf40

8 files changed

Lines changed: 37 additions & 7 deletions

File tree

src-tauri/icons/tray/icon-gray.png

319 Bytes
Loading
99 Bytes
Loading

src-tauri/icons/tray/icon-red.png

88 Bytes
Loading
Lines changed: 1 addition & 0 deletions
Loading

src-tauri/src/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,25 @@ fn main() {
4141
alert_count: Mutex::new(0),
4242
last_shown: Mutex::new(None),
4343
config: Mutex::new(config),
44+
dev_tools_open: Mutex::new(false),
4445
})
4546
.setup(|app| {
4647
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
4748
let show = MenuItem::with_id(app, "show", "Show Window", true, None::<&str>)?;
4849
let hide = MenuItem::with_id(app, "hide", "Hide Window", true, None::<&str>)?;
4950
let menu = Menu::with_items(app, &[&show, &hide, &quit])?;
5051

51-
let icon_data = generate_tray_icon(None);
52+
// Check if repos are configured
53+
let has_repos = {
54+
if let Some(state) = app.try_state::<AppState>() {
55+
let config = state.config.lock().unwrap();
56+
!config.selected_repos.is_empty()
57+
} else {
58+
false
59+
}
60+
};
61+
62+
let icon_data = generate_tray_icon(None, has_repos);
5263
let icon = Image::from_bytes(&icon_data)?;
5364

5465
// Check if user is authenticated

src-tauri/src/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ pub struct AppState {
66
pub alert_count: Mutex<usize>,
77
pub last_shown: Mutex<Option<Instant>>,
88
pub config: Mutex<AppConfig>,
9+
pub dev_tools_open: Mutex<bool>,
910
}

src-tauri/src/tray.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ const ICON_GRAY: &[u8] = include_bytes!("../icons/tray/icon-gray.png");
88
const ICON_GREEN: &[u8] = include_bytes!("../icons/tray/icon-green.png");
99
const ICON_RED: &[u8] = include_bytes!("../icons/tray/icon-red.png");
1010

11-
pub fn generate_tray_icon(count: Option<usize>) -> Vec<u8> {
11+
pub fn generate_tray_icon(count: Option<usize>, has_repos: bool) -> Vec<u8> {
12+
// If no repos are configured, always show gray
13+
if !has_repos {
14+
return ICON_GRAY.to_vec();
15+
}
16+
1217
match count {
1318
None => ICON_GRAY.to_vec(),
1419
Some(0) => ICON_GREEN.to_vec(),
@@ -26,13 +31,23 @@ pub async fn update_tray_icon(
2631
*count = alert_count;
2732
}
2833

29-
let icon_data = generate_tray_icon(Some(alert_count));
34+
// Check if any repos are selected
35+
let has_repos = if let Some(state) = app.try_state::<crate::state::AppState>() {
36+
let config = state.config.lock().unwrap();
37+
!config.selected_repos.is_empty()
38+
} else {
39+
false
40+
};
41+
42+
let icon_data = generate_tray_icon(Some(alert_count), has_repos);
3043

3144
if let Some(tray) = app.tray_by_id("main-tray") {
3245
let icon = Image::from_bytes(&icon_data).map_err(|e| e.to_string())?;
3346
tray.set_icon(Some(icon)).map_err(|e| e.to_string())?;
3447

35-
let tooltip = if alert_count == 0 {
48+
let tooltip = if !has_repos {
49+
"GitHub Security Alerts - No repositories configured".to_string()
50+
} else if alert_count == 0 {
3651
"GitHub Security Alerts - No alerts".to_string()
3752
} else {
3853
format!("GitHub Security Alerts - {} alert(s)!", alert_count)
@@ -41,7 +56,9 @@ pub async fn update_tray_icon(
4156
}
4257

4358
if let Some(window) = app.get_webview_window("main") {
44-
let title = if alert_count > 0 {
59+
let title = if !has_repos {
60+
"GitHub Alerts - Configure repositories".to_string()
61+
} else if alert_count > 0 {
4562
format!("GitHub Alerts - {} alert(s)", alert_count)
4663
} else {
4764
"GitHub Alerts".to_string()

src/app/shared/components/settings-panel/settings-panel.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $border-color: #2a2a4a;
3131
border-radius: 8px;
3232

3333
.user-icon {
34-
font-size: 28px;
34+
font-size: 22px;
3535
color: #4a90d9;
3636
}
3737

@@ -64,7 +64,7 @@ $border-color: #2a2a4a;
6464
gap: 8px;
6565

6666
i {
67-
font-size: 18px;
67+
font-size: 22px;
6868
}
6969

7070
&:hover {

0 commit comments

Comments
 (0)