<commit_before>import UIKit

@objc(WMFArticleCollectionViewController)
class ArticleCollectionViewController: ColumnarCollectionViewController, SwipeableDelegate, AnalyticsContextProviding {
    
    fileprivate static let cellReuseIdentifier = "ArticleCollectionViewControllerCell"
    
    let articleURLs: [URL]
    let dataStore: MWKDataStore
    
    @objc required init(articleURLs: [URL], dataStore: MWKDataStore) {
        self.articleURLs = articleURLs
        self.dataStore = dataStore
        super.init()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) not supported")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let collectionView = self.collectionView {
            swipeToEditController = CollectionViewSwipeToEditController(collectionView: collectionView, theme: theme)
        }
        
        swipeToEditController?.primaryActions = [CollectionViewCellActionType.save.action, CollectionViewCellActionType.share.action]
        
        register(ArticleRightAlignedImageCollectionViewCell.self, forCellWithReuseIdentifier: ArticleCollectionViewController.cellReuseIdentifier, addPlaceholder: true)
    }
    
    func articleURL(at indexPath: IndexPath) -> URL {
        return articleURLs[indexPath.section]
    }
    
    // MARK: - SwipeableDelegate
    var swipeToEditController: CollectionViewSwipeToEditController?
    
    var indexPathForSwipeableCell: IndexPath?
    var isActionPaneOpen = false
    
    func didOpenActionPane(_ didOpen: Bool, at indexPath: IndexPath) {
        indexPathForSwipeableCell = indexPath
        isActionPaneOpen = didOpen
        if isActionPaneOpen {
            let cell = collectionView?.cellForItem(at: indexPath) as? ArticleCollectionViewCell
            swipeToEditController?.cellWithActionPaneOpen = cell
        }
        swipeToEditController?.isActionPanOpenInCollectionView = didOpen
    }
    
    var analyticsContext: String {
        return "ArticleList"
    }
    
    func didTapShare(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        let shareActivityController = ShareActivityController(articleURL: url, userDataStore: dataStore, context: self)
        if UIDevice.current.userInterfaceIdiom == .pad {
            shareActivityController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
            
            if let cell = collectionView?.cellForItem(at: indexPath) {
                shareActivityController.popoverPresentationController?.sourceView = cell
                shareActivityController.popoverPresentationController?.sourceRect = cell.bounds
            }
            
        }
        swipeToEditController?.performedAction()
        present(shareActivityController, animated: true, completion: nil)
    }
    
    func didTapDelete(at indexPath: IndexPath) {
        //TODO
    }
    
    func didTapSave(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        if !savedPageList.isSaved(url) {
            savedPageList.addSavedPage(with: url)
            swipeToEditController?.performedAction()
        }
    }
    
    func didTapUnsave(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        savedPageList.removeEntry(with: url)
        swipeToEditController?.performedAction()
    }
    
    func isArticleSaved(at indexPath: IndexPath) -> Bool {
        let url = articleURL(at: indexPath)
        return savedPageList.isSaved(url)
    }
    
    var savedPageList: MWKSavedPageList {
        return dataStore.savedPageList
    }
}

// MARK: - UICollectionViewDataSource
extension ArticleCollectionViewController {
    override func numberOfSections(in collectionView: UICollectionView) -> Int {
        return articleURLs.count
    }
    
    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 1
    }
    
    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ArticleCollectionViewController.cellReuseIdentifier, for: indexPath)
        guard let articleCell = cell as? ArticleRightAlignedImageCollectionViewCell else {
            return cell
        }
        let url = articleURL(at: indexPath)
        guard let article = dataStore.fetchArticle(with: url) else {
            return articleCell
        }
        articleCell.delegate = self
        articleCell.actionsView?.delegate = self
        
        articleCell.configure(article: article, displayType: .page, index: indexPath.section, count: articleURLs.count, shouldAdjustMargins: false, shouldShowSeparators: true, theme: theme, layoutOnly: false)
        

        return articleCell
    }
}

// MARK: - UICollectionViewDelegate
extension ArticleCollectionViewController {
    override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        if isActionPaneOpen { return }
        wmf_pushArticle(with: articleURLs[indexPath.section], dataStore: dataStore, theme: self.theme, animated: true)
    }
}
<commit_msg>Don't highlight the cell with action pane<commit_after>import UIKit

@objc(WMFArticleCollectionViewController)
class ArticleCollectionViewController: ColumnarCollectionViewController, SwipeableDelegate, AnalyticsContextProviding {
    
    fileprivate static let cellReuseIdentifier = "ArticleCollectionViewControllerCell"
    
    let articleURLs: [URL]
    let dataStore: MWKDataStore
    
    @objc required init(articleURLs: [URL], dataStore: MWKDataStore) {
        self.articleURLs = articleURLs
        self.dataStore = dataStore
        super.init()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) not supported")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let collectionView = self.collectionView {
            swipeToEditController = CollectionViewSwipeToEditController(collectionView: collectionView, theme: theme)
        }
        
        swipeToEditController?.primaryActions = [CollectionViewCellActionType.save.action, CollectionViewCellActionType.share.action]
        
        register(ArticleRightAlignedImageCollectionViewCell.self, forCellWithReuseIdentifier: ArticleCollectionViewController.cellReuseIdentifier, addPlaceholder: true)
    }
    
    func articleURL(at indexPath: IndexPath) -> URL {
        return articleURLs[indexPath.section]
    }
    
    // MARK: - SwipeableDelegate
    var swipeToEditController: CollectionViewSwipeToEditController?
    
    var indexPathForSwipeableCell: IndexPath?
    var isActionPaneOpen = false
    
    func didOpenActionPane(_ didOpen: Bool, at indexPath: IndexPath) {
        indexPathForSwipeableCell = indexPath
        isActionPaneOpen = didOpen
        if isActionPaneOpen {
            let cell = collectionView?.cellForItem(at: indexPath) as? ArticleCollectionViewCell
            swipeToEditController?.cellWithActionPaneOpen = cell
        }
        swipeToEditController?.isActionPanOpenInCollectionView = didOpen
    }
    
    var analyticsContext: String {
        return "ArticleList"
    }
    
    func didTapShare(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        let shareActivityController = ShareActivityController(articleURL: url, userDataStore: dataStore, context: self)
        if UIDevice.current.userInterfaceIdiom == .pad {
            shareActivityController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
            
            if let cell = collectionView?.cellForItem(at: indexPath) {
                shareActivityController.popoverPresentationController?.sourceView = cell
                shareActivityController.popoverPresentationController?.sourceRect = cell.bounds
            }
            
        }
        swipeToEditController?.performedAction()
        present(shareActivityController, animated: true, completion: nil)
    }
    
    func didTapDelete(at indexPath: IndexPath) {
        //TODO
    }
    
    func didTapSave(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        if !savedPageList.isSaved(url) {
            savedPageList.addSavedPage(with: url)
            swipeToEditController?.performedAction()
        }
    }
    
    func didTapUnsave(at indexPath: IndexPath) {
        let url = articleURL(at: indexPath)
        savedPageList.removeEntry(with: url)
        swipeToEditController?.performedAction()
    }
    
    func isArticleSaved(at indexPath: IndexPath) -> Bool {
        let url = articleURL(at: indexPath)
        return savedPageList.isSaved(url)
    }
    
    var savedPageList: MWKSavedPageList {
        return dataStore.savedPageList
    }
}

// MARK: - UICollectionViewDataSource
extension ArticleCollectionViewController {
    override func numberOfSections(in collectionView: UICollectionView) -> Int {
        return articleURLs.count
    }
    
    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 1
    }
    
    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ArticleCollectionViewController.cellReuseIdentifier, for: indexPath)
        guard let articleCell = cell as? ArticleRightAlignedImageCollectionViewCell else {
            return cell
        }
        let url = articleURL(at: indexPath)
        guard let article = dataStore.fetchArticle(with: url) else {
            return articleCell
        }
        articleCell.delegate = self
        articleCell.actionsView?.delegate = self
        
        articleCell.configure(article: article, displayType: .page, index: indexPath.section, count: articleURLs.count, shouldAdjustMargins: false, shouldShowSeparators: true, theme: theme, layoutOnly: false)
        

        return articleCell
    }
}

// MARK: - UICollectionViewDelegate
extension ArticleCollectionViewController {
    override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        if isActionPaneOpen { return }
        wmf_pushArticle(with: articleURLs[indexPath.section], dataStore: dataStore, theme: self.theme, animated: true)
    }
    
    override func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
        return !isActionPaneOpen
    }
}

{'fraction_non_alphanumeric': 0.06855481571790303, 'fraction_numerical': 0.00018756447528838038, 'mean_word_length': 3.0748949178448606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3429688', 'n_tokens_mistral': 2830, 'n_tokens_neox': 2797, 'n_words': 595}