Change routing. Remove a macro
This commit is contained in:
@ -33,7 +33,16 @@ let globalPatreon = false;
|
||||
let guildPatreon = false;
|
||||
|
||||
function guildId() {
|
||||
return document.querySelector(".guildList a.is-active").dataset["guild"];
|
||||
return window.location.pathname.match(/dashboard\/(\d+)/)[1];
|
||||
}
|
||||
|
||||
function pane() {
|
||||
const match = window.location.pathname.match(/dashboard\/\d+\/(.+)/);
|
||||
if (match === null) {
|
||||
return null;
|
||||
} else {
|
||||
return match[1];
|
||||
}
|
||||
}
|
||||
|
||||
function colorToInt(r, g, b) {
|
||||
@ -454,15 +463,16 @@ document.addEventListener("guildSwitched", async (e) => {
|
||||
|
||||
let hasError = false;
|
||||
|
||||
if ($anchor === null) {
|
||||
switch_pane("user-error");
|
||||
hasError = true;
|
||||
return;
|
||||
if ($anchor !== null) {
|
||||
$anchor.classList.add("is-active");
|
||||
}
|
||||
|
||||
switch_pane($anchor.dataset["pane"]);
|
||||
if (pane() === null) {
|
||||
window.history.replaceState({}, "", `/dashboard/${guildId()}/reminders`);
|
||||
}
|
||||
|
||||
switch_pane(pane());
|
||||
reset_guild_pane();
|
||||
$anchor.classList.add("is-active");
|
||||
|
||||
if (globalPatreon || (await fetch_patreon(e.detail.guild_id))) {
|
||||
document
|
||||
@ -695,11 +705,15 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
);
|
||||
$anchor.dataset["guild"] = guild.id;
|
||||
$anchor.dataset["name"] = guild.name;
|
||||
$anchor.href = `/dashboard/${guild.id}?name=${guild.name}`;
|
||||
$anchor.href = `/dashboard/${guild.id}/reminders`;
|
||||
|
||||
$anchor.addEventListener("click", async (e) => {
|
||||
e.preventDefault();
|
||||
window.history.pushState({}, "", `/dashboard/${guild.id}`);
|
||||
window.history.pushState(
|
||||
{},
|
||||
"",
|
||||
`/dashboard/${guild.id}/reminders`
|
||||
);
|
||||
const event = new CustomEvent("guildSwitched", {
|
||||
detail: {
|
||||
guild_name: guild.name,
|
||||
|
Reference in New Issue
Block a user