make reactivity system pluggable
This commit is contained in:
+24
-6
@@ -3,15 +3,34 @@
|
||||
use dioxus::prelude::*;
|
||||
use mumble_web2_client::{
|
||||
network_entrypoint, reqwest, AudioSettings, ChannelId, Command, ConfigSystem,
|
||||
ConfigSystemInterface as _, ConnectionState, Platform, PlatformInterface as _, ServerState,
|
||||
SharedState, State, UserId, UserState, VERSION,
|
||||
ConfigSystemInterface as _, ConnectionState, Platform, PlatformInterface as _, UserId,
|
||||
UserState, VERSION,
|
||||
};
|
||||
use mumble_web2_common::{ProxyOverrides, ServerStatus};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::{fmt, sync::Arc};
|
||||
use Command::*;
|
||||
use ConnectionState::*;
|
||||
|
||||
pub struct DioxusReactivity;
|
||||
|
||||
impl mumble_web2_client::Reactivity for DioxusReactivity {
|
||||
type Signal<T> = Signal<T>;
|
||||
|
||||
fn new<T: 'static>(value: T) -> Signal<T> {
|
||||
Signal::new(value)
|
||||
}
|
||||
|
||||
fn read<T: 'static>(signal: &Signal<T>) -> impl std::ops::Deref<Target = T> {
|
||||
signal.read_unchecked()
|
||||
}
|
||||
|
||||
fn write<T: 'static>(signal: &Signal<T>) -> impl std::ops::DerefMut<Target = T> {
|
||||
signal.write_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
pub type SharedState = mumble_web2_client::SharedState<DioxusReactivity>;
|
||||
pub type State = mumble_web2_client::State<DioxusReactivity>;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum UserIcon {
|
||||
Normal,
|
||||
@@ -519,8 +538,7 @@ pub fn LoginView(overrides: Resource<ProxyOverrides>) -> Element {
|
||||
async move {
|
||||
let client = reqwest::Client::new();
|
||||
loop {
|
||||
*last_status.write_unchecked() =
|
||||
Some(Platform::get_status(&client, &addr).await);
|
||||
*last_status.write_unchecked() = Some(Platform::get_status(&client, &addr).await);
|
||||
Platform::sleep(std::time::Duration::from_secs_f32(1.0)).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user