attempt to add ignored channels page
This commit is contained in:
parent
cb425fe3cd
commit
1c43beb82f
13 changed files with 238 additions and 124 deletions
|
|
@ -1,9 +1,9 @@
|
|||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/stores";
|
||||
import { TOKEN_KEY, type User } from "$lib/api";
|
||||
import { addToast } from "$lib/toast";
|
||||
import {
|
||||
Button,
|
||||
Navbar,
|
||||
NavbarBrand,
|
||||
NavbarToggler,
|
||||
|
|
@ -11,6 +11,10 @@
|
|||
Nav,
|
||||
NavItem,
|
||||
NavLink,
|
||||
Dropdown,
|
||||
DropdownToggle,
|
||||
DropdownMenu,
|
||||
DropdownItem,
|
||||
} from "@sveltestrap/sveltestrap";
|
||||
|
||||
export let user: User | null;
|
||||
|
|
@ -32,15 +36,28 @@
|
|||
<Collapse {isOpen} navbar expand="lg">
|
||||
<Nav class="ms-auto" navbar>
|
||||
<NavItem>
|
||||
<NavLink href="/">Home</NavLink>
|
||||
<NavLink href="/" active={$page.url.pathname === "/"}>About</NavLink>
|
||||
</NavItem>
|
||||
{#if user}
|
||||
<NavItem>
|
||||
<NavLink href="/dash">Dashboard</NavLink>
|
||||
</NavItem>
|
||||
<NavItem>
|
||||
<NavLink on:click={logOut}>Log out</NavLink>
|
||||
</NavItem>
|
||||
<Dropdown nav inNavbar>
|
||||
<DropdownToggle nav caret>
|
||||
<img
|
||||
src={user.avatar_url}
|
||||
alt="Your avatar"
|
||||
style="border-radius: 0.75em; height: 1.5em;"
|
||||
/>
|
||||
{user.tag}
|
||||
</DropdownToggle>
|
||||
<DropdownMenu end>
|
||||
<DropdownItem
|
||||
href="/dash"
|
||||
active={$page.url.pathname.startsWith("/dash")}
|
||||
>
|
||||
Dashboard
|
||||
</DropdownItem>
|
||||
<DropdownItem on:click={logOut}>Log out</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
{:else}
|
||||
<NavItem>
|
||||
<NavLink href="/api/authorize">Log in with Discord</NavLink>
|
||||
|
|
|
|||
77
Catalogger.Frontend/src/lib/util.ts
Normal file
77
Catalogger.Frontend/src/lib/util.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import type { FullGuild } from "./api";
|
||||
|
||||
export const makeFullOptions = (guild: FullGuild, ignore: string[]) => {
|
||||
const options = [];
|
||||
|
||||
options.push(
|
||||
...guild.categories
|
||||
.filter((cat) => !ignore.some((k) => k === cat.id))
|
||||
.map((cat) => ({
|
||||
label: `${cat.name} (category)`,
|
||||
value: cat.id,
|
||||
})),
|
||||
);
|
||||
|
||||
// Filter these channels
|
||||
const channelsWithoutCategory = guild.channels_without_category.filter(
|
||||
(c) => c.can_redirect_from && !ignore.some((k) => k === c.id),
|
||||
);
|
||||
if (channelsWithoutCategory.length > 0)
|
||||
options.push({
|
||||
label: "(no category)",
|
||||
options: channelsWithoutCategory.map((c) => ({
|
||||
value: c.id,
|
||||
label: `#${c.name}`,
|
||||
})),
|
||||
});
|
||||
|
||||
options.push(
|
||||
...guild.categories
|
||||
.map((cat) => ({
|
||||
label: cat.name,
|
||||
options: cat.channels
|
||||
.filter((c) => c.can_redirect_from && !ignore.some((k) => k === c.id))
|
||||
.map((c) => ({ value: c.id, label: `#${c.name}` })),
|
||||
}))
|
||||
.filter((c) => c.options.length > 0),
|
||||
);
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
export const makeFullOptions2 = (guild: FullGuild, ignore: string[]) => {
|
||||
const options: Array<{ label: string; value: string; group: string }> = [];
|
||||
|
||||
options.push(
|
||||
...guild.categories
|
||||
.filter((cat) => !ignore.some((k) => k === cat.id))
|
||||
.map((cat) => ({
|
||||
label: `${cat.name} (category)`,
|
||||
value: cat.id,
|
||||
group: "Categories",
|
||||
})),
|
||||
);
|
||||
|
||||
// Filter these channels
|
||||
const channelsWithoutCategory = guild.channels_without_category.filter(
|
||||
(c) => c.can_redirect_from && !ignore.some((k) => k === c.id),
|
||||
);
|
||||
if (channelsWithoutCategory.length > 0)
|
||||
options.push(
|
||||
...channelsWithoutCategory.map((c) => ({
|
||||
value: c.id,
|
||||
label: `#${c.name}`,
|
||||
group: "(no category)",
|
||||
})),
|
||||
);
|
||||
|
||||
options.push(
|
||||
...guild.categories.flatMap((cat) =>
|
||||
cat.channels
|
||||
.filter((c) => c.can_redirect_from && !ignore.some((k) => k === c.id))
|
||||
.map((c) => ({ value: c.id, label: `#${c.name}`, group: cat.name })),
|
||||
),
|
||||
);
|
||||
|
||||
return options;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue