update login logic

This commit is contained in:
MathMan05
2024-09-24 12:02:20 -05:00
parent b5e5c436f8
commit 9ae7a9c71f
2 changed files with 76 additions and 59 deletions

View File

@@ -3,6 +3,12 @@
"name": "Spacebar",
"description": "The official Spacebar instance.",
"image": "https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/png/Spacebar__Icon-Discord.png",
"urls":{
"wellknown": "https://spacebar.chat/",
"api": "https://old.server.spacebar.chat/api",
"cdn": "https://cdn.old.server.spacebar.chat",
"gateway": "wss://gateway.old.server.spacebar.chat"
},
"url": "https://spacebar.chat"
},
{

View File

@@ -214,7 +214,7 @@ const stringURLsMap = new Map<
}
>();
async function getapiurls(str: string): Promise<
| {
{
api: string;
cdn: string;
gateway: string;
@@ -225,6 +225,15 @@ async function getapiurls(str: string): Promise<
>{
if(!URL.canParse(str)){
const val = stringURLMap.get(str);
if(stringURLMap.size===0){
await new Promise<void>(res=>{
setInterval(()=>{
if(stringURLMap.size!==0){
res();
}
},100)
})
}
if(val){
str = val;
}else{
@@ -265,6 +274,9 @@ async function getapiurls(str: string): Promise<
);
api = info.api;
}catch{
api=str;
}
if(!URL.canParse(api)){
return false;
}
const url = new URL(api);
@@ -323,7 +335,7 @@ async function checkInstance(instance?: string){
gateway: string;
login: string;
value: string;
};
}
if(instanceinfo){
instanceinfo.value = instanceValue;
localStorage.setItem("instanceinfo", JSON.stringify(instanceinfo));
@@ -569,8 +581,7 @@ export function getInstances(){
fetch("/instances.json")
.then(_=>_.json())
.then(
(
json: {
(json: {
name: string;
description?: string;
descriptionLong?: string;
@@ -585,7 +596,7 @@ fetch("/instances.json")
cdn: string;
gateway: string;
login?: string;
};
}
}[]
)=>{
instances = json;