2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// DefaultFeedsImporter.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWire
|
2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 8/13/15.
|
|
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2017-09-17 21:34:10 +02:00
|
|
|
import Account
|
2017-11-15 22:26:10 +01:00
|
|
|
import RSCore
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-09-25 07:35:57 +02:00
|
|
|
struct DefaultFeedsImporter {
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2019-03-15 06:23:16 +01:00
|
|
|
static func importIfNeeded(_ isFirstRun: Bool, account: Account) {
|
|
|
|
guard shouldImportDefaultFeeds(isFirstRun) else {
|
|
|
|
return
|
2017-09-25 07:35:57 +02:00
|
|
|
}
|
2019-03-15 06:23:16 +01:00
|
|
|
|
|
|
|
appDelegate.logDebugMessage("Importing default feeds.")
|
|
|
|
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
|
|
|
|
try! OPMLImporter.parseAndImport(fileURL: defaultFeedsURL, account: AccountManager.shared.localAccount)
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|
2019-03-15 06:23:16 +01:00
|
|
|
|
2017-09-25 07:35:57 +02:00
|
|
|
private static func shouldImportDefaultFeeds(_ isFirstRun: Bool) -> Bool {
|
2017-10-02 22:15:07 +02:00
|
|
|
if !isFirstRun || AccountManager.shared.anyAccountHasAtLeastOneFeed() {
|
2017-05-27 19:43:27 +02:00
|
|
|
return false
|
|
|
|
}
|
2017-09-25 07:35:57 +02:00
|
|
|
return true
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|