Always create UIThreadInner in UIThread

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-19 00:46:46 +10:00
parent ac492e6d8b
commit 417a10ca5d
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -96,11 +96,8 @@ pub struct UIThread(Option<UIThreadInner>);
impl UIThread { impl UIThread {
/// * `enable` - `true` to enable confirmation, `false` to disable it. /// * `enable` - `true` to enable confirmation, `false` to disable it.
pub fn new(enable: bool) -> Self { pub fn new(enable: bool) -> Self {
Self(if enable { let ui_thread = UIThreadInner::new();
Some(UIThreadInner::new()) Self(enable.then(|| ui_thread))
} else {
None
})
} }
pub async fn confirm(&mut self) -> Result<(), BinstallError> { pub async fn confirm(&mut self) -> Result<(), BinstallError> {