Rollback code created to support background downloads that are no longer needed
This commit is contained in:
parent
76b922546c
commit
e10bfde6d9
|
@ -209,13 +209,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
// MARK: - API
|
||||
|
||||
public func restore() {
|
||||
delegate.restore()
|
||||
}
|
||||
public func refreshAll() {
|
||||
|
||||
public func refreshAll(refreshMode: AccountRefreshMode) {
|
||||
|
||||
delegate.refreshAll(for: self, refreshMode: refreshMode)
|
||||
delegate.refreshAll(for: self)
|
||||
}
|
||||
|
||||
public func update(_ feed: Feed, with parsedFeed: ParsedFeed, _ completion: @escaping RSVoidCompletionBlock) {
|
||||
|
@ -360,7 +356,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
structureDidChange()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.refreshAll(refreshMode: .forground)
|
||||
self.refreshAll()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
519881F52271EF43008D4FA8 /* AccountRefreshMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519881F42271EF43008D4FA8 /* AccountRefreshMode.swift */; };
|
||||
841973FE1F6DD1BC006346C4 /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841973EF1F6DD19E006346C4 /* RSCore.framework */; };
|
||||
841973FF1F6DD1C5006346C4 /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841973FA1F6DD1AC006346C4 /* RSParser.framework */; };
|
||||
841974011F6DD1EC006346C4 /* Folder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841974001F6DD1EC006346C4 /* Folder.swift */; };
|
||||
|
@ -84,7 +83,6 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
519881F42271EF43008D4FA8 /* AccountRefreshMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountRefreshMode.swift; sourceTree = "<group>"; };
|
||||
841973E81F6DD19E006346C4 /* RSCore.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSCore.xcodeproj; path = ../RSCore/RSCore.xcodeproj; sourceTree = "<group>"; };
|
||||
841973F41F6DD1AC006346C4 /* RSParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSParser.xcodeproj; path = ../RSParser/RSParser.xcodeproj; sourceTree = "<group>"; };
|
||||
841974001F6DD1EC006346C4 /* Folder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Folder.swift; sourceTree = "<group>"; };
|
||||
|
@ -205,7 +203,6 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
846E77531F6F00E300A165E2 /* AccountManager.swift */,
|
||||
519881F42271EF43008D4FA8 /* AccountRefreshMode.swift */,
|
||||
848935101F62486800CEBD24 /* Account.swift */,
|
||||
84AF4EA3222CFDD100F6A800 /* AccountSettings.swift */,
|
||||
841974241F6DDCE4006346C4 /* AccountDelegate.swift */,
|
||||
|
@ -430,7 +427,6 @@
|
|||
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
|
||||
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
|
||||
84D09623217418DC00D77525 /* FeedbinTagging.swift in Sources */,
|
||||
519881F52271EF43008D4FA8 /* AccountRefreshMode.swift in Sources */,
|
||||
84CAD7161FDF2E22000F0755 /* FeedbinArticle.swift in Sources */,
|
||||
84D0962521741B8500D77525 /* FeedbinSavedSearch.swift in Sources */,
|
||||
841974011F6DD1EC006346C4 /* Folder.swift in Sources */,
|
||||
|
|
|
@ -16,9 +16,7 @@ public protocol AccountDelegate {
|
|||
|
||||
var refreshProgress: DownloadProgress { get }
|
||||
|
||||
func restore()
|
||||
|
||||
func refreshAll(for: Account, refreshMode: AccountRefreshMode)
|
||||
func refreshAll(for: Account)
|
||||
|
||||
// Called at the end of account’s init method.
|
||||
|
||||
|
|
|
@ -84,13 +84,9 @@ public final class AccountManager: UnreadCountProvider {
|
|||
return accountsDictionary[accountID]
|
||||
}
|
||||
|
||||
public func restore() {
|
||||
accounts.forEach { $0.restore() }
|
||||
}
|
||||
public func refreshAll() {
|
||||
|
||||
public func refreshAll(refreshMode: AccountRefreshMode = .forground) {
|
||||
|
||||
accounts.forEach { $0.refreshAll(refreshMode: refreshMode) }
|
||||
accounts.forEach { $0.refreshAll() }
|
||||
}
|
||||
|
||||
public func anyAccountHasAtLeastOneFeed() -> Bool {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
//
|
||||
// AccountRefreshMode.swift
|
||||
// Account
|
||||
//
|
||||
// Created by Maurice Parker on 4/25/19.
|
||||
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum AccountRefreshMode {
|
||||
case background
|
||||
case forground
|
||||
}
|
|
@ -18,13 +18,9 @@ final class LocalAccountDelegate: AccountDelegate {
|
|||
return refresher.progress
|
||||
}
|
||||
|
||||
func restore() {
|
||||
refresher.restore()
|
||||
}
|
||||
func refreshAll(for account: Account) {
|
||||
|
||||
func refreshAll(for account: Account, refreshMode: AccountRefreshMode) {
|
||||
|
||||
refresher.refreshFeeds(account.flattenedFeeds(), refreshMode: refreshMode)
|
||||
refresher.refreshFeeds(account.flattenedFeeds())
|
||||
}
|
||||
|
||||
func accountDidInitialize(_ account: Account) {
|
||||
|
|
|
@ -14,29 +14,18 @@ import Articles
|
|||
|
||||
final class LocalAccountRefresher {
|
||||
|
||||
var progress = DownloadProgress(numberOfTasks: 0)
|
||||
|
||||
private lazy var backgroundDownloadSession: DownloadSession = {
|
||||
return BackgroundDownloadSession(delegate: self, progress: DownloadProgress(numberOfTasks: 0))
|
||||
private lazy var downloadSession: DownloadSession = {
|
||||
return DownloadSession(delegate: self)
|
||||
}()
|
||||
|
||||
private lazy var defaultDownloadSession: DownloadSession = {
|
||||
return DefaultDownloadSession(delegate: self, progress: progress)
|
||||
}()
|
||||
|
||||
public func restore() {
|
||||
_ = backgroundDownloadSession
|
||||
_ = defaultDownloadSession
|
||||
var progress: DownloadProgress {
|
||||
return downloadSession.progress
|
||||
}
|
||||
|
||||
public func refreshFeeds(_ feeds: Set<Feed>, refreshMode: AccountRefreshMode) {
|
||||
if refreshMode == .forground {
|
||||
defaultDownloadSession.downloadObjects(feeds as NSSet)
|
||||
} else {
|
||||
backgroundDownloadSession.downloadObjects(feeds as NSSet)
|
||||
}
|
||||
}
|
||||
public func refreshFeeds(_ feeds: Set<Feed>) {
|
||||
|
||||
downloadSession.downloadObjects(feeds as NSSet)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - DownloadSessionDelegate
|
||||
|
@ -116,14 +105,23 @@ extension LocalAccountRefresher: DownloadSessionDelegate {
|
|||
return true
|
||||
}
|
||||
|
||||
func downloadSession(_ downloadSession: DownloadSession, didReceiveUnexpectedResponse: URLResponse, representedObject: AnyObject) {
|
||||
func downloadSession(_ downloadSession: DownloadSession, didReceiveUnexpectedResponse response: URLResponse, representedObject: AnyObject) {
|
||||
|
||||
// guard let feed = representedObject as? Feed else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// print("Unexpected response \(response) for \(feed.url).")
|
||||
}
|
||||
|
||||
func downloadSession(_ downloadSession: DownloadSession, didReceiveNotModifiedResponse: URLResponse, representedObject: AnyObject) {
|
||||
|
||||
// guard let feed = representedObject as? Feed else {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// print("Not modified response for \(feed.url).")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Utility
|
||||
|
|
|
@ -45,7 +45,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
|
||||
|
||||
AccountManager.shared.restore()
|
||||
// Reinitialize the shared state as early as possible
|
||||
_ = AccountManager.shared
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8b517a8b53bdbbbf2c3bf2b809ca51d586fcf6ad
|
||||
Subproject commit 68704373aa0c34c01f470bb7373da1f4ae7f5d57
|
Loading…
Reference in New Issue