make user profile updates happen more often
This commit is contained in:
parent
683cc1488b
commit
99c348b086
1 changed files with 16 additions and 14 deletions
|
@ -44,16 +44,7 @@ class User extends SnowFlake {
|
||||||
console.error("missing localuser");
|
console.error("missing localuser");
|
||||||
}
|
}
|
||||||
if (dontclone) {
|
if (dontclone) {
|
||||||
for (const key of Object.keys(userjson)) {
|
this.userupdate(userjson);
|
||||||
if (key === "bio") {
|
|
||||||
this.bio = new MarkDown(userjson[key], this.localuser);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (key === "id") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(this as any)[key] = (userjson as any)[key];
|
|
||||||
}
|
|
||||||
this.hypotheticalpfp = false;
|
this.hypotheticalpfp = false;
|
||||||
} else {
|
} else {
|
||||||
return User.checkuser(userjson, owner);
|
return User.checkuser(userjson, owner);
|
||||||
|
@ -358,8 +349,12 @@ class User extends SnowFlake {
|
||||||
}
|
}
|
||||||
|
|
||||||
static checkuser(user: User | userjson, owner: Localuser): User {
|
static checkuser(user: User | userjson, owner: Localuser): User {
|
||||||
if (owner.userMap.has(user.id)) {
|
const tempUser = owner.userMap.get(user.id);
|
||||||
return owner.userMap.get(user.id) as User;
|
if (tempUser) {
|
||||||
|
if (!(user instanceof User)) {
|
||||||
|
tempUser.userupdate(user);
|
||||||
|
}
|
||||||
|
return tempUser;
|
||||||
} else {
|
} else {
|
||||||
const tempuser = new User(user as userjson, owner, true);
|
const tempuser = new User(user as userjson, owner, true);
|
||||||
owner.userMap.set(user.id, tempuser);
|
owner.userMap.set(user.id, tempuser);
|
||||||
|
@ -456,8 +451,15 @@ class User extends SnowFlake {
|
||||||
}
|
}
|
||||||
|
|
||||||
userupdate(json: userjson): void {
|
userupdate(json: userjson): void {
|
||||||
if (json.avatar !== this.avatar) {
|
for (const key of Object.keys(json)) {
|
||||||
this.changepfp(json.avatar);
|
if (key === "bio") {
|
||||||
|
this.bio = new MarkDown(json[key], this.localuser);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key === "id") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(this as any)[key] = (json as any)[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue