2023-12-19 05:27:18 -05:00
|
|
|
import AbstractView from "./abstracts/AbstractView.js";
|
|
|
|
import { client } from "../index.js"
|
|
|
|
|
|
|
|
export default class extends AbstractView {
|
|
|
|
constructor(params) {
|
|
|
|
super(params, "Profile ");
|
|
|
|
this.user_id = params.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
async postInit()
|
|
|
|
{
|
|
|
|
let profile = await client.profiles.getProfile(this.user_id);
|
2023-12-20 18:05:54 -05:00
|
|
|
|
|
|
|
if (profile === null)
|
|
|
|
return 1;
|
|
|
|
|
2023-12-19 05:27:18 -05:00
|
|
|
let info = document.getElementById("info");
|
|
|
|
|
|
|
|
// Username
|
|
|
|
let username = document.createElement("a");
|
|
|
|
username.id = "username";
|
|
|
|
username.appendChild(document.createTextNode(profile.username));
|
|
|
|
info.appendChild(username);
|
|
|
|
|
2023-12-20 18:05:54 -05:00
|
|
|
info.appendChild(document.createElement("br"));
|
2023-12-19 05:27:18 -05:00
|
|
|
|
|
|
|
// Avatar
|
|
|
|
let avatar = document.createElement("img");
|
|
|
|
avatar.id = "avatar";
|
|
|
|
avatar.src = profile.avatar_url;
|
|
|
|
info.appendChild(avatar);
|
|
|
|
|
|
|
|
// Block option
|
|
|
|
let block = document.createElement("a");
|
|
|
|
block.id = "block";
|
|
|
|
block.addEventListener("click", async () => {
|
|
|
|
if (client.me.user_id != user.user_id) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
block.appendChild(document.createTextNode("Block"));
|
|
|
|
info.appendChild(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
async getHtml() {
|
|
|
|
return `
|
|
|
|
<link rel="stylesheet" href="/static/css/profile.css">
|
|
|
|
<div id="info">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|