mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 01:05:34 +03:00
Another attempt
This commit is contained in:
parent
942dac4be0
commit
572358f0f4
1 changed files with 4 additions and 3 deletions
|
@ -60,11 +60,11 @@ export function initClient({ instance, accessToken }) {
|
||||||
// Get the instance information
|
// Get the instance information
|
||||||
// The config is needed for composing
|
// The config is needed for composing
|
||||||
export async function initInstance(client, instance) {
|
export async function initInstance(client, instance) {
|
||||||
__BENCHMARK.start('init-instance');
|
|
||||||
console.log('INIT INSTANCE', client, instance);
|
console.log('INIT INSTANCE', client, instance);
|
||||||
const { masto, accessToken } = client;
|
const { masto, accessToken } = client;
|
||||||
// Request v2, fallback to v1 if fail
|
// Request v2, fallback to v1 if fail
|
||||||
let info;
|
let info;
|
||||||
|
__BENCHMARK.start('fetch-instance');
|
||||||
try {
|
try {
|
||||||
info = await masto.v2.instance.fetch();
|
info = await masto.v2.instance.fetch();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
@ -73,6 +73,7 @@ export async function initInstance(client, instance) {
|
||||||
info = await masto.v1.instance.fetch();
|
info = await masto.v1.instance.fetch();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
__BENCHMARK.end('fetch-instance');
|
||||||
if (!info) return;
|
if (!info) return;
|
||||||
console.log(info);
|
console.log(info);
|
||||||
const {
|
const {
|
||||||
|
@ -133,16 +134,16 @@ export async function initAccount(client, instance, accessToken, vapidKey) {
|
||||||
|
|
||||||
// Get preferences
|
// Get preferences
|
||||||
export async function initPreferences(client) {
|
export async function initPreferences(client) {
|
||||||
__BENCHMARK.start('init-preferences');
|
|
||||||
try {
|
try {
|
||||||
const { masto } = client;
|
const { masto } = client;
|
||||||
|
__BENCHMARK.start('fetch-preferences');
|
||||||
const preferences = await masto.v1.preferences.fetch();
|
const preferences = await masto.v1.preferences.fetch();
|
||||||
|
__BENCHMARK.end('fetch-preferences');
|
||||||
store.account.set('preferences', preferences);
|
store.account.set('preferences', preferences);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// silently fail
|
// silently fail
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
__BENCHMARK.end('init-preferences');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the masto instance
|
// Get the masto instance
|
||||||
|
|
Loading…
Reference in a new issue