feat: small code cleanup

This commit is contained in:
Gabriele Musco 2023-06-20 22:12:11 +02:00
parent b938230922
commit dcece17445
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
3 changed files with 10 additions and 13 deletions

View file

@ -74,7 +74,7 @@ pub struct App {
#[derive(Debug)]
pub enum Msg {
UpdateView,
ClockTicking,
BuildProfile,
EnableDebugViewChanged(bool),
DoStartStopXRService,
@ -151,7 +151,7 @@ impl SimpleComponent for App {
self.reset();
match message {
Msg::UpdateView => {
Msg::ClockTicking => {
match &mut self.xrservice_runner {
None => {}
Some(runner) => {
@ -407,7 +407,6 @@ impl SimpleComponent for App {
selected_profile: config.get_selected_profile(&profiles),
})
.forward(sender.input_sender(), |message| match message {
MainViewOutMsg::UpdateView => Msg::UpdateView,
MainViewOutMsg::EnableDebugViewChanged(val) => Msg::EnableDebugViewChanged(val),
MainViewOutMsg::DoStartStopXRService => Msg::DoStartStopXRService,
MainViewOutMsg::ProfileSelected(name) => Msg::ProfileSelected(name),
@ -418,7 +417,7 @@ impl SimpleComponent for App {
enable_debug_view: config.debug_view_enabled,
})
.forward(sender.input_sender(), |message| match message {
_ => Msg::UpdateView,
_ => Msg::ClockTicking,
}),
about_dialog: AboutDialog::builder()
.transient_for(root)
@ -496,7 +495,7 @@ impl SimpleComponent for App {
let timer_sender = sender.clone();
glib::timeout_add_local(Duration::from_millis(1000), move || {
timer_sender.input(Msg::UpdateView);
timer_sender.input(Msg::ClockTicking);
return glib::Continue(true);
});

View file

@ -7,7 +7,7 @@ use crate::{
};
use gtk::prelude::*;
use relm4::prelude::*;
use std::{cell::Cell, thread::JoinHandle};
use std::thread::JoinHandle;
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum InstallWivrnStatus {
@ -21,7 +21,7 @@ pub struct InstallWivrnBox {
selected_profile: Profile,
install_wivrn_status: InstallWivrnStatus,
#[tracker::do_not_track]
download_thread: Cell<Option<JoinHandle<Result<(), reqwest::Error>>>>,
download_thread: Option<JoinHandle<Result<(), reqwest::Error>>>,
#[tracker::do_not_track]
install_runner: Option<Runner>,
}
@ -135,10 +135,9 @@ impl SimpleComponent for InstallWivrnBox {
match message {
Self::Input::ClockTicking => {
if self.download_thread.get_mut().is_some() {
if self.download_thread.is_some() {
let finished = self
.download_thread
.get_mut()
.as_ref()
.unwrap()
.is_finished();
@ -173,10 +172,10 @@ impl SimpleComponent for InstallWivrnBox {
}
Self::Input::DownloadWivrn => {
self.set_install_wivrn_status(InstallWivrnStatus::InProgress);
self.download_thread.set(Some(download_file(
self.download_thread = Some(download_file(
"https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-oculus-release.apk".into(),
wivrn_apk_download_path()
)));
));
}
Self::Input::InstallWivrnApk => {
let mut runner = get_adb_install_runner(&wivrn_apk_download_path());
@ -197,7 +196,7 @@ impl SimpleComponent for InstallWivrnBox {
let model = Self {
selected_profile: init.selected_profile,
install_wivrn_status: InstallWivrnStatus::Done(None),
download_thread: Cell::new(None),
download_thread: None,
install_runner: None,
tracker: 0,
};

View file

@ -44,7 +44,6 @@ pub enum MainViewMsg {
#[derive(Debug)]
pub enum MainViewOutMsg {
UpdateView,
EnableDebugViewChanged(bool),
DoStartStopXRService,
ProfileSelected(String),