Skip to content

Commit

Permalink
Improve PDFWorkerController & RecognizerController relay bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Feb 26, 2025
1 parent f5dcb15 commit ec93630
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Zotero/Controllers/PDFWorkerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ final class PDFWorkerController {
accessQueue.async(flags: .barrier) { [weak self] in
guard let self else { return }
if let existingSubject = subjectsByPDFWork[work] {
existingSubject.subscribe(subject)
.disposed(by: disposeBag)
existingSubject.bind(to: subject).disposed(by: disposeBag)
return
}
queue[work] = subject
Expand Down
5 changes: 2 additions & 3 deletions Zotero/Controllers/RecognizerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ final class RecognizerController {
accessQueue.async(flags: .barrier) { [weak self] in
guard let self else { return }
if let existingSubject = subjectsByTask[task] {
existingSubject.subscribe(subject)
.disposed(by: disposeBag)
existingSubject.bind(to: subject).disposed(by: disposeBag)
return
}
queue[task] = subject
statesByTask[task] = .enqueued
subject.bind(to: updatesSubject).disposed(by: disposeBag)

emmitUpdate(for: task, subject: subject, kind: .enqueued)
startRecognitionIfNeeded()
Expand All @@ -169,7 +169,6 @@ final class RecognizerController {
latestUpdates[libraryId] = libraryLatestUpdates
}
subject.on(.next(update))
updatesSubject.on(.next(update))
}

private func startRecognitionIfNeeded() {
Expand Down

0 comments on commit ec93630

Please sign in to comment.