Skip to content

Commit

Permalink
continue uploading media after sending post (#4662)
Browse files Browse the repository at this point in the history
regression from #4599

https://pug.ninja/@motoridersd/113102603349423738

The problem is, `MediaUploader` is no longer a singleton, so the state
is not correctly shared between `ComposeActivity` and
`SendStatusService.` But it can't be a singleton, since `MediaUploadApi`
(injected into `MediaUploader`) needs to be recreated on account change.
Let's share the state in the companion object instead.
  • Loading branch information
connyduck authored Sep 10, 2024
1 parent e515784 commit a9d6b60
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ class MediaUploader @Inject constructor(
private val mediaUploadApi: MediaUploadApi
) {

private val uploads = mutableMapOf<Int, UploadData>()

private var mostRecentId: Int = 0
private companion object {
private const val TAG = "MediaUploader"
private val uploads = mutableMapOf<Int, UploadData>()
private var mostRecentId: Int = 0
}

fun getNewLocalMediaId(): Int {
return mostRecentId++
Expand Down Expand Up @@ -326,8 +328,4 @@ class MediaUploader @Inject constructor(
return media.type == QueuedMedia.Type.IMAGE &&
(media.mediaSize > instanceInfo.imageSizeLimit || getImageSquarePixels(context.contentResolver, media.uri) > instanceInfo.imageMatrixLimit)
}

private companion object {
private const val TAG = "MediaUploader"
}
}

0 comments on commit a9d6b60

Please sign in to comment.