refactor: move expiration options into consts.ts

This commit is contained in:
2026-01-25 04:24:39 -05:00
parent 01efa399cf
commit a6b98a97f8
3 changed files with 24 additions and 32 deletions
+20
View File
@@ -156,6 +156,26 @@ export const syntaxes: Record<string, Syntax> = {
zenscript: { name: 'ZenScript', extension: '.zs' } zenscript: { name: 'ZenScript', extension: '.zs' }
}; };
export const expiresOptions = [
{ value: 0, label: 'Never Expire' },
{ value: 30000, label: 'Expire in 5 Minutes' },
{ value: 600000, label: 'Expire in 10 Minutes' },
{ value: 1800000, label: 'Expire in 30 Minutes' },
{ value: 3600000, label: 'Expire in 1 Hour' },
{ value: 21600000, label: 'Expire in 6 Hours' },
{ value: 43200000, label: 'Expire in 12 Hours' },
{ value: 86400000, label: 'Expire in 1 Day' },
{ value: 604800000, label: 'Expire in 1 Week' },
{ value: 1209600000, label: 'Expire in 2 Weeks' },
{ value: 2592000000, label: 'Expire in 1 Month' },
{ value: 7776000000, label: 'Expire in 3 Months' },
{ value: 15552000000, label: 'Expire in 6 Months' },
{ value: 31536000000, label: 'Expire in 1 Year' },
{ value: 63072000000, label: 'Expire in 2 Years' },
{ value: 157680000000, label: 'Expire in 5 Years' },
{ value: 315360000000, label: 'Expire in 10 Years' }
];
export const roles = { export const roles = {
0: 'User', 0: 'User',
1: 'Moderator', 1: 'Moderator',
+2 -16
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { PageData } from './$types'; import type { PageData } from './$types';
import { syntaxes } from '$lib/consts'; import { syntaxes, expiresOptions } from '$lib/consts';
import { user } from '$lib/stores/user'; import { user } from '$lib/stores/user';
import { getToken } from '$lib/utils/auth'; import { getToken } from '$lib/utils/auth';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@@ -108,21 +108,7 @@
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1) label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
})) ?? []; })) ?? [];
const expiresOptions = [
{ value: 0, label: 'Never Expire' },
{ value: 600000, label: 'Expire in 10 Minutes' },
{ value: 3600000, label: 'Expire in 1 Hour' },
{ value: 86400000, label: 'Expire in 1 Day' },
{ value: 604800000, label: 'Expire in 1 Week' },
{ value: 1209600000, label: 'Expire in 2 Weeks' },
{ value: 2592000000, label: 'Expire in 1 Month' },
{ value: 7776000000, label: 'Expire in 3 Months' },
{ value: 15552000000, label: 'Expire in 6 Months' },
{ value: 31536000000, label: 'Expire in 1 Year' },
{ value: 63072000000, label: 'Expire in 2 Years' },
{ value: 157680000000, label: 'Expire in 5 Years' },
{ value: 315360000000, label: 'Expire in 10 Years' }
];
const visibilityOptions = const visibilityOptions =
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({ data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
+2 -16
View File
@@ -32,7 +32,7 @@
isBinaryData isBinaryData
} from '$lib/utils/misc'; } from '$lib/utils/misc';
import { parseMarkdown } from '$lib/utils/markdown'; import { parseMarkdown } from '$lib/utils/markdown';
import { syntaxes } from '$lib/consts'; import { syntaxes, expiresOptions } from '$lib/consts';
import { resolve } from '$app/paths'; import { resolve } from '$app/paths';
import { decryptAES, encryptAES } from '$lib/utils/encryption'; import { decryptAES, encryptAES } from '$lib/utils/encryption';
import { fade } from 'svelte/transition'; import { fade } from 'svelte/transition';
@@ -73,21 +73,7 @@
value: lang, value: lang,
label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1) label: syntaxes[lang]?.name ?? lang.charAt(0).toUpperCase() + lang.slice(1)
})) ?? []; })) ?? [];
const expiresOptions = [
{ value: 0, label: 'Never Expire' },
{ value: 600000, label: 'Expire in 10 Minutes' },
{ value: 3600000, label: 'Expire in 1 Hour' },
{ value: 86400000, label: 'Expire in 1 Day' },
{ value: 604800000, label: 'Expire in 1 Week' },
{ value: 1209600000, label: 'Expire in 2 Weeks' },
{ value: 2592000000, label: 'Expire in 1 Month' },
{ value: 7776000000, label: 'Expire in 3 Months' },
{ value: 15552000000, label: 'Expire in 6 Months' },
{ value: 31536000000, label: 'Expire in 1 Year' },
{ value: 63072000000, label: 'Expire in 2 Years' },
{ value: 157680000000, label: 'Expire in 5 Years' },
{ value: 315360000000, label: 'Expire in 10 Years' }
];
const visibilityOptions = const visibilityOptions =
data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({ data.options?.visibilities?.map((visibility: { value: number; displayName: string }) => ({
value: visibility.value, value: visibility.value,