Avoid re-render of player

This commit is contained in:
Mikko Ahlroth 2023-10-14 23:17:24 +03:00
parent 2672078e2c
commit 912fbf0c16
3 changed files with 43 additions and 32 deletions

View file

@ -2,16 +2,16 @@
# You typically do not need to edit this file
packages = [
{ name = "gleam_fetch", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib", "gleam_javascript"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "F64E93C754D948B2D37ABC4ADD5482FE0FAED4B99C79E66012DDE96BEDC40544" },
{ name = "gleam_fetch", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_http", "gleam_stdlib"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "F64E93C754D948B2D37ABC4ADD5482FE0FAED4B99C79E66012DDE96BEDC40544" },
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
{ name = "gleam_javascript", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "BFEBB63ABE4A1694E07DEFD19B160C2980304B5D775A89D4B02E7DE7C9D8008B" },
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
{ name = "gleam_stdlib", version = "0.31.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6D1BC5B4D4179B9FEE866B1E69FE180AC2CE485AD90047C0B32B2CA984052736" },
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
{ name = "lustre", version = "3.0.6", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "2D2BEF77B5966773467574C2DC23A27FAB7C720DEF428E72C610DA1547E7E171" },
{ name = "plinth", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_stdlib"], otp_app = "plinth", source = "hex", outer_checksum = "E81BA6A6CEAFFADBCB85B04DC817A4CDC43AFA7BB6AE56CE0B7C7E66D1C9ADD1" },
{ name = "lustre", version = "3.0.7", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "0C4763BEB8426DEFCCD96015CE2F0EF1446E26A731B614DDF3EA09BEF9BA8DB2" },
{ name = "plinth", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_javascript"], otp_app = "plinth", source = "hex", outer_checksum = "E81BA6A6CEAFFADBCB85B04DC817A4CDC43AFA7BB6AE56CE0B7C7E66D1C9ADD1" },
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
{ name = "varasto", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "plinth", "gleam_stdlib"], otp_app = "varasto", source = "hex", outer_checksum = "0621E5BFD0B9B7F7D19B8FC6369C6E2EAC5C1F3858A1E5E51342F5BCE10C3728" },
{ name = "varasto", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib", "plinth"], otp_app = "varasto", source = "hex", outer_checksum = "0621E5BFD0B9B7F7D19B8FC6369C6E2EAC5C1F3858A1E5E51342F5BCE10C3728" },
]
[requirements]

View file

@ -177,34 +177,44 @@ pub fn view(model: Model) {
let search_text = string.lowercase(model.search.search_text)
div(
[attribute.id("authed-view-content")],
[attribute.id("authed-view-wrapper")],
[
case model.loading_library {
True -> p([], [text("Loading library…")])
False -> text("")
},
tracks_view.render(
model.library,
[attribute.id("tracks-view"), start_play.on(StartPlay)],
),
div(
[attribute.id("search-positioner")],
[attribute.id("authed-view-library")],
[
search.view(model.search)
|> element.map(Search),
case model.loading_library {
True -> p([], [text("Loading library…")])
False -> text("")
},
tracks_view.render(
model.library,
[attribute.id("tracks-view"), start_play.on(StartPlay)],
),
],
),
case model.play_status {
HasTracks(PlayInfo(player: player, ..)) ->
div(
[attribute.id("authed-view-player")],
[
div(
[attribute.id("player")],
[attribute.id("search-positioner")],
[
player.view(player)
|> element.map(PlayerMsg),
search.view(model.search)
|> element.map(Search),
],
)
NoTracks -> text("")
},
),
case model.play_status {
HasTracks(PlayInfo(player: player, ..)) ->
div(
[attribute.id("player")],
[
player.view(player)
|> element.map(PlayerMsg),
],
)
NoTracks -> text("")
},
],
),
],
)
}

View file

@ -14,16 +14,22 @@ main {
overflow: hidden;
}
#authed-view-content {
#authed-view-wrapper {
height: calc(100vh - 2 * 10px);
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: stretch;
overflow: hidden;
gap: 10px;
}
#authed-view-library {
flex: 1 1;
overflow-y: auto;
}
#player {
}
@ -54,8 +60,3 @@ main {
#search-bar-input-wrapper input {
width: 100%;
}
tracks-view {
flex: 1 1;
overflow-y: auto;
}