From d849083258b8d849b1f572ec3ed8c782006721fd Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Fri, 9 Aug 2024 03:39:54 -0700 Subject: [PATCH] Removed unused problematic code --- Planet/Entities/MyPlanetModel+Aggregate.swift | 5 ++++- Planet/Entities/MyPlanetModel.swift | 7 +------ Planet/Helper/KeyboardShortcutHelper.swift | 2 +- Planet/IPFS/IPFSDaemon.swift | 9 --------- Planet/IPFS/IPFSGateway.swift | 7 ------- .../PFDashboardWindowController.swift | 4 ++-- .../Settings/PlanetSettingsGeneralView.swift | 19 ------------------- Planet/versioning.xcconfig | 2 +- 8 files changed, 9 insertions(+), 46 deletions(-) diff --git a/Planet/Entities/MyPlanetModel+Aggregate.swift b/Planet/Entities/MyPlanetModel+Aggregate.swift index b423af87..64c93e1b 100644 --- a/Planet/Entities/MyPlanetModel+Aggregate.swift +++ b/Planet/Entities/MyPlanetModel+Aggregate.swift @@ -337,8 +337,11 @@ extension MyPlanetModel { Task(priority: .utility) { try existingArticle.savePublic() } - DispatchQueue.main.async { + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { PlanetStore.shared.refreshSelectedArticles() + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + NotificationCenter.default.post(name: .loadArticle, object: nil) + } } } } diff --git a/Planet/Entities/MyPlanetModel.swift b/Planet/Entities/MyPlanetModel.swift index 7f75db91..6cc003d5 100644 --- a/Planet/Entities/MyPlanetModel.swift +++ b/Planet/Entities/MyPlanetModel.swift @@ -1402,15 +1402,12 @@ class MyPlanetModel: Equatable, Hashable, Identifiable, ObservableObject, Codabl tags: tags ) let environment = Environment(extensions: [StencilExtension.common]) - let domain_prefix: String let root_prefix: String if let domainWithGateway = domainWithGateway { - domain_prefix = "https://" + domainWithGateway root_prefix = "https://" + domainWithGateway } else { - domain_prefix = IPFSDaemon.preferredGateway() - root_prefix = IPFSDaemon.preferredGateway() + "/ipns/" + ipns + root_prefix = "https://eth.sucks/ipns/" + ipns } var hasDomain: Bool = false if let planetDomain = domain, planetDomain.count > 0, !planetDomain.contains(":") { @@ -1420,9 +1417,7 @@ class MyPlanetModel: Equatable, Hashable, Identifiable, ObservableObject, Codabl "planet": publicPlanet, "has_domain": hasDomain, "domain": domainWithGateway ?? "", - "domain_prefix": domain_prefix, "root_prefix": root_prefix, - "ipfs_gateway": IPFSDaemon.preferredGateway(), "podcast": podcastOnly, "has_podcast_cover_art": FileManager.default.fileExists( atPath: publicPodcastCoverArtPath.path diff --git a/Planet/Helper/KeyboardShortcutHelper.swift b/Planet/Helper/KeyboardShortcutHelper.swift index b1dacb05..5c2b22d3 100644 --- a/Planet/Helper/KeyboardShortcutHelper.swift +++ b/Planet/Helper/KeyboardShortcutHelper.swift @@ -368,7 +368,7 @@ class KeyboardShortcutHelper: ObservableObject { Button { if let url = URL( string: - "\(IPFSDaemon.preferredGateway())/ipns/\(publishedLink)" + "https://eth.sucks/ipns/\(publishedLink)" ) { self.openURL(url) } diff --git a/Planet/IPFS/IPFSDaemon.swift b/Planet/IPFS/IPFSDaemon.swift index a505dff0..0b73d253 100644 --- a/Planet/IPFS/IPFSDaemon.swift +++ b/Planet/IPFS/IPFSDaemon.swift @@ -754,20 +754,11 @@ extension IPFSDaemon { ] // Filebase ]) - static func preferredGateway() -> String { - let index: Int = UserDefaults.standard.integer(forKey: String.settingsPublicGatewayIndex) - return IPFSGateway.publicGateways[index] - } - static func urlForCID(_ cid: String) -> URL? { - // let gateway = IPFSDaemon.preferredGateway() - // return URL(string: gateway + "/ipfs/" + cid) return URL(string: "https://\(cid).ipfs2.eth.limo/") } static func urlForIPNS(_ ipns: String) -> URL? { - // let gateway = IPFSDaemon.preferredGateway() - // return URL(string: gateway + "/ipns/" + ipns) return URL(string: "https://\(ipns).ipfs2.eth.limo/") } diff --git a/Planet/IPFS/IPFSGateway.swift b/Planet/IPFS/IPFSGateway.swift index 178f0654..063e81c9 100644 --- a/Planet/IPFS/IPFSGateway.swift +++ b/Planet/IPFS/IPFSGateway.swift @@ -41,11 +41,4 @@ enum IPFSGateway: String, Codable, CaseIterable { let gateway = UserDefaults.standard.string(forKey: String.settingsPreferredIPFSPublicGateway) return IPFSGateway(rawValue: gateway ?? IPFSGateway.defaultGateway.rawValue) ?? IPFSGateway.defaultGateway } - - static let publicGateways: [String] = [ - "https://ipfs.io", - "https://dweb.link", - "https://gateway.pinata.cloud", - "https://ipfs.fleek.co" - ] } diff --git a/Planet/Labs/Published Folders/Dashboard/PFDashboardWindowController.swift b/Planet/Labs/Published Folders/Dashboard/PFDashboardWindowController.swift index 1636c488..d5ef0433 100644 --- a/Planet/Labs/Published Folders/Dashboard/PFDashboardWindowController.swift +++ b/Planet/Labs/Published Folders/Dashboard/PFDashboardWindowController.swift @@ -285,7 +285,7 @@ extension PFDashboardWindowController: NSToolbarDelegate { if let selectedID = serviceStore.selectedFolderID, let folder = serviceStore.publishedFolders.first(where: { $0.id == selectedID }) { let menu = NSMenu() if let _ = folder.published, let publishedLink = folder.publishedLink { - if let gatewayURL = URL(string: "\(IPFSDaemon.preferredGateway())/ipns/\(publishedLink)") { + if let gatewayURL = URL(string: "https://eth.sucks/ipns/\(publishedLink)") { let publicGatewayActionItem = NSMenuItem() publicGatewayActionItem.representedObject = gatewayURL publicGatewayActionItem.title = "Open in Public Gateway" @@ -432,7 +432,7 @@ extension PFDashboardWindowController: NSToolbarDelegate { extension PFDashboardWindowController: NSSharingServicePickerToolbarItemDelegate { func items(for pickerToolbarItem: NSSharingServicePickerToolbarItem) -> [Any] { let serviceStore = PlanetPublishedServiceStore.shared - guard let selectedID = serviceStore.selectedFolderID, let folder = serviceStore.publishedFolders.first(where: { $0.id == selectedID }), let _ = folder.published, let publishedLink = folder.publishedLink, let url = URL(string: "\(IPFSDaemon.preferredGateway())/ipns/\(publishedLink)") else { return [] } + guard let selectedID = serviceStore.selectedFolderID, let folder = serviceStore.publishedFolders.first(where: { $0.id == selectedID }), let _ = folder.published, let publishedLink = folder.publishedLink, let url = URL(string: "https://eth.sucks/ipns/\(publishedLink)") else { return [] } let sharableItems = [url] return sharableItems } diff --git a/Planet/Settings/PlanetSettingsGeneralView.swift b/Planet/Settings/PlanetSettingsGeneralView.swift index f75e688a..f8cbb4fd 100644 --- a/Planet/Settings/PlanetSettingsGeneralView.swift +++ b/Planet/Settings/PlanetSettingsGeneralView.swift @@ -84,25 +84,6 @@ struct PlanetSettingsGeneralView: View { .padding(.top, -10) } - // Obsoleted by ipfs2.eth.limo - /* - HStack(spacing: 4) { - Text("Public Gateway") - .frame(width: CAPTION_WIDTH, alignment: .trailing) - Picker(selection: $publicGatewayIndex, label: Text("")) { - ForEach(0..