This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use crate::components::layout::Layout;
|
||||
use perseus::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use sycamore::prelude::*;
|
||||
|
||||
// Reactive page
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::components::layout::Layout;
|
||||
use perseus::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use sycamore::prelude::*;
|
||||
|
||||
// Reactive page
|
||||
|
||||
@@ -1,22 +1,46 @@
|
||||
use crate::components::layout::Layout;
|
||||
use perseus::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
#[cfg(engine)]
|
||||
use crate::data::store::DATA;
|
||||
#[cfg(engine)]
|
||||
use std::thread;
|
||||
use sycamore::prelude::*;
|
||||
|
||||
use crate::data::pool_match::{
|
||||
PoolMatchList, PoolMatch
|
||||
};
|
||||
|
||||
// Reactive page
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, ReactiveState)]
|
||||
#[rx(alias = "PageStateRx")]
|
||||
struct PageState {
|
||||
|
||||
matches: PoolMatchList,
|
||||
}
|
||||
|
||||
fn overall_board_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, state: &'a PageStateRx) -> View<G> {
|
||||
view! { cx,
|
||||
Layout(title = "Overall Leaderboard") {
|
||||
// Anything we put in here will be rendered inside the `<main>` block of the layout
|
||||
p { "leaderboard" }
|
||||
ul {
|
||||
(View::new_fragment(
|
||||
state.matches.get()
|
||||
.pool_matches
|
||||
.iter()
|
||||
.rev()
|
||||
.enumerate()
|
||||
.map(|(index, item)| {
|
||||
let game = item.clone();
|
||||
view! { cx,
|
||||
li {
|
||||
(game.winner)
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +50,20 @@ async fn get_request_state(
|
||||
_info: StateGeneratorInfo<()>,
|
||||
req: Request,
|
||||
) -> Result<PageState, BlamedError<std::convert::Infallible>> {
|
||||
Ok(PageState {})
|
||||
|
||||
let matches = thread::spawn(move || {
|
||||
let mut db = DATA.lock().unwrap();
|
||||
db.matches.pool_matches.push(PoolMatch {
|
||||
players: vec![],
|
||||
winner: "lol".to_string(),
|
||||
});
|
||||
db.write();
|
||||
db.matches.clone()
|
||||
}).join().unwrap();
|
||||
|
||||
Ok(PageState {
|
||||
matches
|
||||
})
|
||||
}
|
||||
|
||||
#[engine_only_fn]
|
||||
|
||||
Reference in New Issue
Block a user