NetNewsWire/Shared/Importers/DefaultFeedsImporter.swift

33 lines
806 B
Swift
Raw Normal View History

2017-05-27 10:43:27 -07:00
//
// DefaultFeedsImporter.swift
2018-08-28 22:18:24 -07:00
// NetNewsWire
2017-05-27 10:43:27 -07:00
//
// Created by Brent Simmons on 8/13/15.
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
//
import Foundation
2017-09-17 12:34:10 -07:00
import Account
import RSCore
2017-05-27 10:43:27 -07:00
2017-09-24 22:35:57 -07:00
struct DefaultFeedsImporter {
2017-05-27 10:43:27 -07:00
static func importIfNeeded(_ isFirstRun: Bool, account: Account) {
guard shouldImportDefaultFeeds(isFirstRun) else {
return
2017-09-24 22:35:57 -07:00
}
appDelegate.logDebugMessage("Importing default feeds.")
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
AccountManager.shared.defaultAccount.importOPML(defaultFeedsURL) { result in }
2017-05-27 10:43:27 -07:00
}
2017-09-24 22:35:57 -07:00
private static func shouldImportDefaultFeeds(_ isFirstRun: Bool) -> Bool {
2017-10-02 13:15:07 -07:00
if !isFirstRun || AccountManager.shared.anyAccountHasAtLeastOneFeed() {
2017-05-27 10:43:27 -07:00
return false
}
2017-09-24 22:35:57 -07:00
return true
2017-05-27 10:43:27 -07:00
}
}