Various improvements and checks

This commit is contained in:
MathMan05 2024-08-20 14:17:54 -05:00
parent a2abc91a2a
commit 1608d00beb
30 changed files with 541 additions and 360 deletions

View file

@ -38,16 +38,17 @@ function showAccountSwitcher() {
userinfo.addEventListener("click", _ => {
thisuser.unload();
thisuser.swapped = true;
document.getElementById("loading").classList.remove("doneloading");
document.getElementById("loading").classList.add("loading");
const loading = document.getElementById("loading");
loading.classList.remove("doneloading");
loading.classList.add("loading");
thisuser = new Localuser(specialuser);
users["currentuser"] = specialuser.uid;
localStorage.setItem("userinfos", JSON.stringify(users));
thisuser.initwebsocket().then(_ => {
thisuser.loaduser();
thisuser.init();
document.getElementById("loading").classList.add("doneloading");
document.getElementById("loading").classList.remove("loading");
loading.classList.add("doneloading");
loading.classList.remove("loading");
console.log("done loading");
});
userinfo.remove();
@ -90,8 +91,9 @@ try {
thisuser.initwebsocket().then(_ => {
thisuser.loaduser();
thisuser.init();
document.getElementById("loading").classList.add("doneloading");
document.getElementById("loading").classList.remove("loading");
const loading = document.getElementById("loading");
loading.classList.add("doneloading");
loading.classList.remove("loading");
console.log("done loading");
});
}
@ -103,10 +105,14 @@ catch (e) {
{
const menu = new Contextmenu("create rightclick");
menu.addbutton("Create channel", function () {
thisuser.lookingguild.createchannels();
if (thisuser.lookingguild) {
thisuser.lookingguild.createchannels();
}
}, null, _ => { return thisuser.isAdmin(); });
menu.addbutton("Create category", function () {
thisuser.lookingguild.createcategory();
if (thisuser.lookingguild) {
thisuser.lookingguild.createcategory();
}
}, null, _ => { return thisuser.isAdmin(); });
menu.bind(document.getElementById("channels"));
}
@ -114,6 +120,8 @@ const pasteimage = document.getElementById("pasteimage");
let replyingto = null;
async function enter(event) {
const channel = thisuser.channelfocus;
if (!channel || !thisuser.channelfocus)
return;
channel.typingstart();
if (event.key === "Enter" && !event.shiftKey) {
event.preventDefault();
@ -124,13 +132,14 @@ async function enter(event) {
else {
replyingto = thisuser.channelfocus.replyingto;
let replying = replyingto;
if (replyingto) {
if (replyingto?.div) {
replyingto.div.classList.remove("replying");
}
thisuser.channelfocus.replyingto = null;
channel.sendMessage(markdown.rawString, {
attachments: images,
replyingto: replying,
embeds: [],
replyingto: replying
});
thisuser.channelfocus.makereplybox();
}
@ -165,6 +174,8 @@ const imageshtml = [];
import { File } from "./file.js";
import { MarkDown } from "./markdown.js";
document.addEventListener('paste', async (e) => {
if (!e.clipboardData)
return;
Array.from(e.clipboardData.files).forEach(async (f) => {
const file = File.initFromBlob(f);
e.preventDefault();
@ -180,13 +191,13 @@ function userSettings() {
}
document.getElementById("settings").onclick = userSettings;
if (mobile) {
document.getElementById("channelw").onclick = function () {
document.getElementById("channelw").onclick = () => {
document.getElementById("channels").parentNode.classList.add("collapse");
document.getElementById("servertd").classList.add("collapse");
document.getElementById("servers").classList.add("collapse");
};
document.getElementById("mobileback").textContent = "#";
document.getElementById("mobileback").onclick = function () {
document.getElementById("mobileback").onclick = () => {
document.getElementById("channels").parentNode.classList.remove("collapse");
document.getElementById("servertd").classList.remove("collapse");
document.getElementById("servers").classList.remove("collapse");