hotfix: fix typescript errors

This commit is contained in:
Xyphyn committed 2023-08-16 15:45:52 -07:00
1 parent b2d0cb269c
commit 61a8344fd7
1 file changed
+10 -9
+10 -9
View File
@@ -2,13 +2,15 @@ import type { CommentSortType, SortType } from 'lemmy-js-client'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
console.log("Using the following default settings from the environment:"); console.log('Using the following default settings from the environment:')
console.log(env); console.log(env)
// Returns a proper boolean or null. Used to set boolean values from env var strings while allowing nullish coalescing to set default values. // Returns a proper boolean or null. Used to set boolean values from env var strings while allowing nullish coalescing to set default values.
const toBool = (str) => { const toBool = (str: string | undefined) => {
if (typeof str === "undefined") { return null; } if (!str) {
return str === "true"; return null
}
return str.toLowerCase() === 'true'
} }
interface Settings { interface Settings {
@@ -49,7 +51,6 @@ interface Settings {
} }
export const defaultSettings: Settings = { export const defaultSettings: Settings = {
newComments: true, newComments: true,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true, expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true, markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
@@ -61,9 +62,9 @@ export const defaultSettings: Settings = {
}, },
showCompactPosts: toBool(env.PUBLIC_SHOW_COMPACT_POSTS) ?? false, showCompactPosts: toBool(env.PUBLIC_SHOW_COMPACT_POSTS) ?? false,
defaultSort: { defaultSort: {
sort: env.PUBLIC_DEFAULT_FEED_SORT ?? 'Active', sort: env.PUBLIC_DEFAULT_FEED_SORT ?? ('Active' as any),
feed: env.PUBLIC_DEFAULT_FEED ?? 'Local', feed: env.PUBLIC_DEFAULT_FEED ?? ('Local' as any),
comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? 'Hot', comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? ('Hot' as any),
}, },
hidePosts: { hidePosts: {
deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? true, deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? true,