Commit f0b5c30eb1

f0b5c30eb13b7d9be75b6ab4cb81df5177a98bbc

parent: d6c593bfff

Unsigned

Jakub Panek <me@panekj.dev> · 2025-03-18 10:57 UTC
committer: <poljar@termina.org.uk>

weechat: fix listing devices

Layout: unified · split

src/server.rs +24 −9
@@ -904,6 +904,7 @@ impl InnerServer {
904904 &self,
905905 connection: Connection,
906906 ) -> Result<(), Error> {
907 let client = connection.client();
907908 let mut response = connection.devices().await?;
908909
909910 if response.devices.is_empty() {
@@ -919,20 +920,34 @@ impl InnerServer {
919920 ));
920921
921922 response.devices.sort_by_key(|d| Reverse(d.last_seen_ts));
922 let own_device_id = connection.client().device_id();
923 let own_user_id = connection
924 .client()
925 .user_id()
923 let own_device_id = client.device_id();
924 let own_user_id = client
925 .session_meta()
926 .map(|s| s.user_id.to_owned())
926927 .expect("Getting our own devices while not being logged in");
927928
928929 let mut lines: Vec<String> = Vec::new();
929930
930931 for device_info in response.devices {
931 let device = connection
932 .client()
933 .encryption()
934 .get_device(&own_user_id, &device_info.device_id)
935 .await?;
932 let client = client.clone();
933 let own_user_id = own_user_id.clone();
934 let device_info_move = device_info.clone();
935 let device = match connection
936 .spawn(async move {
937 client
938 .clone()
939 .encryption()
940 .get_device(&own_user_id, &device_info_move.device_id)
941 .await
942 })
943 .await
944 {
945 Ok(d) => d,
946 Err(e) => {
947 self.print_error(&format!("Failed to obtain device: {e}"));
948 continue;
949 }
950 };
936951
937952 let own_device = own_device_id == Some(&device_info.device_id);
938953