Skip to content

Commit 2aab654

Browse files
committed
Fix always-blocklist never starting the watchdog on its own
The watchdog only auto-launched at startup when a schedule was enabled, so a user with only permanent (always-blocked) entries and no schedule/session never got any enforcement at all - the hosts file just kept whatever stale entries a previous watchdog run had left, with nothing to reconcile it. Now also launches on startup when the always-blocklist has entries, and immediately when one is added while the app is already running.
1 parent cdc83c2 commit 2aab654

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎Umbra.App/MainWindow.xaml.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ public MainWindow()
3434
InitializeComponent();
3535
Title = "Umbra";
3636

37-
if (Periods.HasEnabledPeriod(Periods.Load()))
37+
// "Toujours bloqué" (AlwaysBlocklist) n'a besoin ni d'une session ni
38+
// d'une plage pour être pertinent - sans ce check, un utilisateur qui
39+
// n'a QUE des entrées permanentes (aucune plage activée) ne voyait
40+
// jamais le watchdog se lancer au démarrage, et le blocage restait
41+
// inerte tant qu'aucune session/plage ne le déclenchait par ailleurs.
42+
var always = AlwaysBlocklist.Load();
43+
if (Periods.HasEnabledPeriod(Periods.Load()) || always.Apps.Count > 0 || always.Sites.Count > 0)
3844
{
3945
WatchdogSupervisor.Ensure();
4046
}

‎Umbra.App/Pages/BlocklistPage.xaml.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ private void AlwaysAddItem()
380380
AlwaysBlocklist.Save(_alwaysData);
381381
AlwaysNewItemBox.Text = "";
382382
RenderAlways();
383+
// Sans session ni plage, rien d'autre ne déclenche le watchdog - sans
384+
// cet appel, une première entrée ajoutée pendant que l'app tourne
385+
// déjà (watchdog jamais lancé) resterait sans effet jusqu'au prochain
386+
// redémarrage de l'app.
387+
WatchdogSupervisor.Ensure();
383388
}
384389

385390
private void AlwaysPickRunningApp_Click(object sender, RoutedEventArgs e)
@@ -398,6 +403,7 @@ private void AlwaysPickRunningApp_Click(object sender, RoutedEventArgs e)
398403
_alwaysData.Apps.Add(picked);
399404
AlwaysBlocklist.Save(_alwaysData);
400405
RenderAlways();
406+
WatchdogSupervisor.Ensure();
401407
}
402408

403409
private void RemoveAlwaysApp(string app)

0 commit comments

Comments
 (0)