1786826782
This commit is contained in:
@@ -123,8 +123,14 @@ pub async fn hass(
|
|||||||
let s2c_tx = s2c_tx.clone();
|
let s2c_tx = s2c_tx.clone();
|
||||||
async move {
|
async move {
|
||||||
loop {
|
loop {
|
||||||
let ha_client = HaClient::from_environment().unwrap();
|
let Ok(ha_client) = HaClient::from_environment() else {
|
||||||
let events = ha_client.fetch_calendar_events().unwrap();
|
sleep(Duration::from_secs(30)).await;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let Ok(events) = ha_client.fetch_calendar_events() else {
|
||||||
|
sleep(Duration::from_secs(30)).await;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
s2c_tx.send(EventMessage::CalendarUpdated(events)).ok();
|
s2c_tx.send(EventMessage::CalendarUpdated(events)).ok();
|
||||||
sleep(Duration::from_secs(30)).await;
|
sleep(Duration::from_secs(30)).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ macro_rules! apply_model {
|
|||||||
let data = $app
|
let data = $app
|
||||||
.[<get_ $name>]();
|
.[<get_ $name>]();
|
||||||
|
|
||||||
let model = data
|
if let Some(model) = data
|
||||||
.as_any()
|
.as_any()
|
||||||
.downcast_ref::<VecModel<$ty>>()
|
.downcast_ref::<VecModel<$ty>>() {
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for entity in $entities.iter().filter($filter) {
|
for entity in $entities.iter().filter($filter) {
|
||||||
match model.iter().position(|item| item.id == entity.entity_id) {
|
match model.iter().position(|item| item.id == entity.entity_id) {
|
||||||
Some(index) => model.set_row_data(index, entity.into()),
|
Some(index) => model.set_row_data(index, entity.into()),
|
||||||
None => model.push(entity.into()),
|
None => model.push(entity.into()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ impl Platform for Trekstor {
|
|||||||
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
||||||
button: slint::platform::PointerEventButton::Left,
|
button: slint::platform::PointerEventButton::Left,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.is_just_released(KeyCode::BTN_TOUCH) {
|
if input.is_just_released(KeyCode::BTN_TOUCH) {
|
||||||
@@ -108,7 +108,7 @@ impl Platform for Trekstor {
|
|||||||
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
||||||
button: slint::platform::PointerEventButton::Left,
|
button: slint::platform::PointerEventButton::Left,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.is_down(KeyCode::BTN_TOUCH) {
|
if input.is_down(KeyCode::BTN_TOUCH) {
|
||||||
@@ -116,7 +116,7 @@ impl Platform for Trekstor {
|
|||||||
.try_dispatch_event(WindowEvent::PointerMoved {
|
.try_dispatch_event(WindowEvent::PointerMoved {
|
||||||
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
position: LogicalPosition::new(input.x as f32, input.y as f32),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.quit_flag.load(Ordering::SeqCst) {
|
if self.quit_flag.load(Ordering::SeqCst) {
|
||||||
|
|||||||
Reference in New Issue
Block a user