disable sidebar while loading channels
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

and add new modal code for "non-operational" warning
This commit is contained in:
Corban-Lee Jones 2024-10-12 13:17:16 +01:00
parent 3d4d5733b2
commit eceee915fa
2 changed files with 28 additions and 13 deletions

View File

@ -161,9 +161,9 @@
background-color: inherit;
}
.sidebar .sidebar-content .sidebar-item:hover,
.sidebar .sidebar-content .sidebar-item:focus,
.sidebar .sidebar-content .sidebar-item.active {
.sidebar .sidebar-content .sidebar-item:not(:disabled):hover,
.sidebar .sidebar-content .sidebar-item:not(:disabled):focus,
.sidebar .sidebar-content .sidebar-item:not(:disabled).active {
background-color: var(--bs-body-bg);
}
@ -180,9 +180,9 @@
transition: 0.1s ease;
}
.sidebar .sidebar-content .sidebar-item.is-not-operational:hover::before,
.sidebar .sidebar-content .sidebar-item.is-not-operational:focus::before,
.sidebar .sidebar-content .sidebar-item.is-not-operational.active::before {
.sidebar .sidebar-content .sidebar-item.is-not-operational:not(:disabled):hover::before,
.sidebar .sidebar-content .sidebar-item.is-not-operational:not(:disabled):focus::before,
.sidebar .sidebar-content .sidebar-item.is-not-operational:not(:disabled) .active::before {
transition: 0.3s ease;
width: 0.25rem;
height: 60px;

View File

@ -61,20 +61,35 @@ function loadedChannels(serverId) {
$(document).on("selectedServerChange", async function() {
serverId = selectedServer.id; // take note incase 'selectedServer' changes
$(".sidebar .sidebar-item").prop("disabled", true);
try {
channels = await ajaxRequest(`/generate-channels?guild=${serverId}`, "GET");
_loadedChannels[serverId] = channels;
$(".sidebar .sidebar-item").prop("disabled", false);
}
catch (error) {
logError(error);
// Mark the sidebar item as non-operational
$(`.sidebar .sidebar-item[data-id="${serverId}"]`).addClass("is-not-operational");
await okModal(
"Error: Bot Isn't a Member!",
"The PYRSS Discord Bot is unable to access this server, certain features won't work! Ensure it's a member and has the necessary permissions.",
"danger",
"bi-arrow-return-right",
null
);
// Inform the user of the problem
createModal({
title: "Failed to Fetch Server Channels",
texts: [
{ content: "The Discord Bot is unable to access this server's channels, certain features will not work." },
{ content: "Ensure the Bot is a member, and has the neccessary permissions to operate." }
],
buttons: [
{
className: "btn-danger px-4",
iconClass: "bi-arrow-return-right",
closeModal: true,
onClick: () => { $(".sidebar .sidebar-item").prop("disabled", false); }
}
]
});
}
});