Skip to content

Commit

Permalink
Simplify RecognizerController.Update.Kind
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Feb 26, 2025
1 parent ec93630 commit 8b825ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ZShare/ViewModels/ExtensionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ final class ExtensionViewModel {
case .cancelled:
updateState(with: .processed)

case .recognitionInProgress, .remoteRecognitionInProgress, .identifierLookupInProgress:
case .inProgress:
updateState(with: .decoding)

case .translated(let item):
Expand Down
8 changes: 2 additions & 6 deletions Zotero/Controllers/RecognizerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ final class RecognizerController {
case failed(Error)
case cancelled
case enqueued
case recognitionInProgress
case remoteRecognitionInProgress(data: [String: Any])
case identifierLookupInProgress(response: RemoteRecognizerResponse, identifier: String)
case inProgress
case translated(itemResponse: ItemResponse)
case createdParent(item: RItem)
}
Expand Down Expand Up @@ -179,7 +177,7 @@ final class RecognizerController {
func start(task: Task, subject: PublishSubject<Update>) {
subjectsByTask[task] = subject
statesByTask[task] = .recognitionInProgress
emmitUpdate(for: task, subject: subject, kind: .recognitionInProgress)
emmitUpdate(for: task, subject: subject, kind: .inProgress)

pdfWorkerController.queue(work: PDFWorkerController.PDFWork(file: task.file, kind: .recognizer))
.subscribe(onNext: { update in
Expand Down Expand Up @@ -225,7 +223,6 @@ final class RecognizerController {
return
}
statesByTask[task] = .remoteRecognitionInProgress(data: data)
emmitUpdate(for: task, subject: subject, kind: .remoteRecognitionInProgress(data: data))

apiClient.send(request: RecognizerRequest(parameters: data)).subscribe(
onSuccess: { (response: (RemoteRecognizerResponse, HTTPURLResponse)) in
Expand Down Expand Up @@ -327,7 +324,6 @@ final class RecognizerController {
enqueueNextIdentifierLookup(for: task)
return
}
emmitUpdate(for: task, subject: subject, kind: .identifierLookupInProgress(response: response, identifier: identifier))
lookupWebViewHandler.lookUp(identifier: identifier)

func getLookupWebViewHandler(for task: Task) -> LookupWebViewHandler? {
Expand Down
2 changes: 1 addition & 1 deletion Zotero/Scenes/Detail/Items/Models/ItemCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct ItemCellModel {
text = creatorSummary(for: item)
animated = false

case .enqueued, .recognitionInProgress, .remoteRecognitionInProgress, .identifierLookupInProgress, .translated:
case .enqueued, .inProgress, .translated:
text = L10n.Items.retrievingMetadata
animated = true
}
Expand Down

0 comments on commit 8b825ea

Please sign in to comment.