     var listeningHistoryTableView: EmptyStateTableView! //not a delegate because no action button
     var episodes: [Episode] = []
     var episodeSet = Set<Episode>()
-    
+    var continueInfiniteScroll: Bool = true
     let pageSize: Int = 20
     var offset: Int = 0
     

        listeningHistoryTableView.addInfiniteScroll { tableView in
            self.fetchEpisodes(refresh: false)
        }
        self.fetchEpisodes()
    
        listeningHistoryTableView.refreshControl?.addTarget(self, action: #selector(fetchEpisodes), for: .valueChanged)

        let historyRequest = FetchListeningHistoryEndpointRequest(offset: offset, max: pageSize)
        historyRequest.success = { request in
            guard let newEpisodes = request.processedResponseValue as? [Episode] else { return }
            let oldCount = self.episodeSet.count
            for episode in newEpisodes {
                self.episodeSet.insert(episode)
            }
            if oldCount == self.episodeSet.count { self.continueInfiniteScroll = false }
            self.episodes = self.episodeSet.sorted { (e1,e2) in e1.dateCreated > e2.dateCreated } //TODO: order these by listening history creation
            self.listeningHistoryTableView.endRefreshing()
            self.listeningHistoryTableView.stopLoadingAnimation()
            self.listeningHistoryTableView.finishInfiniteScroll()
            self.listeningHistoryTableView.reloadData()
        }

        historyRequest.failure = { _ in
            self.listeningHistoryTableView.endRefreshing()
            self.listeningHistoryTableView.stopLoadingAnimation()
            self.listeningHistoryTableView.finishInfiniteScroll()
        }
        System.endpointRequestQueue.addOperation(historyRequest)
