From 1556b372ce9bd31b718d80ca8f0b0b4da3df36ca Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 2 Apr 2021 23:00:39 +0100 Subject: [PATCH] movehist: Show on reload Move the data from Session to DataLoad where it should have been all alone, and actually use it. Signed-off-by: Ian Jackson --- daemon/session.rs | 4 ++-- templates/script.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/session.rs b/daemon/session.rs index 29af6336..8ddda535 100644 --- a/daemon/session.rs +++ b/daemon/session.rs @@ -24,7 +24,6 @@ struct SessionRenderContext { links: Html, player_info_pane: Html, fake_rng: bool, - movehist: movehist::PlHist, } #[derive(Debug,Serialize)] @@ -58,6 +57,7 @@ struct DataLoad { last_log_ts: String, players: HashMap, held_surround_colour: &'static str, + movehist: movehist::PlHist, } #[derive(Deserialize)] @@ -229,13 +229,13 @@ fn session_inner(form: Json, space_attrs: space_table_attrs(table_size).to_html(), rect_attrs: space_table_attrs(table_size).to_html(), nick, - movehist, sse_url_prefix, player_info_pane, ptoken: form.ptoken.clone(), links: (&*ig.links).into(), fake_rng: config().game_rng.is_fake(), load: serde_json::to_string(&DataLoad { + movehist, players: load_players, last_log_ts: timestamp_abbrev.unwrap_or_default(), held_surround_colour: HELD_SURROUND_COLOUR, diff --git a/templates/script.ts b/templates/script.ts index fc3af686..478a1acc 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -1529,6 +1529,10 @@ function startup() { last_log_ts = wasm_bindgen.timestamp_abbreviator(dataload.last_log_ts); + for (let ent of dataload.movehist.hist) { + movehist_record(ent); + } + var es = new EventSource( sse_url_prefix + "/_/updates?ctoken="+ctoken+'&gen='+gen ); -- 2.30.2