functions for adding/removing spot classes to ".server-item"s
This commit is contained in:
parent
004e7b8b11
commit
233968634b
@ -67,12 +67,13 @@ const fetchChannels = async serverId => {
|
|||||||
$(".sidebar .sidebar-item").prop("disabled", true);
|
$(".sidebar .sidebar-item").prop("disabled", true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$(`.sidebar .sidebar-item[data-id="${serverId}"]`).removeClass("spot spot-danger");
|
|
||||||
channels = await ajaxRequest(`/generate-channels?guild=${serverId}`, "GET");
|
channels = await ajaxRequest(`/generate-channels?guild=${serverId}`, "GET");
|
||||||
_loadedChannels[serverId] = channels;
|
_loadedChannels[serverId] = channels;
|
||||||
|
unspotItem(serverId); // remove the spot because no errors occured
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
logError(error);
|
logError(error);
|
||||||
|
unspotItem(serverId);
|
||||||
|
|
||||||
switch (error?.status) {
|
switch (error?.status) {
|
||||||
case 429:
|
case 429:
|
||||||
@ -113,7 +114,7 @@ const rateLimitedLoadingChannels = retryAfterSeconds => {
|
|||||||
|
|
||||||
const notAuthorisedLoadingChannels = serverId => {
|
const notAuthorisedLoadingChannels = serverId => {
|
||||||
// Mark the sidebar item as non-operational
|
// Mark the sidebar item as non-operational
|
||||||
$(`.sidebar .sidebar-item[data-id="${serverId}"]`).addClass("spot spot-danger");
|
spotItem(serverId, "danger");
|
||||||
|
|
||||||
const inviteBotToServer = () => {
|
const inviteBotToServer = () => {
|
||||||
window.open(
|
window.open(
|
||||||
@ -297,3 +298,16 @@ async function loadServers() {
|
|||||||
|
|
||||||
// Retry load servers button
|
// Retry load servers button
|
||||||
$(".sidebar .sidebar-retry-btn").on("click", loadServers);
|
$(".sidebar .sidebar-retry-btn").on("click", loadServers);
|
||||||
|
|
||||||
|
|
||||||
|
// region Spot Icons
|
||||||
|
|
||||||
|
const unspotItem = id => {
|
||||||
|
$(`.sidebar .sidebar-item[data-id="${id}"]`).removeClass(
|
||||||
|
"spot spot-primary spot-secondary spot-success spot-info spot-warning spot-danger"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const spotItem = (id, spotStyle) => {
|
||||||
|
$(`.sidebar .sidebar-item[data-id="${id}"]`).addClass(`spot spot-${spotStyle}`);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user