A cheap attempt at a native Bluesky client for Android
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

TimelineView: don't attach an empty image

geesawra a2684072 3d43174a

+24 -24
+1 -9
app/src/main/java/industries/geesawra/jerryno/TimelineView.kt
··· 280 280 uploadingPost.value = true 281 281 timelineViewModel.post( 282 282 postText, 283 - { 284 - val list = mediaSelected.value.keys.toList() 285 - if (list.isEmpty()) { 286 - null 287 - } else { 288 - list 289 - } 290 - }(), 291 - null 283 + mediaSelected.value.keys.toList().ifEmpty { null } 292 284 ).onSuccess { 293 285 scaffoldState.bottomSheetState.hide() 294 286 postText = ""
+23 -15
app/src/main/java/industries/geesawra/jerryno/datalayer/Bluesky.kt
··· 11 11 import app.bsky.actor.PreferencesUnion 12 12 import app.bsky.embed.Images 13 13 import app.bsky.embed.ImagesImage 14 + import app.bsky.embed.Video 14 15 import app.bsky.feed.GeneratorView 15 16 import app.bsky.feed.GetFeedGeneratorsQueryParams 16 17 import app.bsky.feed.GetTimelineQueryParams ··· 340 341 return runCatching { 341 342 create().getOrThrow() 342 343 343 - val blobs = mutableListOf<Blob>() 344 + var postEmbed: PostEmbedUnion? = null 344 345 345 346 if (images != null) { 346 - blobs += uploadImages(images).getOrThrow() 347 + val blobs = uploadImages(images).getOrThrow() 348 + postEmbed = PostEmbedUnion.Images( 349 + value = Images( 350 + images = blobs.map { 351 + ImagesImage( 352 + image = it, 353 + alt = "", 354 + ) 355 + } 356 + ) 357 + ) 347 358 } 348 359 349 360 if (video != null) { 350 - blobs += uploadVideo(video).getOrThrow() 361 + val blob = uploadVideo(video).getOrThrow() 362 + postEmbed = PostEmbedUnion.Video( 363 + value = Video( 364 + video = blob, 365 + alt = "", 366 + ) 367 + ) 351 368 } 352 369 353 370 val r = BlueskyJson.encodeAsJsonContent( 354 371 Post( 355 372 text = content, 356 373 createdAt = Clock.System.now(), 357 - embed = PostEmbedUnion.Images( 358 - value = Images( 359 - images = blobs.map { 360 - ImagesImage( 361 - image = it, 362 - alt = "", 363 - ) 364 - } 365 - ) 366 - ) 374 + embed = postEmbed 367 375 ) 368 376 ) 369 377 ··· 404 412 } 405 413 } 406 414 407 - suspend fun uploadVideo(video: Uri): Result<List<Blob>> { 415 + suspend fun uploadVideo(video: Uri): Result<Blob> { 408 416 return runCatching { 409 417 create().getOrThrow() 410 418 ··· 422 430 } 423 431 424 432 425 - return Result.success(uploadedBlobs) 433 + return Result.success(uploadedBlobs.first()) 426 434 } 427 435 } 428 436