compiled TS
This commit is contained in:
parent
75c58c3ef0
commit
9269a08972
4 changed files with 89 additions and 4 deletions
|
@ -655,7 +655,7 @@ class Channel {
|
|||
this.localuser.channelfocus = this;
|
||||
const prom = this.infinite.delete();
|
||||
history.pushState(null, "", "/channels/" + this.guild_id + "/" + this.snowflake);
|
||||
document.getElementById("channelname").textContent = "#" + this.name;
|
||||
this.localuser.pageTitle("#" + this.name);
|
||||
const channelTopic = document.getElementById("channelTopic");
|
||||
if (this.topic) {
|
||||
channelTopic.innerHTML = new MarkDown(this.topic, this).makeHTML().innerHTML;
|
||||
|
|
|
@ -132,7 +132,7 @@ class Group extends Channel {
|
|||
}
|
||||
this.buildmessages();
|
||||
history.pushState(null, "", "/channels/" + this.guild_id + "/" + this.id);
|
||||
document.getElementById("channelname").textContent = "@" + this.name;
|
||||
this.localuser.pageTitle("@" + this.name);
|
||||
document.getElementById("channelTopic").setAttribute("hidden", "");
|
||||
document.getElementById("typebox").contentEditable = "" + true;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ class Localuser {
|
|||
typing = new Map();
|
||||
connectionSucceed = 0;
|
||||
errorBackoff = 0;
|
||||
instancePing = {
|
||||
name: "Unknown",
|
||||
};
|
||||
mfa_enabled;
|
||||
constructor(userinfo) {
|
||||
if (userinfo === -1) {
|
||||
|
@ -94,6 +97,7 @@ class Localuser {
|
|||
user.nickname = thing.nickname;
|
||||
user.relationshipType = thing.type;
|
||||
}
|
||||
this.pingEndpoint();
|
||||
}
|
||||
outoffocus() {
|
||||
const servers = document.getElementById("servers");
|
||||
|
@ -369,14 +373,26 @@ class Localuser {
|
|||
else {
|
||||
thing = { id: temp.d.user_id };
|
||||
}
|
||||
message.makeReaction(temp.d.emoji, thing);
|
||||
message.reactionAdd(temp.d.emoji, thing);
|
||||
}
|
||||
break;
|
||||
case "MESSAGE_REACTION_REMOVE":
|
||||
if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) {
|
||||
const message = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject();
|
||||
console.log("test");
|
||||
message.removeReaction(temp.d.emoji, temp.d.user_id);
|
||||
message.reactionRemove(temp.d.emoji, temp.d.user_id);
|
||||
}
|
||||
break;
|
||||
case "MESSAGE_REACTION_REMOVE_ALL":
|
||||
if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) {
|
||||
const messageReactionRemoveAll = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject();
|
||||
messageReactionRemoveAll.reactionRemoveAll();
|
||||
}
|
||||
break;
|
||||
case "MESSAGE_REACTION_REMOVE_EMOJI":
|
||||
if (SnowFlake.hasSnowFlakeFromID(temp.d.message_id, Message)) {
|
||||
const messageReactionRemoveEmoji = SnowFlake.getSnowFlakeFromID(temp.d.message_id, Message).getObject();
|
||||
messageReactionRemoveEmoji.reactionRemoveEmoji(temp.d.emoji);
|
||||
}
|
||||
break;
|
||||
case "GUILD_MEMBERS_CHUNK":
|
||||
|
@ -1341,6 +1357,38 @@ 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").textContent = channelName;
|
||||
document.getElementsByTagName("title")[0].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;
|
||||
|
|
|
@ -465,6 +465,43 @@ class MarkDown {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (txt[i] == "[" && !keep) {
|
||||
let partsFound = 0;
|
||||
let j = i + 1;
|
||||
const build = ["["];
|
||||
for (; txt[j] !== void 0; j++) {
|
||||
build.push(txt[j]);
|
||||
if (partsFound === 0 && txt[j] === "]") {
|
||||
if (txt[j + 1] === "(" &&
|
||||
txt[j + 2] === "h" && txt[j + 3] === "t" && txt[j + 4] === "t" && txt[j + 5] === "p" && (txt[j + 6] === "s" || txt[j + 6] === ":")) {
|
||||
partsFound++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
;
|
||||
}
|
||||
else if (partsFound === 1 && txt[j] === ")") {
|
||||
partsFound++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (partsFound === 2) {
|
||||
appendcurrent();
|
||||
i = j;
|
||||
const parts = build.join("").match(/^\[(.+)\]\((https?:.+?)( ('|").+('|"))?\)$/);
|
||||
if (parts) {
|
||||
const linkElem = document.createElement("a");
|
||||
linkElem.href = parts[2];
|
||||
linkElem.textContent = parts[1];
|
||||
linkElem.target = "_blank";
|
||||
linkElem.rel = "noopener noreferrer";
|
||||
linkElem.title = (parts[3] ? parts[3].substring(2, parts[3].length - 1) + "\n\n" : "") + parts[2];
|
||||
span.appendChild(linkElem);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
current.textContent += txt[i];
|
||||
}
|
||||
appendcurrent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue