mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Stop including AppDefaults in share extension.
This commit is contained in:
1 parent
2ce850441b
commit
dccf7d3e89
2 files changed
+8
-11
No files matched your search
@@ -333,7 +333,6 @@
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
/Localized/ShareExtension/ShareViewController.xib,
|
||||
AppDefaults.swift,
|
||||
ShareExtension/icon.icns,
|
||||
ShareExtension/ShareViewController.swift,
|
||||
);
|
||||
@@ -378,7 +377,6 @@
|
||||
84A6D0402D1B4EC500F23315 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
AppDefaults.swift,
|
||||
Resources/Assets.xcassets,
|
||||
ShareExtension/ShareFolderPickerAccountCell.xib,
|
||||
ShareExtension/ShareFolderPickerCell.swift,
|
||||
@@ -416,7 +414,6 @@
|
||||
84D35E0C2DB9F32D004AA60E /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
ArticleSpecifier.swift,
|
||||
Assets.swift,
|
||||
"Extensions/Node+Extensions.swift",
|
||||
ShareExtension/ExtensionContainers.swift,
|
||||
@@ -425,7 +422,6 @@
|
||||
ShareExtension/ExtensionFeedAddRequestFile.swift,
|
||||
ShareExtension/SafariExt.js,
|
||||
ShareExtension/ShareDefaultContainer.swift,
|
||||
UserInfoKey.swift,
|
||||
);
|
||||
target = 513C5CE5232571C2003D4054 /* NetNewsWire iOS Share Extension */;
|
||||
};
|
||||
@@ -442,14 +438,12 @@
|
||||
84D35E0F2DB9F32D004AA60E /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
"Article Rendering/ArticleTextSize.swift",
|
||||
ShareExtension/ExtensionContainers.swift,
|
||||
ShareExtension/ExtensionContainersFile.swift,
|
||||
ShareExtension/ExtensionFeedAddRequest.swift,
|
||||
ShareExtension/ExtensionFeedAddRequestFile.swift,
|
||||
ShareExtension/SafariExt.js,
|
||||
ShareExtension/ShareDefaultContainer.swift,
|
||||
Timer/RefreshInterval.swift,
|
||||
);
|
||||
target = 510C415B24E5CDE3008226FD /* NetNewsWire Share Extension */;
|
||||
};
|
||||
|
||||
@@ -10,10 +10,13 @@ import Foundation
|
||||
|
||||
@MainActor struct ShareDefaultContainer {
|
||||
|
||||
private static let addFeedAccountIDKey = "addFeedAccountID"
|
||||
private static let addFeedFolderNameKey = "addFeedFolderName"
|
||||
|
||||
static func defaultContainer(containers: ExtensionContainers) -> ExtensionContainer? {
|
||||
|
||||
if let accountID = AppDefaults.addFeedAccountID, let account = containers.accounts.first(where: { $0.accountID == accountID }) {
|
||||
if let folderName = AppDefaults.addFeedFolderName, let folder = account.folders.first(where: { $0.name == folderName }) {
|
||||
if let accountID = UserDefaults.standard.string(forKey: addFeedAccountIDKey), let account = containers.accounts.first(where: { $0.accountID == accountID }) {
|
||||
if let folderName = UserDefaults.standard.string(forKey: addFeedFolderNameKey), let folder = account.folders.first(where: { $0.name == folderName }) {
|
||||
return folder
|
||||
} else {
|
||||
return substituteContainerIfNeeded(account: account)
|
||||
@@ -27,11 +30,11 @@ import Foundation
|
||||
}
|
||||
|
||||
static func saveDefaultContainer(_ container: ExtensionContainer) {
|
||||
AppDefaults.addFeedAccountID = container.accountID
|
||||
UserDefaults.standard.set(container.accountID, forKey: addFeedAccountIDKey)
|
||||
if let folder = container as? ExtensionFolder {
|
||||
AppDefaults.addFeedFolderName = folder.name
|
||||
UserDefaults.standard.set(folder.name, forKey: addFeedFolderNameKey)
|
||||
} else {
|
||||
AppDefaults.addFeedFolderName = nil
|
||||
UserDefaults.standard.removeObject(forKey: addFeedFolderNameKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user