Merge branch 'main' into resizable-sidebars
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
ci/woodpecker/pull_request_closed/build-and-publish Pipeline was successful

This commit is contained in:
SauceyRed 2025-07-19 06:46:12 +00:00
commit 72701c9aef
16 changed files with 97 additions and 54 deletions

View file

@ -1,6 +1,6 @@
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces";
export function getDisplayName(user: UserResponse, member?: GuildMemberResponse): string {
export default (user: UserResponse, member?: GuildMemberResponse): string => {
if (member?.nickname) return member.nickname
if (user.display_name) return user.display_name
return user.username

View file

@ -1,4 +1,4 @@
export async function hashPassword(password: string) {
export default async (password: string) => {
const encodedPass = new TextEncoder().encode(password);
const hashBuffer = await crypto.subtle.digest("SHA-384", encodedPass);
const hashArray = Array.from(new Uint8Array(hashBuffer));

View file

@ -0,0 +1,28 @@
let themeLinkElement: HTMLLinkElement | null;
export default function loadPreferredTheme() {
const currentTheme = settingsLoad().selectedThemeId ?? "dark"
if (themeLinkElement) {
themeLinkElement.href = getThemeUrl(currentTheme);
} else {
// create the theme link if one doesn't already exist
useHead({
link: [{
id: "main-theme",
rel: "stylesheet",
href: getThemeUrl(currentTheme)
}]
})
themeLinkElement = document.getElementById('main-theme') as HTMLLinkElement;
}
}
function getThemeUrl(id: string): string {
const runtimeConfig = useRuntimeConfig()
const baseURL = runtimeConfig.app.baseURL;
// this should preferrably use version hash, but that's not implemented yet
return `${baseURL}themes/${id}.css?v=${runtimeConfig.public.buildTimeString}`
}

7
utils/sortMembers.ts Normal file
View file

@ -0,0 +1,7 @@
import type { GuildMemberResponse } from "~/types/interfaces";
export default (members: GuildMemberResponse[]): GuildMemberResponse[] => {
return members.sort((a, b) => {
return getDisplayName(a.user, a).localeCompare(getDisplayName(b.user, b))
})
}

7
utils/sortUsers.ts Normal file
View file

@ -0,0 +1,7 @@
import type { UserResponse } from "~/types/interfaces";
export default (users: UserResponse[]): UserResponse[] => {
return users.sort((a, b) => {
return getDisplayName(a).localeCompare(getDisplayName(b))
})
}

View file

@ -0,0 +1,3 @@
export default (username: string) => {
return /^[\w.-]+$/.test(username);
}

View file

@ -1,3 +0,0 @@
export function validateUsername(username: string) {
return /^[\w.-]+$/.test(username);
}