Skip to content

Commit d316c98

Browse files
committed
fix(weather): fix weather regression with tokio runtime preventing reqwest completing
also add refactor work to config lua watcher
1 parent 0df92fd commit d316c98

File tree

7 files changed

+201
-184
lines changed

7 files changed

+201
-184
lines changed

hitokage-core/src/components/bar.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub enum BarMsg {
135135
LuaHook(BarLuaHook),
136136
}
137137

138-
#[derive(Debug, Deserialize, Serialize)]
138+
#[derive(Debug, Deserialize, Serialize, PartialEq, Copy, Clone)]
139139
pub enum BarPosition {
140140
Top,
141141
Bottom,
@@ -205,10 +205,17 @@ impl Component for Bar {
205205

206206
// println!("{:?} {:?}", (model.geometry.height + &model.offset_y), height);
207207

208-
let _ = komorebi_client::send_message(&komorebi_client::SocketMessage::MonitorWorkAreaOffset(
209-
model.index,
210-
komorebi_client::Rect { left: 0, top: height, right: 0, bottom: height }
211-
));
208+
if (model.position.is_some_and(|pos| pos == BarPosition::Bottom)) {
209+
let _ = komorebi_client::send_message(&komorebi_client::SocketMessage::MonitorWorkAreaOffset(
210+
model.index,
211+
komorebi_client::Rect { left: 0, top: 0, right: 0, bottom: height }
212+
));
213+
} else {
214+
let _ = komorebi_client::send_message(&komorebi_client::SocketMessage::MonitorWorkAreaOffset(
215+
model.index,
216+
komorebi_client::Rect { left: 0, top: height, right: 0, bottom: height }
217+
));
218+
}
212219
},
213220

214221
connect_unrealize => move |_window| {

hitokage-lua/src/api/event.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use hitokage_core::components::app::{LuaHook, LuaHookType};
22
use hitokage_core::event::{CONFIG_UPDATE, EVENT, NEW_EVENT};
33
use mlua::{Lua, LuaSerdeExt, Value};
4-
use relm4::prelude::AsyncComponent;
5-
use relm4::AsyncComponentSender;
4+
use relm4::{Component, ComponentSender};
65

7-
pub fn make<C>(lua: &Lua, sender: &AsyncComponentSender<C>) -> anyhow::Result<mlua::Table>
6+
pub fn make<C>(lua: &Lua, sender: &ComponentSender<C>) -> anyhow::Result<mlua::Table>
87
where
9-
C: AsyncComponent<Input = crate::AppMsg>,
10-
<C as AsyncComponent>::Output: std::marker::Send,
8+
C: Component<Input = crate::AppMsg>,
9+
<C as Component>::Output: std::marker::Send,
1110
{
1211
let table = lua.create_table()?;
1312

hitokage-lua/src/components/bar.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use mlua::{
1414
Lua, LuaSerdeExt, UserData, UserDataMethods,
1515
Value::{self},
1616
};
17-
use relm4::prelude::AsyncComponent;
18-
use relm4::{AsyncComponentSender, Component, ComponentSender};
17+
use relm4::{Component, ComponentSender};
1918
use serde::Deserialize;
2019
use std::sync::{Arc, Mutex};
2120

@@ -135,10 +134,10 @@ impl UserData for BarUserData {
135134
}
136135
}
137136

138-
pub fn make<C>(lua: &Lua, sender: &AsyncComponentSender<C>) -> anyhow::Result<mlua::Table>
137+
pub fn make<C>(lua: &Lua, sender: &ComponentSender<C>) -> anyhow::Result<mlua::Table>
139138
where
140-
C: AsyncComponent<Input = crate::AppMsg>,
141-
<C as AsyncComponent>::Output: std::marker::Send,
139+
C: Component<Input = crate::AppMsg>,
140+
<C as Component>::Output: std::marker::Send,
142141
{
143142
let table = lua.create_table()?;
144143

@@ -155,7 +154,7 @@ where
155154

156155
let bar_sender: Arc<Mutex<Option<relm4::Sender<BarMsg>>>> = Arc::new(Mutex::new(None));
157156

158-
sender.input(<C as AsyncComponent>::Input::LuaHook(LuaHook {
157+
sender.input(<C as Component>::Input::LuaHook(LuaHook {
159158
t: LuaHookType::CreateBar(Box::new(monitor.clone()), props, {
160159
let bar_sender = Arc::clone(&bar_sender);
161160
{

hitokage-lua/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use components::bar;
33
use hitokage_core::components::app::AppMsg;
44
use luahelper::ValuePrinter;
55
use mlua::{AnyUserData, Lua, Table, Value, Variadic};
6-
use relm4::{prelude::AsyncComponent, AsyncComponentSender};
6+
use relm4::{Component, ComponentSender};
77
use std::fmt;
88

99
pub mod api;
@@ -83,10 +83,10 @@ async fn sleep_ms(_: Lua, milliseconds: u64) -> mlua::Result<()> {
8383
Ok(())
8484
}
8585

86-
pub fn make<C>(lua: mlua::Lua, sender: AsyncComponentSender<C>) -> anyhow::Result<mlua::Lua>
86+
pub fn make<C>(lua: mlua::Lua, sender: ComponentSender<C>) -> anyhow::Result<mlua::Lua>
8787
where
88-
C: AsyncComponent<Input = AppMsg>,
89-
<C as AsyncComponent>::Output: std::marker::Send,
88+
C: Component<Input = AppMsg>,
89+
<C as Component>::Output: std::marker::Send,
9090
{
9191
{
9292
let globals = lua.globals();

0 commit comments

Comments
 (0)