mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Remove Master from names.
This commit is contained in:
64
iOS/Feeds/UpdateSelectionOperation.swift
Normal file
64
iOS/Feeds/UpdateSelectionOperation.swift
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// UpdateSelectionOperation.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 2/22/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import RSCore
|
||||
|
||||
class UpdateSelectionOperation: MainThreadOperation {
|
||||
|
||||
// MainThreadOperation
|
||||
public var isCanceled = false
|
||||
public var id: Int?
|
||||
public weak var operationDelegate: MainThreadOperationDelegate?
|
||||
public var name: String? = "UpdateSelectionOperation"
|
||||
public var completionBlock: MainThreadOperation.MainThreadOperationCompletionBlock?
|
||||
|
||||
private var coordinator: SceneCoordinator
|
||||
private var dataSource: MasterFeedDataSource
|
||||
private var tableView: UITableView
|
||||
private var animations: Animations
|
||||
|
||||
init(coordinator: SceneCoordinator, dataSource: MasterFeedDataSource, tableView: UITableView, animations: Animations) {
|
||||
self.coordinator = coordinator
|
||||
self.dataSource = dataSource
|
||||
self.tableView = tableView
|
||||
self.animations = animations
|
||||
}
|
||||
|
||||
func run() {
|
||||
if dataSource.snapshot().numberOfItems > 0 {
|
||||
if let indexPath = coordinator.currentFeedIndexPath {
|
||||
CATransaction.begin()
|
||||
CATransaction.setCompletionBlock {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
tableView.selectRowAndScrollIfNotVisible(at: indexPath, animations: animations)
|
||||
CATransaction.commit()
|
||||
} else {
|
||||
if let indexPath = tableView.indexPathForSelectedRow {
|
||||
if animations.contains(.select) {
|
||||
CATransaction.begin()
|
||||
CATransaction.setCompletionBlock {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
CATransaction.commit()
|
||||
} else {
|
||||
tableView.deselectRow(at: indexPath, animated: false)
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
} else {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.operationDelegate?.operationDidComplete(self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user