mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 17:16:26 +01:00
Try get the v2 instance config then fallback to v1
There are new things in v2 that will be needed later
This commit is contained in:
parent
77054f10de
commit
7c6157d47c
1 changed files with 16 additions and 4 deletions
14
src/app.jsx
14
src/app.jsx
|
@ -170,12 +170,24 @@ function App() {
|
||||||
|
|
||||||
// Collect instance info
|
// Collect instance info
|
||||||
(async () => {
|
(async () => {
|
||||||
const info = await masto.v1.instances.fetch();
|
// Request v2, fallback to v1 if fail
|
||||||
|
let info;
|
||||||
|
try {
|
||||||
|
info = await masto.v2.instance.fetch();
|
||||||
|
} catch (e) {}
|
||||||
|
if (!info) {
|
||||||
|
try {
|
||||||
|
info = await masto.v1.instances.fetch();
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
if (!info) return;
|
||||||
console.log(info);
|
console.log(info);
|
||||||
const { uri, domain } = info;
|
const { uri, domain } = info;
|
||||||
|
if (uri || domain) {
|
||||||
const instances = store.local.getJSON('instances') || {};
|
const instances = store.local.getJSON('instances') || {};
|
||||||
instances[(domain || uri).toLowerCase()] = info;
|
instances[(domain || uri).toLowerCase()] = info;
|
||||||
store.local.setJSON('instances', instances);
|
store.local.setJSON('instances', instances);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
states.init = true;
|
states.init = true;
|
||||||
|
|
Loading…
Reference in a new issue