feat: add option to disable random placeholders, close #107
This commit is contained in:
1 parent
61a8344fd7
commit
dbbd460597
4 files changed
+47
-28
No files matched your search
@@ -48,6 +48,7 @@ interface Settings {
|
||||
removalReasonPreset: string
|
||||
}
|
||||
newVote: boolean
|
||||
randomPlaceholders: boolean
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
@@ -83,6 +84,7 @@ export const defaultSettings: Settings = {
|
||||
removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
|
||||
},
|
||||
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
|
||||
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? true,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
+7
-3
@@ -1,4 +1,6 @@
|
||||
import { goto } from '$app/navigation'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export const findClosestNumber = (numbers: number[], target: number): number =>
|
||||
numbers.reduce((prev, curr) =>
|
||||
@@ -47,8 +49,10 @@ export const placeholders = {
|
||||
'existential crisis in progress',
|
||||
],
|
||||
get: (type: 'url' | 'post' | 'comment') => {
|
||||
return placeholders[type][
|
||||
Math.floor(Math.random() * placeholders[type].length)
|
||||
]
|
||||
return get(userSettings)?.randomPlaceholders
|
||||
? placeholders[type][
|
||||
Math.floor(Math.random() * placeholders[type].length)
|
||||
]
|
||||
: ''
|
||||
},
|
||||
}
|
||||
@@ -95,6 +95,14 @@
|
||||
Show a user's display name instead of their account username.
|
||||
</span>
|
||||
</Setting>
|
||||
<Setting>
|
||||
<Checkbox slot="title" bind:checked={$userSettings.randomPlaceholders}>
|
||||
Random placeholders
|
||||
</Checkbox>
|
||||
<span slot="description">
|
||||
Show a random placeholder for forms for comments, posts, etc.
|
||||
</span>
|
||||
</Setting>
|
||||
|
||||
<SectionTitle class="mt-4">UI</SectionTitle>
|
||||
<Setting>
|
||||
|
||||
Reference in new issue
Block a user