Skip to content

Commit

Permalink
Fix ban indicator on user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
An0n3m0us committed Mar 26, 2021
1 parent 4488aef commit 3d84bf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async function addUserInfo (uok: UsernameOrKaid): Promise<void> {
getJSON(`${userEndpoint}/profile?${uok.type}=${uok.id}`, {
dateJoined: 1,
countVideosCompleted: 1,
isPublic: 1,
kaid: 1
})
.then(data => data as UserProfileData)
Expand All @@ -69,26 +70,21 @@ async function addUserInfo (uok: UsernameOrKaid): Promise<void> {
}

if (User.kaid === getKAID()) {
getJSON(`${window.location.origin}/api/v1/user`, {"discussion_banned":1}).then((data: User) => {
//If something messes up I don't want to accidentally tell someone they're banned
if (!data.hasOwnProperty("discussion_banned")) {
throw new Error("Error loading ban information.");
}else {
//If something messes up I don't want to accidentally tell someone they're banned
if (!User.hasOwnProperty("isPublic")) {
throw new Error("Error loading ban information.");
}else {
if (User.isPublic === false) {
let bannedHTML = `<tr><td class="user-statistics-label">Banned</td>`;

if (data.discussion_banned === false) {
bannedHTML += `<td>No</td>`;
}else if (data.discussion_banned === true) {
bannedHTML += `<td style="color: red">Discussion banned</td>`;
}else {
throw new Error("Error loading ban information.");
}
bannedHTML += `<td style="color: red">Discussion banned</td>`;

const lastTR = table.querySelector("tr:last-of-type");
if (!lastTR) { throw new Error("Table has no tr"); }
lastTR.outerHTML = bannedHTML + `</tr>` + lastTR.outerHTML;
} else if (User.isPublic !== true) {
throw new Error("Error loading ban information.");
}
});
}
}
});

Expand Down
1 change: 1 addition & 0 deletions src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ interface UserProfileData {
countBrandNewNotifications: number;
countVideosCompleted: number;
isModerator?: boolean;
isPublic?: boolean;
dateJoined: string;
kaid: string;
isPhantom: boolean;
Expand Down

0 comments on commit 3d84bf0

Please sign in to comment.