mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-05-01 21:00:51 +03:00
Try handle case when configured instance domain is different than the actual instance domain
Honestly how do I even test if this will work
This commit is contained in:
parent
ef12916bab
commit
d264af14f1
2 changed files with 9 additions and 6 deletions
src/utils
|
@ -48,7 +48,7 @@ export function initClient({ instance, accessToken }) {
|
|||
|
||||
// Get the instance information
|
||||
// The config is needed for composing
|
||||
export async function initInstance(client) {
|
||||
export async function initInstance(client, instance) {
|
||||
const masto = client;
|
||||
// Request v2, fallback to v1 if fail
|
||||
let info;
|
||||
|
@ -70,16 +70,19 @@ export async function initInstance(client) {
|
|||
domain,
|
||||
configuration: { urls: { streaming } = {} } = {},
|
||||
} = info;
|
||||
const instances = store.local.getJSON('instances') || {};
|
||||
if (uri || domain) {
|
||||
const instances = store.local.getJSON('instances') || {};
|
||||
instances[
|
||||
(domain || uri)
|
||||
.replace(/^https?:\/\//, '')
|
||||
.replace(/\/+$/, '')
|
||||
.toLowerCase()
|
||||
] = info;
|
||||
store.local.setJSON('instances', instances);
|
||||
}
|
||||
if (instance) {
|
||||
instances[instance.toLowerCase()] = info;
|
||||
}
|
||||
store.local.setJSON('instances', instances);
|
||||
// This is a weird place to put this but here's updating the masto instance with the streaming API URL set in the configuration
|
||||
// Reason: Streaming WebSocket URL may change, unlike the standard API REST URLs
|
||||
if (streamingApi || streaming) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue