 //  Copyright © 2016 Jeffrey Bergier. All rights reserved.
 //
 
-import Aspects
 import RealmSwift
 import SafariServices
 import UIKit

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.tableView?.flashScrollIndicators()
    }
    
    fileprivate lazy var presentedViewControllerDidDisappear: @convention(block) (Void) -> Void = { [weak self] in
        self?.tableView?.deselectAllRows(animated: true)
        self?.tableView?.flashScrollIndicators()
    }
    
    private var notificationToken: NotificationToken?

    }
}

extension URLListViewController: UIViewControllerPreviewingDelegate {
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        guard
            let tableView = self.tableView,
            let indexPath = tableView.indexPathForRow(at: self.view.convert(location, to: tableView)),
            let cellView = tableView.cellForRow(at: indexPath),
            let item = self.data?[indexPath.row],
            let url = URL(string: item.urlString)
        else { return .none }
        
        previewingContext.sourceRect = tableView.convert(cellView.frame, to: self.view)
        let sfVC = SFSafariViewController(url: url, entersReaderIfAvailable: false)
        
        return sfVC
    }
    
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
        guard viewControllerToCommit is SFSafariViewController else { return }
        self.present(viewControllerToCommit, animated: true, completion: .none)
    }
    
    /*
    // possible future code to add 3d touch actions
    let closure: ((Void) -> [UIPreviewActionItem]) = {
        let archiveAction = UIPreviewAction(title: "Archive", style: .default) { action in
            print(action)
        }
        return [archiveAction]
    }
    let block: @convention(block) (Void) -> [UIPreviewActionItem] = closure
    let _ = try! sfVC.aspect_hook(#selector(getter: UIViewController.previewActionItems), with: .positionBefore, usingBlock: block)
    */
}

extension URLListViewController: UITableViewDelegate {
 
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let selectedItems = self.selectedURLItems ?? []
        if tableView.isEditing {
