fix: post attachment task not trigger on queue issue
This commit is contained in:
parent
9460ab2c58
commit
5dc0cb0cc5
|
@ -292,33 +292,32 @@ final class ComposeViewModel: NSObject {
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
// setup attribute updater
|
// setup attribute updater
|
||||||
Publishers.CombineLatest(
|
attachmentServices
|
||||||
attachmentServices,
|
.receive(on: DispatchQueue.main)
|
||||||
context.timestampUpdatePublisher
|
.debounce(for: 0.3, scheduler: DispatchQueue.main)
|
||||||
)
|
.sink { attachmentServices in
|
||||||
.sink { attachmentServices, _ in
|
// drive service upload state
|
||||||
// drive service upload state
|
// make image upload in the queue
|
||||||
// make image upload in the queue
|
for attachmentService in attachmentServices {
|
||||||
for attachmentService in attachmentServices {
|
// skip when prefix N task when task finish OR fail OR uploading
|
||||||
// skip when prefix N task when task finish OR fail OR uploading
|
guard let currentState = attachmentService.uploadStateMachine.currentState else { break }
|
||||||
guard let currentState = attachmentService.uploadStateMachine.currentState else { break }
|
if currentState is MastodonAttachmentService.UploadState.Fail {
|
||||||
if currentState is MastodonAttachmentService.UploadState.Fail {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
if currentState is MastodonAttachmentService.UploadState.Finish {
|
||||||
if currentState is MastodonAttachmentService.UploadState.Finish {
|
continue
|
||||||
continue
|
}
|
||||||
}
|
if currentState is MastodonAttachmentService.UploadState.Uploading {
|
||||||
if currentState is MastodonAttachmentService.UploadState.Uploading {
|
break
|
||||||
break
|
}
|
||||||
}
|
// trigger uploading one by one
|
||||||
// trigger uploading one by one
|
if currentState is MastodonAttachmentService.UploadState.Initial {
|
||||||
if currentState is MastodonAttachmentService.UploadState.Initial {
|
attachmentService.uploadStateMachine.enter(MastodonAttachmentService.UploadState.Uploading.self)
|
||||||
attachmentService.uploadStateMachine.enter(MastodonAttachmentService.UploadState.Uploading.self)
|
break
|
||||||
break
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.store(in: &disposeBag)
|
||||||
.store(in: &disposeBag)
|
|
||||||
|
|
||||||
// bind delegate
|
// bind delegate
|
||||||
attachmentServices
|
attachmentServices
|
||||||
|
|
Loading…
Reference in New Issue