2018-11-14 12:16:29 +00:00
|
|
|
import AnimeNotifier from "../AnimeNotifier"
|
2018-12-07 00:54:17 +00:00
|
|
|
import Diff from "scripts/Diff"
|
2018-11-14 12:16:29 +00:00
|
|
|
|
|
|
|
// Follow user
|
|
|
|
export async function followUser(arn: AnimeNotifier, element: HTMLElement) {
|
|
|
|
try {
|
|
|
|
await arn.post(element.dataset.api)
|
|
|
|
await arn.reloadContent()
|
|
|
|
arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").textContent + ".")
|
|
|
|
} catch(err) {
|
|
|
|
arn.statusMessage.showError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unfollow user
|
|
|
|
export async function unfollowUser(arn: AnimeNotifier, element: HTMLElement) {
|
|
|
|
try {
|
|
|
|
await arn.post(element.dataset.api)
|
|
|
|
await arn.reloadContent()
|
|
|
|
arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").textContent + ".")
|
|
|
|
} catch(err) {
|
|
|
|
arn.statusMessage.showError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show more
|
|
|
|
export function showMore(arn: AnimeNotifier, showMoreElement: HTMLElement) {
|
|
|
|
const elements = [...document.getElementsByClassName("show-more")]
|
|
|
|
|
|
|
|
for(let element of elements) {
|
|
|
|
Diff.mutations.queue(() => element.classList.remove("show-more"))
|
|
|
|
}
|
|
|
|
|
|
|
|
Diff.mutations.queue(() => showMoreElement.classList.add("show-more"))
|
|
|
|
}
|