access profiles with username instead of id
This commit is contained in:
@ -4,17 +4,16 @@ import { client } from "../index.js"
|
||||
export default class extends AbstractView {
|
||||
constructor(params) {
|
||||
super(params, "Profile ");
|
||||
this.user_id = params.id;
|
||||
this.username = params.username;
|
||||
}
|
||||
|
||||
async postInit()
|
||||
{
|
||||
let profile = await client.profiles.getProfile(this.user_id);
|
||||
|
||||
if (profile === null)
|
||||
this.profile = await client.profiles.getProfile(this.username);
|
||||
if (this.profile === null)
|
||||
return 404;
|
||||
this.userId = this.profile.id;
|
||||
|
||||
this.profile = await client.profiles.getProfile(this.user_id);
|
||||
this.info = document.getElementById("info");
|
||||
|
||||
// Username
|
||||
@ -39,16 +38,16 @@ export default class extends AbstractView {
|
||||
if (await client.isAuthentificate() === false)
|
||||
return;
|
||||
|
||||
if (client.me.id != this.user_id) {
|
||||
if (client.me.id != this.userId) {
|
||||
let block = document.getElementById("block") || document.createElement("a");
|
||||
block.id = "block";
|
||||
block.innerText = "";
|
||||
block.onclick = async () => {
|
||||
if (!this.profile.isBlocked)
|
||||
await client.profiles.block(this.user_id);
|
||||
await client.profiles.block(this.userId);
|
||||
else
|
||||
await client.profiles.deblock(this.user_id);
|
||||
this.profile = await client.profiles.getProfile(this.user_id);
|
||||
await client.profiles.deblock(this.userId);
|
||||
this.profile = await client.profiles.getProfile(this.username);
|
||||
this.blockButton();
|
||||
};
|
||||
if (this.profile.isBlocked)
|
||||
|
Reference in New Issue
Block a user