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

Function MainApp

src/app.rs:93–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91#[tracing::instrument(level = "debug", skip())]
92#[component]
93pub fn MainApp() -> impl IntoView {
94 let i18n = use_i18n();
95
96 spawn_local(async move {
97 if let Ok(lang) = load_selective("i18n_language".into()).await {
98 let lang: Vec<CheckboxPreference> = serde_wasm_bindgen::from_value(lang).unwrap();
99 if let Some(enabled) = lang.into_iter().find(|v| v.enabled) {
100 tracing::debug!("Setting locale to {:?}", enabled.key);
101 i18n.set_locale(get_locale(&enabled.key))
102 }
103 }
104 });
105
106 let tabs = vec![
107 Tab::new(
108 move || t_string!(use_i18n(), sidebar.tabs.queue),
109 "Queue",
110 "queue",
111 ),
112 Tab::new(
113 move || t_string!(use_i18n(), sidebar.tabs.allSongs),
114 "Songs",
115 "/main/allsongs",
116 ),
117 Tab::new(
118 move || t_string!(use_i18n(), sidebar.tabs.playlists),
119 "Playlists",
120 "/main/playlists",
121 ),
122 Tab::new(
123 move || t_string!(use_i18n(), sidebar.tabs.artists),
124 "Artists",
125 "/main/artists",
126 ),
127 Tab::new(
128 move || t_string!(use_i18n(), sidebar.tabs.albums),
129 "Albums",
130 "/main/albums",
131 ),
132 Tab::new(
133 move || t_string!(use_i18n(), sidebar.tabs.genre),
134 "Genres",
135 "/main/genres",
136 ),
137 Tab::new(
138 move || t_string!(use_i18n(), sidebar.tabs.explore),
139 "Explore",
140 "/main/explore",
141 ),
142 ];
143
144 let ui_store = expect_context::<RwSignal<UiStore>>();
145 let is_mobile = create_read_slice(ui_store, |u| u.get_is_mobile()).get();
146 let sidebar_open = create_read_slice(ui_store, |u| u.get_sidebar_open());
147
148 Effect::new(move || {
149 let sidebar_open = sidebar_open.get();
150 let document = window().document().unwrap();

Callers

nothing calls this directly

Calls 5

load_selectiveFunction · 0.85
get_localeFunction · 0.85
getMethod · 0.80
get_is_mobileMethod · 0.80
get_sidebar_openMethod · 0.80

Tested by

no test coverage detected