|
|
@ -27,7 +27,14 @@ fn fetchThread(state: *AppState) !void { |
|
|
|
var curl = Curl.init() orelse return; |
|
|
|
var curl = Curl.init() orelse return; |
|
|
|
defer curl.deinit(); |
|
|
|
defer curl.deinit(); |
|
|
|
|
|
|
|
|
|
|
|
while (state.departure_screen_state.fetch_thread != null) { |
|
|
|
while (true) { |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
state.departure_screen_state.mutex.lock(); |
|
|
|
|
|
|
|
defer state.departure_screen_state.mutex.unlock(); |
|
|
|
|
|
|
|
if (state.departure_screen_state.fetch_thread == null) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var fetch_anyway = state.departure_screen_state.should_refresh; |
|
|
|
var fetch_anyway = state.departure_screen_state.should_refresh; |
|
|
|
if (state.departure_screen_state.last_refresh_time + 30000 < std.time.milliTimestamp()) { |
|
|
|
if (state.departure_screen_state.last_refresh_time + 30000 < std.time.milliTimestamp()) { |
|
|
|
fetch_anyway = true; |
|
|
|
fetch_anyway = true; |
|
|
@ -635,6 +642,9 @@ pub fn render(state: *AppState) !void { |
|
|
|
switch (key) { |
|
|
|
switch (key) { |
|
|
|
rl.KEY_LEFT => { |
|
|
|
rl.KEY_LEFT => { |
|
|
|
state.screen = .home; |
|
|
|
state.screen = .home; |
|
|
|
|
|
|
|
ds.mutex.lock(); |
|
|
|
|
|
|
|
defer ds.mutex.unlock(); |
|
|
|
|
|
|
|
ds.fetch_thread = null; |
|
|
|
}, |
|
|
|
}, |
|
|
|
rl.KEY_R => { |
|
|
|
rl.KEY_R => { |
|
|
|
ds.should_refresh = true; |
|
|
|
ds.should_refresh = true; |
|
|
@ -666,7 +676,10 @@ pub fn render(state: *AppState) !void { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ds.mutex.lock(); |
|
|
|
ds.mutex.lock(); |
|
|
|
defer ds.mutex.unlock(); |
|
|
|
defer { |
|
|
|
|
|
|
|
ds.mutex.unlock(); |
|
|
|
|
|
|
|
_ = std.Thread.yield() catch null; |
|
|
|
|
|
|
|
} |
|
|
|
switch (ds.render_style) { |
|
|
|
switch (ds.render_style) { |
|
|
|
.db1 => try draw_db1(state), |
|
|
|
.db1 => try draw_db1(state), |
|
|
|
.ns => try draw_ns(state), |
|
|
|
.ns => try draw_ns(state), |
|
|
|