gled-ui 2.32.1

gled's egui interface, shared by the desktop app and the browser
Documentation
//! Actions only the user interface handles, such as closing one of its
//! windows. They never leave the user interface's thread.

use std::cell::RefCell;

use egui::ViewportId;

thread_local! {
    static QUEUE: RefCell<Vec<LocalAction>> = const { RefCell::new(Vec::new()) };
}

#[derive(Debug)]
pub(crate) enum LocalAction {
    CloseWindow(ViewportId),
    OpenGitConfigWindow,
}

impl LocalAction {
    /// Queues the action for the next frame.
    pub(crate) fn enqueue(self) {
        QUEUE.with(|queue| queue.borrow_mut().push(self));
    }

    /// The queued actions, oldest first.
    pub(crate) fn take_all() -> Vec<Self> {
        QUEUE.with(|queue| std::mem::take(&mut *queue.borrow_mut()))
    }
}