Merge branch 'main' into resizable-sidebars
This commit is contained in:
commit
72701c9aef
16 changed files with 97 additions and 54 deletions
|
@ -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
|
||||
|
|
|
@ -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));
|
28
utils/loadPreferredTheme.ts
Normal file
28
utils/loadPreferredTheme.ts
Normal 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
7
utils/sortMembers.ts
Normal 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
7
utils/sortUsers.ts
Normal 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))
|
||||
})
|
||||
}
|
3
utils/validateUsername.ts
Normal file
3
utils/validateUsername.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export default (username: string) => {
|
||||
return /^[\w.-]+$/.test(username);
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export function validateUsername(username: string) {
|
||||
return /^[\w.-]+$/.test(username);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue