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 { env } from '$env/dynamic/public'
console.log("Using the following default settings from the environment:");
console.log(env);
console.log('Using the following default settings from the environment:')
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.
const toBool = (str) => {
if (typeof str === "undefined") { return null; }
return str === "true";
const toBool = (str: string | undefined) => {
if (!str) {
return null
}
return str.toLowerCase() === 'true'
}
interface Settings {
@@ -49,7 +51,6 @@ interface Settings {
}
export const defaultSettings: Settings = {
newComments: true,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? 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,
defaultSort: {
sort: env.PUBLIC_DEFAULT_FEED_SORT ?? 'Active',
feed: env.PUBLIC_DEFAULT_FEED ?? 'Local',
comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? 'Hot',
sort: env.PUBLIC_DEFAULT_FEED_SORT ?? ('Active' as any),
feed: env.PUBLIC_DEFAULT_FEED ?? ('Local' as any),
comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? ('Hot' as any),
},
hidePosts: {
deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? true,