mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix import/export subscriptions
Beta 6 has changed the way import and export works. It's changed from a environment variable to view modifier now.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import Account
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
enum FeedsSettingsError: LocalizedError, Equatable {
|
||||
case none, noActiveAccount, exportFailed(reason: String?), importFailed
|
||||
@@ -51,6 +52,11 @@ class FeedsSettingsModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
@Published var showError: Bool = false
|
||||
@Published var isImporting: Bool = false
|
||||
@Published var isExporting: Bool = false
|
||||
@Published var selectedAccount: Account? = nil
|
||||
|
||||
let importingContentTypes: [UTType] = [UTType(filenameExtension: "opml"), UTType("public.xml")].compactMap { $0 }
|
||||
|
||||
func checkForActiveAccount() -> Bool {
|
||||
if AccountManager.shared.activeAccounts.count == 0 {
|
||||
@@ -60,7 +66,18 @@ class FeedsSettingsModel: ObservableObject {
|
||||
return true
|
||||
}
|
||||
|
||||
func generateExportURL(for account: Account) -> URL? {
|
||||
func importOPML(account: Account?) {
|
||||
selectedAccount = account
|
||||
isImporting = true
|
||||
}
|
||||
|
||||
func exportOPML(account: Account?) {
|
||||
selectedAccount = account
|
||||
isExporting = true
|
||||
}
|
||||
|
||||
func generateExportURL() -> URL? {
|
||||
guard let account = selectedAccount else { return nil }
|
||||
let accountName = account.nameForDisplay.replacingOccurrences(of: " ", with: "").trimmingCharacters(in: .whitespaces)
|
||||
let filename = "Subscriptions-\(accountName).opml"
|
||||
let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename)
|
||||
@@ -75,9 +92,9 @@ class FeedsSettingsModel: ObservableObject {
|
||||
return tempFile
|
||||
}
|
||||
|
||||
func processImportedFiles(_ urls: [URL],_ account: Account?) {
|
||||
func processImportedFiles(_ urls: [URL]) {
|
||||
urls.forEach{
|
||||
account?.importOPML($0, completion: { [weak self] result in
|
||||
selectedAccount?.importOPML($0, completion: { [weak self] result in
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user