Disable unavailable subreddits after Reddit 404

This commit is contained in:
jjbrunton committed 2026-08-08 22:53:24 +01:00
1 parent 664aa5c098
commit dcf57273e2
13 files changed
+153 -12

No files matched your search

@@ -9,6 +9,7 @@ import {
export interface SubredditDraft {
name: string;
enabled: boolean;
type: 'image' | 'chat';
weight: string;
tone: z.infer<typeof ToneKeySchema>;
@@ -67,6 +68,7 @@ export function createSettingsDraft(config: ConfigResponse): SettingsDraft {
recentWindowMinutes: String(config.reddit.recentWindowMinutes),
subreddits: config.subreddits.map((subreddit) => ({
name: subreddit.name,
enabled: subreddit.enabled,
type: subreddit.type,
weight: subreddit.weight === undefined ? '' : String(subreddit.weight),
tone: subreddit.tone,
@@ -112,6 +114,7 @@ export function validateSettingsDraft(draft: SettingsDraft): SettingsValidationR
recentWindowMinutes: Number(draft.recentWindowMinutes),
subreddits: draft.subreddits.map((subreddit) => ({
name: subreddit.name.trim(),
enabled: subreddit.enabled,
type: subreddit.type,
weight: subreddit.weight.trim() === '' ? undefined : Number(subreddit.weight),
tone: subreddit.tone,
@@ -122,7 +122,7 @@ export function BehaviourSection({ config, draft, errors, onChange }: SectionPro
...draft,
subreddits: [
...draft.subreddits,
{ name: '', type: 'image', weight: '1', tone: 'default', scripted: '' },
{ name: '', enabled: true, type: 'image', weight: '1', tone: 'default', scripted: '' },
],
})}
type="button"
@@ -157,6 +157,15 @@ export function BehaviourSection({ config, draft, errors, onChange }: SectionPro
<option value="image">Image</option><option value="chat">Chat</option>
</select>
</label>
<label className="toggle-field">
<input
aria-label={`Subreddit ${index + 1} enabled`}
checked={subreddit.enabled}
onChange={(event) => onChange(updateSubreddit(draft, index, { ...subreddit, enabled: event.target.checked }))}
type="checkbox"
/>
<span><strong>Enabled</strong><small>Disabled subreddits are not polled.</small></span>
</label>
<label className="settings-field">
<span>Weight</span>
<input