merged updatepronouns & updatebio
This commit is contained in:
parent
e0ae529494
commit
5384ac64ec
2 changed files with 15 additions and 42 deletions
|
@ -615,22 +615,11 @@ class Localuser {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
updatepronouns(pronouns) {
|
updateProfile(json) {
|
||||||
fetch(this.info.api + "/users/@me/profile", {
|
fetch(this.info.api + "/users/@me/profile", {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(json)
|
||||||
pronouns: pronouns,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
updatebio(bio) {
|
|
||||||
fetch(this.info.api + "/users/@me/profile", {
|
|
||||||
method: "PATCH",
|
|
||||||
headers: this.headers,
|
|
||||||
body: JSON.stringify({
|
|
||||||
bio: bio,
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
rendertyping() {
|
rendertyping() {
|
||||||
|
@ -670,9 +659,9 @@ class Localuser {
|
||||||
{
|
{
|
||||||
const userOptions = settings.addButton("User Settings", { ltr: true });
|
const userOptions = settings.addButton("User Settings", { ltr: true });
|
||||||
const hypotheticalProfile = document.createElement("div");
|
const hypotheticalProfile = document.createElement("div");
|
||||||
let file = null;
|
let file = undefined;
|
||||||
let newpronouns = null;
|
let newpronouns = undefined;
|
||||||
let newbio = null;
|
let newbio = undefined;
|
||||||
let hypouser = this.user.clone();
|
let hypouser = this.user.clone();
|
||||||
function regen() {
|
function regen() {
|
||||||
hypotheticalProfile.textContent = "";
|
hypotheticalProfile.textContent = "";
|
||||||
|
@ -698,8 +687,8 @@ class Localuser {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const pronounbox = settingsLeft.addTextInput("Pronouns", _ => {
|
const pronounbox = settingsLeft.addTextInput("Pronouns", _ => {
|
||||||
if (newpronouns) {
|
if (newpronouns || newbio) {
|
||||||
this.updatepronouns(newpronouns);
|
this.updateProfile({ pronouns: newpronouns, bio: newbio });
|
||||||
}
|
}
|
||||||
}, { initText: this.user.pronouns });
|
}, { initText: this.user.pronouns });
|
||||||
pronounbox.watchForChange(_ => {
|
pronounbox.watchForChange(_ => {
|
||||||
|
@ -708,9 +697,6 @@ class Localuser {
|
||||||
regen();
|
regen();
|
||||||
});
|
});
|
||||||
const bioBox = settingsLeft.addMDInput("Bio:", _ => {
|
const bioBox = settingsLeft.addMDInput("Bio:", _ => {
|
||||||
if (newbio) {
|
|
||||||
this.updatebio(newbio);
|
|
||||||
}
|
|
||||||
}, { initText: this.user.bio.rawString });
|
}, { initText: this.user.bio.rawString });
|
||||||
bioBox.watchForChange(_ => {
|
bioBox.watchForChange(_ => {
|
||||||
newbio = _;
|
newbio = _;
|
||||||
|
|
|
@ -634,22 +634,11 @@ class Localuser{
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
updatepronouns(pronouns:string):void{
|
updateProfile(json:{bio?:string,pronouns?:string}){
|
||||||
fetch(this.info.api+"/users/@me/profile",{
|
fetch(this.info.api+"/users/@me/profile",{
|
||||||
method:"PATCH",
|
method:"PATCH",
|
||||||
headers:this.headers,
|
headers:this.headers,
|
||||||
body:JSON.stringify({
|
body:JSON.stringify(json)
|
||||||
pronouns:pronouns,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
updatebio(bio:string):void{
|
|
||||||
fetch(this.info.api+"/users/@me/profile",{
|
|
||||||
method:"PATCH",
|
|
||||||
headers:this.headers,
|
|
||||||
body:JSON.stringify({
|
|
||||||
bio:bio,
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
rendertyping():void{
|
rendertyping():void{
|
||||||
|
@ -687,9 +676,9 @@ class Localuser{
|
||||||
{
|
{
|
||||||
const userOptions=settings.addButton("User Settings",{ltr:true});
|
const userOptions=settings.addButton("User Settings",{ltr:true});
|
||||||
const hypotheticalProfile=document.createElement("div");
|
const hypotheticalProfile=document.createElement("div");
|
||||||
let file=null;
|
let file=undefined;
|
||||||
let newpronouns=null;
|
let newpronouns:string=undefined;
|
||||||
let newbio=null;
|
let newbio:string=undefined;
|
||||||
let hypouser=this.user.clone();
|
let hypouser=this.user.clone();
|
||||||
function regen(){
|
function regen(){
|
||||||
hypotheticalProfile.textContent="";
|
hypotheticalProfile.textContent="";
|
||||||
|
@ -717,8 +706,8 @@ class Localuser{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const pronounbox=settingsLeft.addTextInput("Pronouns",_=>{
|
const pronounbox=settingsLeft.addTextInput("Pronouns",_=>{
|
||||||
if(newpronouns){
|
if(newpronouns||newbio){
|
||||||
this.updatepronouns(newpronouns);
|
this.updateProfile({pronouns:newpronouns,bio:newbio});
|
||||||
}
|
}
|
||||||
},{initText:this.user.pronouns});
|
},{initText:this.user.pronouns});
|
||||||
pronounbox.watchForChange(_=>{
|
pronounbox.watchForChange(_=>{
|
||||||
|
@ -727,9 +716,7 @@ class Localuser{
|
||||||
regen();
|
regen();
|
||||||
});
|
});
|
||||||
const bioBox=settingsLeft.addMDInput("Bio:",_=>{
|
const bioBox=settingsLeft.addMDInput("Bio:",_=>{
|
||||||
if(newbio){
|
|
||||||
this.updatebio(newbio);
|
|
||||||
}
|
|
||||||
},{initText:this.user.bio.rawString});
|
},{initText:this.user.bio.rawString});
|
||||||
bioBox.watchForChange(_=>{
|
bioBox.watchForChange(_=>{
|
||||||
newbio=_;
|
newbio=_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue