mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-09 01:26:24 +01:00
Don't store instances list inside JS bundle
This commit is contained in:
parent
2925afeefc
commit
8099fedf82
1 changed files with 15 additions and 1 deletions
|
@ -3,7 +3,7 @@ import './login.css';
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||||
|
|
||||||
import Loader from '../components/loader';
|
import Loader from '../components/loader';
|
||||||
import instancesList from '../data/instances.json';
|
import instancesListURL from '../data/instances.json?url';
|
||||||
import { getAuthorizationURL, registerApplication } from '../utils/auth';
|
import { getAuthorizationURL, registerApplication } from '../utils/auth';
|
||||||
import store from '../utils/store';
|
import store from '../utils/store';
|
||||||
import useTitle from '../utils/useTitle';
|
import useTitle from '../utils/useTitle';
|
||||||
|
@ -14,6 +14,20 @@ function Login() {
|
||||||
const cachedInstanceURL = store.local.get('instanceURL');
|
const cachedInstanceURL = store.local.get('instanceURL');
|
||||||
const [uiState, setUIState] = useState('default');
|
const [uiState, setUIState] = useState('default');
|
||||||
|
|
||||||
|
const [instancesList, setInstancesList] = useState([]);
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(instancesListURL);
|
||||||
|
const data = await res.json();
|
||||||
|
setInstancesList(data);
|
||||||
|
} catch (e) {
|
||||||
|
// Silently fail
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (cachedInstanceURL) {
|
if (cachedInstanceURL) {
|
||||||
instanceURLRef.current.value = cachedInstanceURL.toLowerCase();
|
instanceURLRef.current.value = cachedInstanceURL.toLowerCase();
|
||||||
|
|
Loading…
Reference in a new issue