fix user server future

This commit is contained in:
Evan Almloff committed 2024-02-02 18:01:57 -06:00
1 parent 1c4e1d84ea
commit 1afada528d
3 files changed
+13 -7

No files matched your search

@@ -18,8 +18,11 @@ where
// We're doing this regardless so inputs get tracked, even if we drop the future before polling it
let user_fut = cb.call();
let currently_in_first_run = first_run.cloned();
// If this is the first run and we are on the web client, the data might be cached
if *first_run.peek() {
if currently_in_first_run {
tracing::info!("First run of use_server_future");
// This is no longer the first run
first_run.set(false);
@@ -34,7 +37,7 @@ where
// If this is the first run and we are on the server, cache the data
#[cfg(feature = "ssr")]
if *first_run.peek() {
if currently_in_first_run {
let _ = crate::server_context::server_context().push_html_data(&out);
}
+4 -2
View File
@@ -1,7 +1,8 @@
#![allow(unused)]
use base64::Engine;
use std::{io::Cursor, sync::atomic::AtomicUsize};
use base64::engine::general_purpose::STANDARD;
use serde::{de::DeserializeOwned, Serialize};
pub(crate) mod deserialize;
@@ -45,8 +46,9 @@ impl HTMLDataCursor {
return None;
}
let mut cursor = &self.data[current];
let mut decoded = STANDARD.decode(cursor).unwrap();
self.index.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
match ciborium::from_reader(Cursor::new(cursor)) {
match ciborium::from_reader(Cursor::new(decoded)) {
Ok(x) => Some(x),
Err(e) => {
tracing::error!("Error deserializing data: {:?}", e);