diff --git a/Mlem/Models/Trackers/SiteInformationTracker.swift b/Mlem/Models/Trackers/SiteInformationTracker.swift index 0fd58be25..b15e523af 100644 --- a/Mlem/Models/Trackers/SiteInformationTracker.swift +++ b/Mlem/Models/Trackers/SiteInformationTracker.swift @@ -14,6 +14,7 @@ class SiteInformationTracker: ObservableObject { @Dependency(\.errorHandler) var errorHandler @Dependency(\.accountsTracker) var accountsTracker + @Published private(set) var instance: InstanceModel? @Published private(set) var enableDownvotes = true @Published var version: SiteVersion? @Published private(set) var allLanguages: [APILanguage] = .init() @@ -23,8 +24,8 @@ class SiteInformationTracker: ObservableObject { version = account.siteVersion Task { do { - let response = try await apiClient.loadSiteInformation() + instance = .init(from: response) enableDownvotes = response.siteView.localSite.enableDownvotes version = SiteVersion(response.version) if version != account.siteVersion { diff --git a/Mlem/Views/Shared/Instance/InstanceView.swift b/Mlem/Views/Shared/Instance/InstanceView.swift index 9a4ed5209..5380644c6 100644 --- a/Mlem/Views/Shared/Instance/InstanceView.swift +++ b/Mlem/Views/Shared/Instance/InstanceView.swift @@ -27,6 +27,7 @@ enum InstanceViewTab: String, Identifiable, CaseIterable { struct InstanceView: View { @Dependency(\.apiClient) var apiClient: APIClient @Dependency(\.errorHandler) var errorHandler + @Dependency(\.siteInformation) var siteInformation @Environment(\.navigationPathWithRoutes) private var navigationPath @Environment(\.scrollViewProxy) private var scrollViewProxy @@ -42,6 +43,10 @@ struct InstanceView: View { init(domainName: String, instance: InstanceModel? = nil) { _domainName = State(wrappedValue: domainName) + var instance = instance + if domainName == siteInformation.instance?.url.host() { + instance = siteInformation.instance ?? instance + } _instance = State(wrappedValue: instance) }