Skip to content

Upgrade to iced::Application to auto-delete expired blocks #2

@Singularityy0

Description

@Singularityy0

The Problem

Currently, our expire_timed_sites() function does a great job of cleaning up the blocklist, but it is only triggered during a manual update_hosts() cycle (e.g., when a user clicks "Add" or "Remove").

Because our UI is built using iced::Sandbox, the app is entirely synchronous and only reacts to direct user input. If the app is left running in the background, a timed block can expire, but the hosts file will not be automatically updated until the user interacts with the app window again.

The Task

To fix this, we need to introduce a background timer (a "Tick") that checks for expirations every second. This requires graduating the UI from a Sandbox to an Application.

  1. Change the Trait: In src/app.rs, change the implementation from Sandbox to Application.
  2. Add a Tick Message: Expand the Message enum to handle a time tick:
pub enum Message {
    UrlChanged(String),
    DurationChanged(String),
    AddSite,
    RemoveSite(String),
    ToggleBlocking,
    Tick(std::time::Instant),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions