Add demo instance, remove public manifest

This commit is contained in:
Arkadiusz Fal
2022-10-26 13:11:35 +02:00
parent 8ab6a0fa89
commit 1fe01808a4
16 changed files with 488 additions and 58 deletions

View File

@@ -8,6 +8,7 @@ struct AccountsNavigationLink: View {
NavigationLink(instance.longDescription) {
InstanceSettings(instance: instance)
}
.disabled(instance.app == .demoApp)
.buttonStyle(.plain)
.contextMenu {
removeInstanceButton(instance)

View File

@@ -41,28 +41,30 @@ struct LocationsSettings: View {
}
@ViewBuilder var settings: some View {
Section(header: SettingsHeader(text: "Public Locations".localized()), footer: countryFooter) {
Picker("Country", selection: $countryOfPublicInstances) {
Text("Don't use public locations").tag(String?.none)
ForEach(countries, id: \.self) { country in
Text(country).tag(Optional(country))
if !InstancesManifest.shared.manifestURL.isNil {
Section(header: SettingsHeader(text: "Public Locations".localized()), footer: countryFooter) {
Picker("Country", selection: $countryOfPublicInstances) {
Text("Don't use public locations").tag(String?.none)
ForEach(countries, id: \.self) { country in
Text(country).tag(Optional(country))
}
}
}
#if os(tvOS)
.pickerStyle(.inline)
#endif
.disabled(countries.isEmpty)
#if os(tvOS)
.pickerStyle(.inline)
#endif
.disabled(countries.isEmpty)
Button {
InstancesManifest.shared.changePublicAccount(accounts, settings: model)
} label: {
if let account = accounts.current, account.isPublic {
Text("Switch to other public location")
} else {
Text("Switch to public locations")
Button {
InstancesManifest.shared.changePublicAccount(accounts, settings: model)
} label: {
if let account = accounts.current, account.isPublic {
Text("Switch to other public location")
} else {
Text("Switch to public locations")
}
}
.disabled(countryOfPublicInstances.isNil)
}
.disabled(countryOfPublicInstances.isNil)
}
Section(header: SettingsHeader(text: "Custom Locations".localized())) {
@@ -92,7 +94,8 @@ struct LocationsSettings: View {
}
func loadCountries() {
InstancesManifest.shared.instancesList.load()
InstancesManifest.shared.configure()
InstancesManifest.shared.instancesList?.load()
.onSuccess { response in
if let instances: [ManifestedInstance] = response.typedContent() {
self.countries = instances.map(\.country).unique().sorted()

View File

@@ -31,6 +31,7 @@ struct PlayerSettings: View {
@Default(.enableReturnYouTubeDislike) private var enableReturnYouTubeDislike
@Default(.systemControlsCommands) private var systemControlsCommands
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<PlayerModel> private var player
#if os(iOS)
@@ -99,7 +100,10 @@ struct PlayerSettings: View {
keywordsToggle
showHistoryToggle
returnYouTubeDislikeToggle
if !accounts.isDemo {
returnYouTubeDislikeToggle
}
}
#if os(iOS)