#47 Remove requests to other instances during sign-in process

This commit is contained in:
Marcin Czachurski 2023-04-19 15:42:07 +02:00
parent 00da250b21
commit 3983cb97ad
3 changed files with 6 additions and 37 deletions

View File

@ -5,47 +5,16 @@
//
import Foundation
import PixelfedKit
public struct AppMetadata: Codable {
public let instructionsUrl: String
public let serversUrl: String
public let instances: [String]
public let instances: [Instance]
init() {
self.instructionsUrl = "https://pixelfed.org/how-to-join"
self.serversUrl = "https://pixelfed.org/servers"
self.instances = [
"https://pixelfed.de",
"https://pixelfed.social",
"https://pxlmo.com",
"https://metapixl.com",
"https://pixey.org",
"https://pixel.tchncs.de",
"https://pixelfed.tokyo",
"https://pixelfed.fr",
"https://pixelfed.nz",
"https://pixelfed.au",
"https://pixelfed.eus",
"https://pixelfed.bachgau.social",
"https://pixelfed.es",
"https://pixelfed.cz",
"https://pixelfed.automat.click",
"https://gram.social",
"https://nixorigin.one",
"https://miniature.photography",
"https://fedifilm.art",
"https://fedipix.de",
"https://pixel.jabbxi.de",
"https://nodegray.com",
"https://socialpixels.xyz",
"https://pixel.mamutut.space",
"https://pixelfed.fioverse.zone",
"https://pixel.artemai.art",
"https://pix.anduin.net",
"https://faf.photos",
"https://pix.vleij.com",
"https://pixels.gsi.li",
"https://eorzea.photos"
]
self.instances = []
}
}

View File

@ -12,7 +12,7 @@ public class AppMetadataService {
public static let shared = AppMetadataService()
private init() { }
private let metadataUrl = URL(string: "https://raw.githubusercontent.com/VernissageApp/Home/main/instances.json")!
private let metadataUrl = URL(string: "https://raw.githubusercontent.com/VernissageApp/Home/main/instances2.json")!
private let metadataCacheKey = "metadataCacheKey"
private var memoryCacheData = MemoryCache<String, AppMetadata>(entryLifetime: 600)

View File

@ -74,7 +74,7 @@ struct SignInView: View {
}
}
ForEach(self.instances, id: \.uri) { instance in
ForEach(self.instances.filter { self.serverAddress.isEmpty || $0.uri.contains(self.serverAddress) }, id: \.uri) { instance in
InstanceRowView(instance: instance) { uri in
let baseAddress = self.getServerAddress(uri: uri)
self.signIn(baseAddress: baseAddress)
@ -84,7 +84,7 @@ struct SignInView: View {
}
.onFirstAppear {
let metadata = await AppMetadataService.shared.metadata()
self.instances = await self.client.instances.instances(instanceUrls: metadata.instances)
self.instances = metadata.instances
self.instructionsUrlString = metadata.instructionsUrl
}
.navigationTitle("signin.navigationBar.title")