4 İşlemeler 34caed4ba9 ... 85ad64fe5d

Yazar SHA1 Mesaj Tarih
  Houkime 85ad64fe5d update deps and reference server 3 ay önce
  Houkime d740386c3a specify toolchain 3 ay önce
  Houkime d1c136a899 make requesting a pic for a user a separate operation 1 yıl önce
  Houkime d48607fe0c change mastodon server to poll 1 yıl önce
4 değiştirilmiş dosya ile 626 ekleme ve 451 silme
  1. 610 440
      Cargo.lock
  2. 2 0
      rust-toolchain.toml
  3. 5 3
      src/client.rs
  4. 9 8
      src/user.rs

Dosya farkı çok büyük olduğundan ihmal edildi
+ 610 - 440
Cargo.lock


+ 2 - 0
rust-toolchain.toml

@@ -0,0 +1,2 @@
+[toolchain] 
+channel = "nightly" 

+ 5 - 3
src/client.rs

@@ -1,3 +1,4 @@
+use core::panic;
 use std::borrow::Borrow;
 
 use macroquad::prelude::{error, Texture2D};
@@ -12,10 +13,11 @@ pub fn get_client() -> Result<blocking::Client, Box<dyn std::error::Error>> {
 }
 
 pub fn request_posts(tag: &str) -> Result<api::GetPostsResponse, Box<dyn std::error::Error>> {
-    let request_addr = String::from("https://mastodon.technology/api/v1/timelines/tag/")
-        + tag.trim_start_matches("#");
+    let request_addr =
+        String::from("https://mastodon.social/api/v1/timelines/tag/") + tag.trim_start_matches("#");
     let resp = get_client()?.get(request_addr).send();
-    // pritln!("{:#?}", resp);
+    // panic!("{:?}", resp.expect("ff"));
+
     let result = resp
         .expect("sending failed")
         .json::<api::GetPostsResponse>()

+ 9 - 8
src/user.rs

@@ -7,6 +7,13 @@ use crate::client::request_texture;
 pub struct User {
     pub finger: String,
     pub avatar: Texture2D,
+    pub avatar_link: String,
+}
+
+impl User {
+    pub async fn request_texture(&mut self) {
+        self.avatar = request_texture(&self.avatar_link).unwrap_or_else(|_| no_avatar());
+    }
 }
 
 pub struct UserCache {
@@ -32,17 +39,11 @@ impl UserCache {
             if !res.finger_exists(&acc.acct) {
                 res.users.push(User {
                     finger: acc.acct.clone(),
-                    avatar: request_texture(&acc.avatar_static).unwrap_or_else(|_| no_avatar()),
+                    avatar: no_avatar(),
+                    avatar_link: acc.avatar_static.clone(),
                 })
             }
         }
-        res.users.push(User {
-            finger: "@houkime@mastodon.technology".to_string(),
-            avatar: Texture2D::from_file_with_format(
-                include_bytes!("../h.png"),
-                Some(ImageFormat::Png),
-            ),
-        });
         return res;
     }
 }