Ver código fonte

wallet: load the emoji cache in the background

darkfi 1 ano atrás
pai
commit
4c8f02fd0d

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

@@ -158,6 +158,16 @@ pub async fn make(app: &App, window: SceneNodePtr) {
         EMOJI_PICKER_ICON_SIZE,
     );
 
+    let emoji_meshes2 = emoji_meshes.clone();
+    std::thread::spawn(move || {
+        for i in (0..500).step_by(20) {
+            let mut emoji = emoji_meshes2.lock().unwrap();
+            for j in i..(i + 20) {
+                emoji.get(j);
+            }
+        }
+    });
+
     let db = sled::open(CHATDB_PATH).expect("cannot open sleddb");
     for channel in CHANNELS {
         chat::make(app, window.clone(), channel, &db, emoji_meshes.clone()).await;

+ 1 - 1
bin/darkwallet/src/ui/emoji_picker/mod.rs

@@ -93,7 +93,7 @@ impl EmojiMeshes {
         mesh.alloc(&self.render_api).draw_with_texture(atlas.texture)
     }
 
-    fn get(&mut self, i: usize) -> GfxDrawMesh {
+    pub fn get(&mut self, i: usize) -> GfxDrawMesh {
         assert!(i < emoji::EMOJI_LIST.len());
 
         if i >= self.meshes.len() {