@@ -5,8 +5,8 @@ use egui::{Color32, RichText};
55use egui_hooks:: UseHookExt ;
66use egui_hooks:: hook:: state:: { State , Var } ;
77use egui_taffy:: { Tui , TuiBuilderLogic , tui} ;
8- use nullspace_client:: internal:: UserDetails ;
9- use nullspace_structs:: fragment:: Attachment ;
8+ use nullspace_client:: internal:: { UploadedRoot , UserDetails } ;
9+ use nullspace_structs:: fragment:: ImageAttachment ;
1010use pollster:: FutureExt ;
1111use taffy:: style_helpers:: { auto, fr, length} ;
1212use taffy:: { AlignItems , Dimension , Display , FlexDirection , Size as TaffySize , Style } ;
@@ -21,13 +21,13 @@ use crate::widgets::avatar::Avatar;
2121enum AvatarChoice {
2222 Keep ,
2323 Clear ,
24- Set ( Attachment ) ,
24+ Set ( ImageAttachment ) ,
2525}
2626
2727#[ derive( Clone ) ]
2828struct SaveRequest {
2929 display_name : Option < String > ,
30- avatar : Option < Attachment > ,
30+ avatar : Option < ImageAttachment > ,
3131}
3232
3333enum SaveOutcome {
@@ -247,7 +247,15 @@ impl Widget for ProfileInner<'_> {
247247 ui. add ( eframe:: egui:: ProgressBar :: new ( progress) . text ( "Uploading..." ) ) ;
248248 } else if let Some ( done) = self . app . state . upload_done . get ( & upload_id) {
249249 let root = done. clone ( ) ;
250- avatar_choice. set_next ( AvatarChoice :: Set ( root) ) ;
250+ match root {
251+ UploadedRoot :: ImageAttachment ( root) => {
252+ avatar_choice. set_next ( AvatarChoice :: Set ( root) ) ;
253+ }
254+ UploadedRoot :: Attachment ( _) => {
255+ self . app . state . error_dialog =
256+ Some ( "avatar upload produced non-image payload" . to_string ( ) ) ;
257+ }
258+ }
251259 avatar_upload_id. set_next ( None ) ;
252260 self . app . state . upload_done . remove ( & upload_id) ;
253261 self . app . state . upload_progress . remove ( & upload_id) ;
@@ -336,7 +344,7 @@ fn start_avatar_upload(app: &mut NullspaceApp, upload_id: &State<Option<i64>>, p
336344 app. state . error_dialog = Some ( "avatar must be an image" . to_string ( ) ) ;
337345 return ;
338346 }
339- let Ok ( id) = flatten_rpc ( get_rpc ( ) . attachment_upload ( path, mime ) . block_on ( ) ) else {
347+ let Ok ( id) = flatten_rpc ( get_rpc ( ) . image_attachment_upload ( path) . block_on ( ) ) else {
340348 return ;
341349 } ;
342350 upload_id. set_next ( Some ( id) ) ;
0 commit comments