fix(hls): pre-increment upload counter so it ticks through N of M
Previously the lambda set HlsPublishState.Uploading(done=uploadsDone) before running the upload and incremented after. So while upload #1 was actually in flight the state said "0 / 5 done", and StateFlow conflation ate the post-upload increment before the UI could paint it — the counter appeared stalled until the next rendition's onProgress flipped state back to Transcoding. Pre-incrementing means `done` now represents "working on item N of M" rather than "N already finished, N+1 silently in flight", so the first upload displays as "1 of 5" and each subsequent upload ticks to 2, 3, 4, 5 visibly. The earlier "done" wording existed to disambiguate 0/N from a stalled bar; with pre-increment we never show 0/N, so the string drops "done" and reads as the cleaner "Uploading X of Y". Confirmed via logcat on device: R1 sinkFinish=5669ms, R2 sinkFinish=6343ms — the "phantom upload" between R1 encoding and R2 encoding really was the R1 combined upload; the counter just wasn't reflecting it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+7
-2
@@ -125,6 +125,12 @@ class HlsPublishOrchestrator(
|
||||
|
||||
val uploadResult =
|
||||
runUpload(config, listener) { file, suggestedFilename ->
|
||||
// Pre-increment so `done` means "working on item N of total" rather than
|
||||
// "N completed, with N+1 silently in flight". Without this, the counter
|
||||
// is stuck on the previous value while the current upload runs, and
|
||||
// StateFlow conflation eats the post-upload increment before the UI
|
||||
// paints it — the net effect is a visibly stalled counter.
|
||||
uploadsDone++
|
||||
_state.value =
|
||||
HlsPublishState.Uploading(
|
||||
done = uploadsDone,
|
||||
@@ -138,12 +144,12 @@ class HlsPublishOrchestrator(
|
||||
HlsContentTypes.FMP4_SEGMENT
|
||||
}
|
||||
val result = uploader.upload(file, contentType)
|
||||
uploadsDone++
|
||||
segmentUploads[suggestedFilename] = result
|
||||
result.url
|
||||
?: error("Uploader returned null URL for $suggestedFilename")
|
||||
}
|
||||
|
||||
uploadsDone++
|
||||
_state.value =
|
||||
HlsPublishState.Uploading(
|
||||
done = uploadsDone,
|
||||
@@ -151,7 +157,6 @@ class HlsPublishOrchestrator(
|
||||
currentLabel = "master.m3u8",
|
||||
)
|
||||
val masterUpload = uploadMaster(uploader, uploadResult.masterPlaylist)
|
||||
uploadsDone++
|
||||
val masterUrl =
|
||||
masterUpload.url ?: error("Uploader returned null URL for master playlist")
|
||||
|
||||
|
||||
@@ -2106,8 +2106,8 @@
|
||||
<string name="hls_publish_button">Publish HD video</string>
|
||||
<string name="hls_publishing_header_format">Publishing “%1$s”…</string>
|
||||
<string name="hls_state_transcoding_format">Transcoding %1$s</string>
|
||||
<string name="hls_state_uploading_format">Uploading %1$d / %2$d done</string>
|
||||
<string name="hls_state_uploading_with_label_format">Uploading %1$s (%2$d / %3$d done)</string>
|
||||
<string name="hls_state_uploading_format">Uploading %1$d of %2$d</string>
|
||||
<string name="hls_state_uploading_with_label_format">Uploading %1$s (%2$d of %3$d)</string>
|
||||
<string name="hls_state_publishing">Publishing event…</string>
|
||||
<string name="hls_state_success_title">Video published</string>
|
||||
<string name="hls_state_success_body">Your HD video is live on Nostr.</string>
|
||||
|
||||
Reference in New Issue
Block a user