From ca93a00eda4c0c95fa644675f5c704106d8a656c Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Wed, 4 Nov 2020 16:18:38 +0000 Subject: [PATCH] "set palette" function --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 11225c8..f56f6d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,6 +94,16 @@ pub fn set_room_name(room_name: String) { } } +#[wasm_bindgen] +pub fn set_palette(palette_id: String) { + let mut state = STATE.lock().unwrap(); + + match palette_id.is_empty() { + true => { state.palette = None }, + false => { state.palette = Some(palette_id) }, + } +} + #[wasm_bindgen] pub fn add_room() -> String { let mut state = STATE.lock().expect("Couldn't lock application state");