@@ -101,7 +101,7 @@ class ReaderViewController: UIViewController, Loggable {
101101 navigator. didMove ( toParent: self )
102102
103103 stackView. addArrangedSubview ( accessibilityToolbar)
104-
104+
105105 positionLabel. translatesAutoresizingMaskIntoConstraints = false
106106 positionLabel. font = . systemFont( ofSize: 12 )
107107 positionLabel. textColor = . darkGray
@@ -181,9 +181,9 @@ class ReaderViewController: UIViewController, Loggable {
181181 }
182182
183183 locatorPublisher
184- . sink ( receiveValue: { locator in
185- self . navigator. go ( to: locator, animated: false ) {
186- self . dismiss ( animated: true )
184+ . sink ( receiveValue: { [ weak self ] locator in
185+ self ? . navigator. go ( to: locator, animated: false ) {
186+ self ? . dismiss ( animated: true )
187187 }
188188 } )
189189 . store ( in: & subscriptions)
@@ -218,9 +218,9 @@ class ReaderViewController: UIViewController, Loggable {
218218 @objc func showSearchUI( ) {
219219 if searchViewModel == nil {
220220 searchViewModel = SearchViewModel ( publication: publication)
221- searchViewModel? . $selectedLocator. sink ( receiveValue: { locator in
222- self . searchViewController? . dismiss ( animated: true , completion: nil )
223- if let locator = locator {
221+ searchViewModel? . $selectedLocator. sink ( receiveValue: { [ weak self ] locator in
222+ self ? . searchViewController? . dismiss ( animated: true , completion: nil )
223+ if let self = self , let locator = locator {
224224 self . navigator. go ( to: locator, animated: true ) {
225225 if let decorator = self . navigator as? DecorableNavigator {
226226 let decoration = Decoration ( id: " selectedSearchResult " , locator: locator, style: Decoration . Style. highlight ( tint: . yellow, isActive: false ) )
@@ -244,8 +244,8 @@ class ReaderViewController: UIViewController, Loggable {
244244 if highlights == nil { return }
245245
246246 if let decorator = self . navigator as? DecorableNavigator {
247- decorator. observeDecorationInteractions ( inGroup: highlightDecorationGroup) { event in
248- self . activateDecoration ( event)
247+ decorator. observeDecorationInteractions ( inGroup: highlightDecorationGroup) { [ weak self ] event in
248+ self ? . activateDecoration ( event)
249249 }
250250 }
251251 }
@@ -255,8 +255,8 @@ class ReaderViewController: UIViewController, Loggable {
255255
256256 highlights. all ( for: bookId)
257257 . assertNoFailure ( )
258- . sink { highlights in
259- if let decorator = self . navigator as? DecorableNavigator {
258+ . sink { [ weak self ] highlights in
259+ if let self = self , let decorator = self . navigator as? DecorableNavigator {
260260 let decorations = highlights. map { Decoration ( id: $0. id, locator: $0. locator, style: . highlight( tint: $0. color. uiColor, isActive: false ) ) }
261261 decorator. apply ( decorations: decorations, in: self . highlightDecorationGroup)
262262 }
@@ -283,17 +283,17 @@ class ReaderViewController: UIViewController, Loggable {
283283 systemFontSize: 20 ,
284284 colorScheme: colorScheme)
285285
286- menuView. selectedColorPublisher. sink { color in
287- self . currentHighlightCancellable? . cancel ( )
288- self . updateHighlight ( event. decoration. id, withColor: color)
289- self . highlightContextMenu? . dismiss ( animated: true , completion: nil )
286+ menuView. selectedColorPublisher. sink { [ weak self ] color in
287+ self ? . currentHighlightCancellable? . cancel ( )
288+ self ? . updateHighlight ( event. decoration. id, withColor: color)
289+ self ? . highlightContextMenu? . dismiss ( animated: true , completion: nil )
290290 }
291291 . store ( in: & subscriptions)
292292
293- menuView. selectedDeletePublisher. sink { _ in
294- self . currentHighlightCancellable? . cancel ( )
295- self . deleteHighlight ( event. decoration. id)
296- self . highlightContextMenu? . dismiss ( animated: true , completion: nil )
293+ menuView. selectedDeletePublisher. sink { [ weak self ] _ in
294+ self ? . currentHighlightCancellable? . cancel ( )
295+ self ? . deleteHighlight ( event. decoration. id)
296+ self ? . highlightContextMenu? . dismiss ( animated: true , completion: nil )
297297 }
298298 . store ( in: & subscriptions)
299299
@@ -385,8 +385,8 @@ extension ReaderViewController: NavigatorDelegate {
385385
386386 func navigator( _ navigator: Navigator , locationDidChange locator: Locator ) {
387387 books. saveProgress ( for: bookId, locator: locator)
388- . sink { completion in
389- if case . failure( let error) = completion {
388+ . sink { [ weak self ] completion in
389+ if let self = self , case . failure( let error) = completion {
390390 self . moduleDelegate? . presentError ( error, from: self )
391391 }
392392 } receiveValue: { _ in }
0 commit comments