hotfix: fix typescript errors
This commit is contained in:
1 parent
b2d0cb269c
commit
61a8344fd7
1 file changed
+24
-23
+24
-23
@@ -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,39 +51,38 @@ 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,
|
||||||
revertColors: toBool(env.PUBLIC_REVERT_VOTE_COLORS) ?? false,
|
revertColors: toBool(env.PUBLIC_REVERT_VOTE_COLORS) ?? false,
|
||||||
showInstances: {
|
showInstances: {
|
||||||
user: toBool(env.PUBLIC_SHOW_INSTANCES_USER) ?? false,
|
user: toBool(env.PUBLIC_SHOW_INSTANCES_USER) ?? false,
|
||||||
community: toBool(env.PUBLIC_SHOW_INSTANCES_COMMUNITY) ?? true,
|
community: toBool(env.PUBLIC_SHOW_INSTANCES_COMMUNITY) ?? true,
|
||||||
comments: toBool(env.PUBLIC_SHOW_INSTANCES_COMMENTS) ?? false,
|
comments: toBool(env.PUBLIC_SHOW_INSTANCES_COMMENTS) ?? false,
|
||||||
},
|
},
|
||||||
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,
|
||||||
removed: toBool(env.PUBLIC_HIDE_REMOVED) ?? false,
|
removed: toBool(env.PUBLIC_HIDE_REMOVED) ?? false,
|
||||||
},
|
},
|
||||||
fullWidthLayout: toBool(env.PUBLIC_FULL_WIDTH_LAYOUT) ?? false,
|
fullWidthLayout: toBool(env.PUBLIC_FULL_WIDTH_LAYOUT) ?? false,
|
||||||
expandSidebar: toBool(env.PUBLIC_EXPAND_SIDEBAR) ?? true,
|
expandSidebar: toBool(env.PUBLIC_EXPAND_SIDEBAR) ?? true,
|
||||||
notifications: {
|
notifications: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
pollRate: 60 * 1000,
|
pollRate: 60 * 1000,
|
||||||
notifRate: 10 * 60 * 1000,
|
notifRate: 10 * 60 * 1000,
|
||||||
},
|
},
|
||||||
displayNames: toBool(env.PUBLIC_DISPLAY_NAMES) ?? true,
|
displayNames: toBool(env.PUBLIC_DISPLAY_NAMES) ?? true,
|
||||||
nsfwBlur: toBool(env.PUBLIC_NSFW_BLUR) ?? true,
|
nsfwBlur: toBool(env.PUBLIC_NSFW_BLUR) ?? true,
|
||||||
moderation: {
|
moderation: {
|
||||||
removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
|
removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
|
||||||
},
|
},
|
||||||
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
|
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userSettings = writable(defaultSettings)
|
export const userSettings = writable(defaultSettings)
|
||||||
|
|||||||
Reference in new issue
Block a user