From 6b4bd1a034bb092277fea84aba3a61e61e589882 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 23 Feb 2022 12:38:21 +0000 Subject: [PATCH] Fetch instances using Instances API. (#854) --- src/components/PreferencesPage.vue | 48 +++++++++++------------------- src/locales/en.json | 3 ++ 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/components/PreferencesPage.vue b/src/components/PreferencesPage.vue index b7f32027..2e5e221c 100644 --- a/src/components/PreferencesPage.vue +++ b/src/components/PreferencesPage.vue @@ -158,6 +158,9 @@ + + + @@ -165,9 +168,12 @@ - + + + + - + @@ -178,7 +184,7 @@
@@ -257,34 +263,16 @@ export default { async mounted() { if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} }); - fetch("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md") - .then(resp => resp.text()) - .then(body => { - var skipped = 0; - const lines = body.split("\n"); - lines.map(line => { - const split = line.split("|"); - if (split.length == 5) { - if (skipped < 2) { - skipped++; - return; - } - this.instances.push({ - name: split[0].trim(), - apiurl: split[1].trim(), - locations: split[2].trim(), - cdn: split[3].trim(), - }); - } + this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => { + this.instances = resp; + if (this.instances.filter(instance => instance.api_url == this.apiUrl()).length == 0) + this.instances.push({ + name: "Custom Instance", + api_url: this.apiUrl(), + locations: "Unknown", + cdn: false, }); - if (this.instances.filter(instance => instance.apiurl == this.apiUrl()).length == 0) - this.instances.push({ - name: "Custom Instance", - apiurl: this.apiUrl(), - locations: "Unknown", - cdn: "Unknown", - }); - }); + }); if (this.testLocalStorage) { this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks"); diff --git a/src/locales/en.json b/src/locales/en.json index f56bac29..01eab33e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -79,6 +79,9 @@ "instance_name": "Instance Name", "instance_locations": "Instance Locations", "has_cdn": "Has CDN?", + "registered_users": "Registered Users", + "version": "Version", + "up_to_date": "Up to Date?", "ssl_score": "SSL Score" }, "login": {