From 5384ac64eccce01422ba221bf1cde673b9561313 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 13 Aug 2024 10:54:58 -0500 Subject: [PATCH] merged updatepronouns & updatebio --- .dist/localuser.js | 28 +++++++--------------------- webpage/localuser.ts | 29 ++++++++--------------------- 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/.dist/localuser.js b/.dist/localuser.js index f709a0e..a0f1a25 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -615,22 +615,11 @@ class Localuser { }); }; } - updatepronouns(pronouns) { + updateProfile(json) { fetch(this.info.api + "/users/@me/profile", { method: "PATCH", headers: this.headers, - body: JSON.stringify({ - pronouns: pronouns, - }) - }); - } - updatebio(bio) { - fetch(this.info.api + "/users/@me/profile", { - method: "PATCH", - headers: this.headers, - body: JSON.stringify({ - bio: bio, - }) + body: JSON.stringify(json) }); } rendertyping() { @@ -670,9 +659,9 @@ class Localuser { { const userOptions = settings.addButton("User Settings", { ltr: true }); const hypotheticalProfile = document.createElement("div"); - let file = null; - let newpronouns = null; - let newbio = null; + let file = undefined; + let newpronouns = undefined; + let newbio = undefined; let hypouser = this.user.clone(); function regen() { hypotheticalProfile.textContent = ""; @@ -698,8 +687,8 @@ class Localuser { } }); const pronounbox = settingsLeft.addTextInput("Pronouns", _ => { - if (newpronouns) { - this.updatepronouns(newpronouns); + if (newpronouns || newbio) { + this.updateProfile({ pronouns: newpronouns, bio: newbio }); } }, { initText: this.user.pronouns }); pronounbox.watchForChange(_ => { @@ -708,9 +697,6 @@ class Localuser { regen(); }); const bioBox = settingsLeft.addMDInput("Bio:", _ => { - if (newbio) { - this.updatebio(newbio); - } }, { initText: this.user.bio.rawString }); bioBox.watchForChange(_ => { newbio = _; diff --git a/webpage/localuser.ts b/webpage/localuser.ts index fe560ad..15ee8f2 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -634,22 +634,11 @@ class Localuser{ }; } - updatepronouns(pronouns:string):void{ + updateProfile(json:{bio?:string,pronouns?:string}){ fetch(this.info.api+"/users/@me/profile",{ method:"PATCH", headers:this.headers, - body:JSON.stringify({ - pronouns:pronouns, - }) - }); - } - updatebio(bio:string):void{ - fetch(this.info.api+"/users/@me/profile",{ - method:"PATCH", - headers:this.headers, - body:JSON.stringify({ - bio:bio, - }) + body:JSON.stringify(json) }); } rendertyping():void{ @@ -687,9 +676,9 @@ class Localuser{ { const userOptions=settings.addButton("User Settings",{ltr:true}); const hypotheticalProfile=document.createElement("div"); - let file=null; - let newpronouns=null; - let newbio=null; + let file=undefined; + let newpronouns:string=undefined; + let newbio:string=undefined; let hypouser=this.user.clone(); function regen(){ hypotheticalProfile.textContent=""; @@ -717,8 +706,8 @@ class Localuser{ } }); const pronounbox=settingsLeft.addTextInput("Pronouns",_=>{ - if(newpronouns){ - this.updatepronouns(newpronouns); + if(newpronouns||newbio){ + this.updateProfile({pronouns:newpronouns,bio:newbio}); } },{initText:this.user.pronouns}); pronounbox.watchForChange(_=>{ @@ -727,9 +716,7 @@ class Localuser{ regen(); }); const bioBox=settingsLeft.addMDInput("Bio:",_=>{ - if(newbio){ - this.updatebio(newbio); - } + },{initText:this.user.bio.rawString}); bioBox.watchForChange(_=>{ newbio=_;