Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion hyperprocess_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ fn generate_component_impl(
// Extract values from args for use in the quote macro
let name = &args.name;
let endpoints = &args.endpoints;
let _save_config = &args.save_config;
let save_config = &args.save_config;
let wit_world = &args.wit_world;

let icon = match &args.icon {
Expand Down Expand Up @@ -1132,6 +1132,13 @@ fn generate_component_impl(
// Initialize our state
let mut state = hyperware_app_common::initialize_state::<#self_ty>();

// Set to persist state according to user setting
hyperware_app_common::APP_CONTEXT.with(|ctx| {
ctx.borrow_mut().hidden_state = Some(
hyperware_app_common::HiddenState::new(#save_config)
);
});

// Set up necessary components
let app_name = #name;
let app_icon = #icon;
Expand Down
2 changes: 0 additions & 2 deletions hyperware_app_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ thread_local! {

pub static RESPONSE_REGISTRY: RefCell<HashMap<String, Vec<u8>>> = RefCell::new(HashMap::new());


pub static APP_HELPERS: RefCell<AppHelpers> = RefCell::new(AppHelpers {
current_path: None,
current_server: None,
Expand Down Expand Up @@ -405,7 +404,6 @@ where
if let Some(ref mut hidden_state) = ctx_mut.hidden_state {
if hidden_state.should_save_state() {
if let Ok(s_bytes) = rmp_serde::to_vec(state) {
kiprintln!("State persisted");
let _ = set_state(&s_bytes);
}
}
Expand Down