MCPcopy Create free account
hub / github.com/Moosync/Moosync / App

Function App

src/app.rs:263–457  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261#[tracing::instrument(level = "debug", skip())]
262#[component]
263pub fn App() -> impl IntoView {
264 let _ = use_event_listener(document().body(), keydown, |ev| {
265 if ev.shift_key() && ev.ctrl_key() && ev.key_code() == 75 {
266 spawn_local(async move {
267 let _ = toggle_dev_tools().await;
268 });
269 }
270 });
271
272 provide_context_menu_state();
273 provide_context(RwSignal::new(UiStore::new()));
274 provide_context(RwSignal::new(ModalStore::default()));
275
276 {
277 let ui_store = expect_context::<RwSignal<UiStore>>();
278 let is_mobile = window()
279 .get("is_mobile")
280 .and_then(|v| v.as_bool())
281 .unwrap_or_default();
282 ui_store.update(|u| u.set_is_mobile(is_mobile));
283 let is_mobile_player = window()
284 .get("is_mobile_player")
285 .and_then(|v| v.as_bool())
286 .unwrap_or_default();
287 ui_store.update(|u| u.set_is_mobile_player(is_mobile_player));
288
289 if is_mobile {
290 let body = document().body().unwrap();
291 body.set_class_name("body-mobile");
292 }
293 }
294
295 provide_context(PlayerStore::new());
296 provide_context(Arc::new(ProviderStore::new()));
297
298 spawn_local(async move {
299 let id = load_selective("themes.active_theme".into()).await.unwrap();
300 handle_theme(serde_wasm_bindgen::from_value(id).unwrap());
301 });
302
303 let _ = use_event_listener(document().body(), contextmenu, |ev| {
304 ev.prevent_default();
305 });
306
307 let owner = Owner::new();
308 let ui_requests_unlisten = listen_event("ui-requests", move |data| {
309 owner.with(|| {
310 let payload = js_sys::Reflect::get(&data, &JsValue::from_str("payload")).unwrap();
311 let payload: ExtensionUIRequest = serde_wasm_bindgen::from_value(payload).unwrap();
312
313 #[tracing::instrument(level = "debug", skip(payload, data))]
314 fn send_reply<T>(payload: ExtensionUIRequest, data: T)
315 where
316 T: Serialize + Clone,
317 {
318 let value = serde_wasm_bindgen::to_value(&data).unwrap();
319 spawn_local(async move {
320 let res = emit(format!("ui-reply-{}", payload.channel).as_str(), value);

Callers 1

open_windowMethod · 0.85

Calls 15

load_selectiveFunction · 0.85
handle_themeFunction · 0.85
listen_eventFunction · 0.85
send_replyFunction · 0.85
watch_preferencesFunction · 0.85
get_localeFunction · 0.85
check_for_updatesFunction · 0.85
getMethod · 0.80
set_is_mobileMethod · 0.80
set_is_mobile_playerMethod · 0.80
get_current_songMethod · 0.80
get_timeMethod · 0.80

Tested by

no test coverage detected