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

wallet: print cool lil msg when changing your nick: 'you are now known as <mistah>'

darkfi 1 год назад
Родитель
Сommit
27c1bcbc73

+ 0 - 10
bin/darkwallet/src/app/mod.rs

@@ -232,16 +232,6 @@ impl App {
 
         self.start_procs().await;
         debug!(target: "app", "App started");
-
-        //let chatty =
-        //    self.sg_root.clone().lookup_node("/window/dev_chat_layer/content/chatty").unwrap();
-        //let mut arg_data = vec![];
-        //crate::util::unixtime().encode(&mut arg_data).unwrap();
-        //let id: [u8; 32] = rand::random();
-        //id.encode(&mut arg_data).unwrap();
-        //"NOTICE".encode(&mut arg_data).unwrap();
-        //"you are now known as <genjix>".encode(&mut arg_data).unwrap();
-        //chatty.call_method("insert_line", arg_data).await.unwrap();
     }
 
     pub fn stop(&self) {

+ 14 - 2
bin/darkwallet/src/app/schema/chat.rs

@@ -42,6 +42,7 @@ use crate::{
         emoji_picker, Button, ChatEdit, ChatView, EditBox, EmojiPicker, Image, Layer, ShapeVertex,
         Text, VectorArt, VectorShape, Window,
     },
+    util::unixtime,
     ExecutorPtr,
 };
 
@@ -540,7 +541,7 @@ pub async fn make(
     //    populate_tree(&chat_tree);
     //}
     debug!(target: "app", "db has {} lines", chat_tree.len());
-    let node = node
+    let chatview_node = node
         .setup(|me| {
             ChatView::new(
                 me,
@@ -552,7 +553,7 @@ pub async fn make(
             )
         })
         .await;
-    layer_node.clone().link(node);
+    layer_node.clone().link(chatview_node.clone());
 
     // Create the editbox bg
     let node = create_vector_art("editbox_bg");
@@ -896,6 +897,17 @@ pub async fn make(
                 let nick = text.split_whitespace().nth(1).unwrap_or("anon");
                 info!(target: "app::chat", "Setting nick to: {nick}");
                 darkirc.set_property_str(Role::App, "nick", nick);
+
+                let msg = format!("You are now known as <{nick}>");
+                let id: [u8; 32] = rand::random();
+
+                let mut data = vec![];
+                unixtime().encode(&mut data).unwrap();
+                id.encode(&mut data).unwrap();
+                "NOTICE".encode(&mut data).unwrap();
+                msg.encode(&mut data).unwrap();
+                chatview_node.call_method("insert_line", data).await.unwrap();
+
                 continue
             }
 

+ 8 - 2
bin/darkwallet/src/plugin/darkirc.rs

@@ -70,7 +70,7 @@ fn nick_filename() -> PathBuf {
 
 /// Due to drift between different machine's clocks, if the message timestamp is recent
 /// then we will just correct it to the current time so messages appear sequential in the UI.
-const RECENT_TIME_DIST: u64 = 10_000;
+const RECENT_TIME_DIST: u64 = 25_000;
 
 macro_rules! d { ($($arg:tt)*) => { debug!(target: "plugin::darkirc", $($arg)*); } }
 macro_rules! inf { ($($arg:tt)*) => { info!(target: "plugin::darkirc", $($arg)*); } }
@@ -260,11 +260,17 @@ impl DarkIrc {
             }
             channel.remove(0);
 
+            // Workaround for the chatview hack. This nick is off limits!
+            let mut nick = privmsg.nick;
+            if nick == "NOTICE" {
+                nick = "noticer".to_string();
+            }
+
             let mut arg_data = vec![];
             channel.encode(&mut arg_data).unwrap();
             ev.timestamp.encode(&mut arg_data).unwrap();
             ev.id().as_bytes().encode(&mut arg_data).unwrap();
-            privmsg.nick.encode(&mut arg_data).unwrap();
+            nick.encode(&mut arg_data).unwrap();
             privmsg.msg.encode(&mut arg_data).unwrap();
 
             let node = self.node.upgrade().unwrap();