mod widget;

use crate::{Video, WidgetBuilder};
use gtk4::{Widget, prelude::*};

pub use widget::VideoWidget;

impl WidgetBuilder {
    pub(super) fn create_video(&self, video: Video) -> Widget {
        let ids = video.ids.clone();
        let widget = VideoWidget::create(video, self.image_downloader.clone()).upcast::<Widget>();

        for id in ids {
            tracing::trace!(id, "instert video into id_map");
            self.id_map.borrow_mut().insert(id, widget.clone());
        }

        widget
    }
}
