Remove redrawing on tick from ui
The `musicplayer` will update the state as needed, e.g. on an interval
This commit is contained in:
@@ -3,7 +3,6 @@ import gleam/erlang/process.{type Subject}
|
|||||||
import musicplayer/ui/layout.{type Section}
|
import musicplayer/ui/layout.{type Section}
|
||||||
|
|
||||||
pub type Control {
|
pub type Control {
|
||||||
Redraw
|
|
||||||
UpdateState(section: Section, content: String)
|
UpdateState(section: Section, content: String)
|
||||||
|
|
||||||
Exit(reply_to: Subject(Nil))
|
Exit(reply_to: Subject(Nil))
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ pub fn new() -> Result(Subject(Control), String) {
|
|||||||
redraw_on_update_loop(redraw)
|
redraw_on_update_loop(redraw)
|
||||||
})
|
})
|
||||||
|
|
||||||
process.spawn(fn() { redraw_on_tick_loop(ui, 1000) })
|
|
||||||
|
|
||||||
Ok(ui)
|
Ok(ui)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,10 +45,6 @@ fn handle_message(
|
|||||||
control: Control,
|
control: Control,
|
||||||
) -> actor.Next(State(redraw, layout), Control) {
|
) -> actor.Next(State(redraw, layout), Control) {
|
||||||
case control {
|
case control {
|
||||||
control.Redraw -> {
|
|
||||||
actor.send(state.redraw, state.layout)
|
|
||||||
actor.continue(state)
|
|
||||||
}
|
|
||||||
control.UpdateState(section, content) -> {
|
control.UpdateState(section, content) -> {
|
||||||
let layout = layout.update_section(state.layout, section, content)
|
let layout = layout.update_section(state.layout, section, content)
|
||||||
let state = State(..state, layout:)
|
let state = State(..state, layout:)
|
||||||
@@ -76,13 +70,6 @@ fn redraw_on_update_loop(redraw: Subject(Layout)) -> Nil {
|
|||||||
redraw_on_update_loop(redraw)
|
redraw_on_update_loop(redraw)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn redraw_on_tick_loop(ui: Subject(Control), interval_ms: Int) {
|
|
||||||
process.sleep(interval_ms)
|
|
||||||
process.send(ui, control.Redraw)
|
|
||||||
|
|
||||||
redraw_on_tick_loop(ui, interval_ms)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_layout(layout: Layout, from: Section) -> Nil {
|
fn render_layout(layout: Layout, from: Section) -> Nil {
|
||||||
case dict.get(layout.nodes, from) {
|
case dict.get(layout.nodes, from) {
|
||||||
Error(_) -> Nil
|
Error(_) -> Nil
|
||||||
|
|||||||
Reference in New Issue
Block a user