page title & instance stats
This commit is contained in:
parent
1de4767c6d
commit
79463edb07
3 changed files with 40 additions and 2 deletions
|
@ -658,7 +658,7 @@ class Channel{
|
|||
const prom=this.infinite.delete();
|
||||
history.pushState(null, "","/channels/"+this.guild_id+"/"+this.snowflake);
|
||||
|
||||
(document.getElementById("channelname") as HTMLSpanElement).textContent="#"+this.name;
|
||||
this.localuser.pageTitle("#"+this.name);
|
||||
const channelTopic=document.getElementById("channelTopic") as HTMLSpanElement;
|
||||
if (this.topic) {
|
||||
channelTopic.innerHTML=new MarkDown(this.topic, this).makeHTML().innerHTML;
|
||||
|
|
|
@ -138,7 +138,7 @@ class Group extends Channel{
|
|||
}
|
||||
this.buildmessages();
|
||||
history.pushState(null, "","/channels/"+this.guild_id+"/"+this.id);
|
||||
(document.getElementById("channelname") as HTMLElement).textContent="@"+this.name;
|
||||
this.localuser.pageTitle("@"+this.name);
|
||||
(document.getElementById("channelTopic") as HTMLElement).setAttribute("hidden","");
|
||||
(document.getElementById("typebox") as HTMLDivElement).contentEditable=""+true;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@ class Localuser{
|
|||
typing:Map<Member,number>=new Map();
|
||||
connectionSucceed=0;
|
||||
errorBackoff=0;
|
||||
instancePing={
|
||||
name:"Unknown",
|
||||
};
|
||||
mfa_enabled:boolean;
|
||||
constructor(userinfo:Specialuser|-1){
|
||||
if(userinfo===-1){
|
||||
|
@ -100,6 +103,8 @@ class Localuser{
|
|||
user.nickname=thing.nickname;
|
||||
user.relationshipType=thing.type;
|
||||
}
|
||||
|
||||
this.pingEndpoint()
|
||||
}
|
||||
outoffocus():void{
|
||||
const servers=document.getElementById("servers") as HTMLDivElement;
|
||||
|
@ -1353,6 +1358,39 @@ class Localuser{
|
|||
})
|
||||
}
|
||||
}
|
||||
async pingEndpoint() {
|
||||
const userInfo = getBulkInfo();
|
||||
if (!userInfo.instances) userInfo.instances = {};
|
||||
const wellknown = this.info.wellknown;
|
||||
if (!userInfo.instances[wellknown]) {
|
||||
const pingRes = await fetch(this.info.api + "/ping");
|
||||
const pingJSON = await pingRes.json();
|
||||
userInfo.instances[wellknown] = pingJSON;
|
||||
localStorage.setItem("userinfos", JSON.stringify(userInfo));
|
||||
}
|
||||
this.instancePing = userInfo.instances[wellknown].instance;
|
||||
|
||||
this.pageTitle("Loading...");
|
||||
}
|
||||
pageTitle(channelName = "", guildName = "") {
|
||||
(document.getElementById("channelname") as HTMLSpanElement).textContent = channelName;
|
||||
(document.getElementsByTagName("title")[0] as HTMLTitleElement).textContent = channelName + (guildName ? " | " + guildName : "") + " | " + this.instancePing.name + " | Jank Client (Tomato fork)";
|
||||
}
|
||||
async instanceStats() {
|
||||
const res = await fetch(this.info.api + "/policies/stats", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json = await res.json();
|
||||
|
||||
const dialog = new Dialog(["vdiv",
|
||||
["title", "Instance stats: " + this.instancePing.name],
|
||||
["text", "Registered users: " + json.counts.user],
|
||||
["text", "Servers: " + json.counts.guild],
|
||||
["text", "Messages: " + json.counts.message],
|
||||
["text", "Members: " + json.counts.members]
|
||||
]);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
export {Localuser};
|
||||
let fixsvgtheme:Function;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue