Просмотр исходного кода

app/schema/menu: organise nodes by creating parent node for schema files

- design matches wallet node layout
media 4 дней назад
Родитель
Сommit
6267465c67

+ 1 - 1
bin/app/src/app/schema/chat.rs

@@ -343,7 +343,7 @@ pub async fn make(
         let editz_node = layer_node2.lookup_node("/content/editz").unwrap();
         editz_node.call_method("unfocus", vec![]).await.unwrap();
 
-        let menu_node = sg_root2.lookup_node("/window/content/menu_layer").unwrap();
+        let menu_node = sg_root2.lookup_node("/window/content/chat/menu_layer").unwrap();
         menu_node.set_property_bool(atom, Role::App, "is_visible", true).unwrap();
 
         chatview_is_visible.set(atom, false);

+ 1 - 1
bin/app/src/app/schema/menu/channel.rs

@@ -285,7 +285,7 @@ pub async fn make(
     let contact_vis = contact_is_visible.clone();
     let channel_vis = channel_is_visible.clone();
     let renderer = app.renderer.clone();
-    let menu_node = sg_root.lookup_node("/window/content/menu_layer").unwrap();
+    let menu_node = sg_root.lookup_node("/window/content/chat/menu_layer").unwrap();
     let netstatus_layer = sg_root.lookup_node("/window/content/netstatus_layer").unwrap();
     let content_go = content.clone();
     let goback = async move || {

+ 1 - 1
bin/app/src/app/schema/menu/contact.rs

@@ -286,7 +286,7 @@ pub async fn make(
     let contact_vis = contact_is_visible.clone();
     let channel_vis = channel_is_visible.clone();
     let renderer = app.renderer.clone();
-    let menu_node = sg_root.lookup_node("/window/content/menu_layer").unwrap();
+    let menu_node = sg_root.lookup_node("/window/content/chat/menu_layer").unwrap();
     let netstatus_layer = sg_root.lookup_node("/window/content/netstatus_layer").unwrap();
     let content_go = content.clone();
     let goback = async move || {

+ 6 - 7
bin/app/src/app/schema/menu/mod.rs

@@ -152,7 +152,7 @@ pub async fn make(
     let contact_layer = contact_layer
         .setup(|me| Layer::new(me, app.renderer.clone(), app.redraw_trigger.clone()))
         .await;
-    content.link(contact_layer.clone());
+    chat_layer.link(contact_layer.clone());
     let contact_is_visible =
         PropertyBool::wrap(&contact_layer, Role::App, "is_visible", 0).unwrap();
 
@@ -168,7 +168,7 @@ pub async fn make(
     let channel_layer = channel_layer
         .setup(|me| Layer::new(me, app.renderer.clone(), app.redraw_trigger.clone()))
         .await;
-    content.link(channel_layer.clone());
+    chat_layer.link(channel_layer.clone());
     let channel_is_visible =
         PropertyBool::wrap(&channel_layer, Role::App, "is_visible", 0).unwrap();
 
@@ -196,7 +196,7 @@ pub async fn make(
     let layer_node = layer_node
         .setup(|me| Layer::new(me, app.renderer.clone(), app.redraw_trigger.clone()))
         .await;
-    content.link(layer_node.clone());
+    chat_layer.link(layer_node.clone());
 
     let menulayer_is_visible = PropertyBool::wrap(&layer_node, Role::App, "is_visible", 0).unwrap();
 
@@ -453,7 +453,7 @@ pub async fn make(
     let listen_click = app.ex.spawn(async move {
         while let Ok(data) = recvr.recv().await {
             let channel: String = deserialize(&data).unwrap();
-            let path = format!("/window/content/{}_chat_layer", channel);
+            let path = format!("/window/content/chat/{}_chat_layer", channel);
             if let Some(node) = sg_root.lookup_node(path) {
                 let atom = &mut renderer.make_guard(gfxtag!("channel_clicked"));
                 info!(target: "app::menu", "clicked: {channel}!");
@@ -488,14 +488,13 @@ pub async fn make(
     let edit_done_listen = app.ex.spawn(async move {
         while let Ok(data) = edit_done_recvr.recv().await {
             let deleted_items: Vec<String> = deserialize(&data).unwrap();
-
             // Persist the post-edit joined list (captures removals + reorders)
             let current: Vec<String> =
                 menu_node2.get_property("items").unwrap().get_str_vec().unwrap();
             write_joined_channels(&current);
 
             for item in &deleted_items {
-                let path = format!("/window/content/{}_chat_layer", item);
+                let path = format!("/window/content/chat/{}_chat_layer", item);
                 if let Some(node) = sg_root.lookup_node(&path) {
                     node.clear_tasks();
                     debug!(target: "app::menu", "deleted item: {item}");
@@ -537,7 +536,7 @@ pub async fn setup_wallet_button(app: &App, menu_layer: SceneNodePtr, i18n_fish:
 
     let menulayer_is_visible = PropertyBool::wrap(&menu_layer, Role::App, "is_visible", 0).unwrap();
     let mainlayer_node =
-        app.sg_root.lookup_node("/window/content/menu_layer/mainbtn_layer").unwrap();
+        app.sg_root.lookup_node("/window/content/chat/menu_layer/mainbtn_layer").unwrap();
 
     // Wallet button
     let node = create_vector_art("walletbtn_bg");

+ 19 - 17
bin/app/src/app/schema/mod.rs

@@ -634,8 +634,8 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish, db
         //  router currently points to view1 and we call router.goto("./view2")).
         //
         //  2. Support of wildcard in lookups in .get_children() or another method, like this "*_chat_layer".
-        let windows = sg_root.lookup_node("/window/content").unwrap().get_children();
-        let target_substrings = vec!["_chat_layer", "menu_layer", "settings_layer"];
+        let windows = sg_root.lookup_node("/window/content/chat").unwrap().get_children();
+        let target_substrings = vec!["_chat_layer", "menu_layer"];
         for node in windows.iter() {
             if target_substrings.iter().any(|&s| node.name.contains(s)) {
                 if let Err(e) = node.set_property_bool(atom, Role::App, "is_visible", false) {
@@ -700,6 +700,19 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish, db
     // Seed the joined-channels file with defaults on first run.
     ensure_joined_channels_seeded();
 
+    menu::make(
+        app,
+        content.clone(),
+        i18n_fish,
+        channels_tree.clone(),
+        contacts_tree.clone(),
+        &db,
+        emoji_meshes.clone(),
+        is_first_time,
+    )
+    .await;
+    let chat_layer = app.sg_root.lookup_node("/window/content/chat").unwrap();
+
     // Create chat layers only for joined channels/contacts, in joined order.
     for name in read_joined_channels() {
         let bare = if name.starts_with('#') || name.starts_with('@') { &name[1..] } else { &name };
@@ -717,7 +730,7 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish, db
             &app.sg_root,
             &app.renderer,
             &app.ex,
-            content.clone(),
+            chat_layer.clone(),
             &name,
             &db,
             i18n_fish,
@@ -727,26 +740,15 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish, db
         )
         .await;
     }
-    menu::make(
-        app,
-        content.clone(),
-        i18n_fish,
-        channels_tree,
-        contacts_tree,
-        &db,
-        emoji_meshes.clone(),
-        is_first_time,
-    )
-    .await;
     wallet::make(app, content.clone(), i18n_fish).await;
 
     // Setup wallet button after wallet layer is created
-    let menu_layer = app.sg_root.lookup_node("/window/content/menu_layer").unwrap();
+    let menu_layer = app.sg_root.lookup_node("/window/content/chat/menu_layer").unwrap();
     menu::setup_wallet_button(app, menu_layer, i18n_fish).await;
 
     // @@@ Debug stuff @@@
-    //let chatview_node = app.sg_root.lookup_node("/window/content/dev_chat_layer").unwrap();
+    //let chatview_node = app.sg_root.lookup_node("/window/content/chat/dev_chat_layer").unwrap();
     //chatview_node.set_property_bool(atom, Role::App, "is_visible", true).unwrap();
-    //let menu_node = app.sg_root.lookup_node("/window/content/menu_layer").unwrap();
+    //let menu_node = app.sg_root.lookup_node("/window/content/chat/menu_layer").unwrap();
     //menu_node.set_property_bool(atom, Role::App, "is_visible", false).unwrap();
 }

+ 3 - 3
bin/app/src/app/schema/settings.rs

@@ -232,8 +232,8 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
 
         // Disable visilibity of all relevant window nodes
         // This is needed since for example all chats have a different node name.
-        let windows = sg_root.lookup_node("/window/content").unwrap().get_children();
-        let target_substrings = vec!["_chat_layer", "menu_layer", "settings_layer"];
+        let windows = sg_root.lookup_node("/window/content/chat").unwrap().get_children();
+        let target_substrings = vec!["_chat_layer", "menu_layer"];
 
         for node in windows.iter() {
             // Check if the node's name contains any of the target substrings
@@ -245,7 +245,7 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
         }
 
         // Go back to the dev channel
-        let menu_node = sg_root.lookup_node("/window/content/dev_chat_layer").unwrap();
+        let menu_node = sg_root.lookup_node("/window/content/chat/dev_chat_layer").unwrap();
         menu_node.set_property_bool(atom, Role::App, "is_visible", true).unwrap();
     };
 

+ 1 - 1
bin/app/src/app/schema/wallet/main.rs

@@ -488,7 +488,7 @@ async fn create_chat_btn(
     let sg_root = app.sg_root.clone();
     let renderer = app.renderer.clone();
     let menu_is_visible = PropertyBool::wrap(
-        &sg_root.lookup_node("/window/content/menu_layer").unwrap(),
+        &sg_root.lookup_node("/window/content/chat/menu_layer").unwrap(),
         Role::App,
         "is_visible",
         0,

+ 4 - 3
bin/app/src/main.rs

@@ -317,7 +317,7 @@ async fn load_plugins(
             let nick = String::decode(&mut cur).unwrap();
             let msg = String::decode(&mut cur).unwrap();
 
-            let node_path = format!("/window/content/{channel}_chat_layer/content/chatty");
+            let node_path = format!("/window/content/chat/{channel}_chat_layer/content/chatty");
             t!("Attempting to relay message to {node_path}");
             let Some(chatview) = sg_root2.lookup_node(&node_path) else {
                 d!("Ignoring message since {node_path} doesn't exist");
@@ -338,13 +338,14 @@ async fn load_plugins(
             }
 
             // Apply coloring when you get a message
-            let chat_path = format!("/window/content/{channel}_chat_layer");
+            let chat_path = format!("/window/content/chat/{channel}_chat_layer");
             let chat_layer = sg_root2.lookup_node(chat_path).unwrap();
             if chat_layer.get_property_bool("is_visible").unwrap() {
                 continue
             }
 
-            let menu_node = sg_root2.lookup_node("/window/content/menu_layer/main_menu").unwrap();
+            let menu_node =
+                sg_root2.lookup_node("/window/content/chat/menu_layer/main_menu").unwrap();
             let group_name = if msg.contains(&darkirc_nick.get()) { "role2_group" } else { "role1_group" };
             let group = menu_node.get_property(group_name).unwrap();
             if !group.get_str_vec().unwrap().contains(&channel) {