continue uploading media after sending post (#4662)

regression from https://github.com/tuskyapp/Tusky/pull/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.
This commit is contained in:
Konrad Pozniak 2024-09-10 19:16:53 +02:00 committed by GitHub
parent e515784729
commit a9d6b60291
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 7 deletions

View File

@ -97,9 +97,11 @@ class MediaUploader @Inject constructor(
private val mediaUploadApi: MediaUploadApi private val mediaUploadApi: MediaUploadApi
) { ) {
private val uploads = mutableMapOf<Int, UploadData>() private companion object {
private const val TAG = "MediaUploader"
private var mostRecentId: Int = 0 private val uploads = mutableMapOf<Int, UploadData>()
private var mostRecentId: Int = 0
}
fun getNewLocalMediaId(): Int { fun getNewLocalMediaId(): Int {
return mostRecentId++ return mostRecentId++
@ -326,8 +328,4 @@ class MediaUploader @Inject constructor(
return media.type == QueuedMedia.Type.IMAGE && return media.type == QueuedMedia.Type.IMAGE &&
(media.mediaSize > instanceInfo.imageSizeLimit || getImageSquarePixels(context.contentResolver, media.uri) > instanceInfo.imageMatrixLimit) (media.mediaSize > instanceInfo.imageSizeLimit || getImageSquarePixels(context.contentResolver, media.uri) > instanceInfo.imageMatrixLimit)
} }
private companion object {
private const val TAG = "MediaUploader"
}
} }