diff --git a/src/webpage/index.ts b/src/webpage/index.ts index 6f9e678..b954ca3 100644 --- a/src/webpage/index.ts +++ b/src/webpage/index.ts @@ -429,7 +429,7 @@ stickerTB.onclick = (e) => { }; const updateIcon = document.getElementById("updateIcon"); if (updateIcon) { - new Hover(() => updateIcon.textContent).addEvent(updateIcon); + new Hover(() => updateIcon.textContent || "").addEvent(updateIcon); updateIcon.onclick = () => { window.location.reload(); }; diff --git a/src/webpage/jsontypes.ts b/src/webpage/jsontypes.ts index 8e9cbe4..e52e1c5 100644 --- a/src/webpage/jsontypes.ts +++ b/src/webpage/jsontypes.ts @@ -44,6 +44,7 @@ interface readyjson { timezone_offset: number; view_nsfw_guilds: boolean; }; + auth_token?: string; guilds: guildjson[]; relationships: { id: string; diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 5660921..82c7618 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -56,7 +56,9 @@ class Localuser { ][], ); lastSequence: number | null = null; - token!: string; + get token() { + return this.headers.Authorization; + } userinfo!: Specialuser; serverurls!: Specialuser["serverurls"]; initialized!: boolean; @@ -212,7 +214,6 @@ class Localuser { this.rights = new Rights(""); return; } - this.token = userinfo.token; this.userinfo = userinfo; this.perminfo.guilds ??= {}; this.perminfo.user ??= {}; @@ -348,6 +349,12 @@ class Localuser { this.userinfo.id = this.user.id; this.userinfo.pfpsrc = this.user.getpfpsrc(); + if (ready.d.auth_token) { + this.userinfo.token = ready.d.auth_token; + this.headers.Authorization = ready.d.auth_token; + this.userinfo.updateLocal(); + } + this.status = this.ready.d.user_settings.status; this.channelfocus = undefined; this.lookingguild = undefined; diff --git a/src/webpage/user.ts b/src/webpage/user.ts index 901e78e..e0264a9 100644 --- a/src/webpage/user.ts +++ b/src/webpage/user.ts @@ -510,14 +510,27 @@ class User extends SnowFlake { this.contextmenu.addButton( () => I18n.user.instanceBan(), function (this: User) { + const params = { + reason: "", + persistInstanceBan: true, + }; const menu = new Dialog(""); const options = menu.float.options; options.addTitle(I18n.user.confirmInstBan(this.name)); + options.addTextInput(I18n.member["reason:"](), () => {}, {}).onchange = (txt) => { + params.reason = txt; + }; + options.addCheckboxInput(I18n.member.persist(), () => {}, { + initState: false, + }).onchange = (checked) => { + params.persistInstanceBan = !checked; + }; const opt = options.addOptions("", {ltr: true}); opt.addButtonInput("", I18n.yes(), () => { fetch(this.info.api + "/users/" + this.id + "/delete", { headers: this.localuser.headers, method: "POST", + body: JSON.stringify(params), }); menu.hide(); }); diff --git a/translations/en.json b/translations/en.json index ef69006..7d5d728 100644 --- a/translations/en.json +++ b/translations/en.json @@ -734,6 +734,7 @@ "kick": "Kick $1 from $2", "timeout":"Timeout $1", "reason:": "Reason:", + "persist":"Only delete user:", "timeoutTime":"Timeout Time:", "ban": "Ban $1 from $2", "nick:": "Nickname:"