Add commenter targeting mode

This commit is contained in:
Jamie Brunton committed 2026-08-14 08:51:27 +01:00
1 parent 0dfdda61fd
commit e9a4c965ee
23 files changed
+374 -10

No files matched your search

@@ -164,6 +164,19 @@ export function SubredditEditor({
options={[{ value: 'image', label: 'Image posts' }, { value: 'chat', label: 'Chat and text posts' }]}
value={draft.type}
/>
<SelectField
hint="Comment mode scans reactions on each new image post and contacts only high-confidence matches."
label="Recipient"
name="subreddit-targeting-mode"
onChange={(targetingMode) => update({ targetingMode })}
options={draft.type === 'chat'
? [{ value: 'post-author', label: 'Post author' }]
: [
{ value: 'post-author', label: 'Post author' },
{ value: 'comment-author', label: 'Qualifying commenter' },
]}
value={draft.type === 'chat' ? 'post-author' : draft.targetingMode}
/>
</div>
</fieldset>
@@ -15,6 +15,7 @@ export interface SubredditDraft {
name: string;
enabled: boolean;
type: 'image' | 'chat';
targetingMode: 'post-author' | 'comment-author';
weight: string;
tone: ToneKey;
scripted: string;
@@ -84,6 +85,7 @@ export function toSubredditDraft(subreddit: SubredditConfig): SubredditDraft {
name: subreddit.name,
enabled: subreddit.enabled,
type: subreddit.type,
targetingMode: subreddit.targetingMode,
weight: subreddit.weight === undefined ? '' : String(subreddit.weight),
tone: subreddit.tone,
scripted: subreddit.scripted ?? '',
@@ -98,6 +100,7 @@ export function createEmptySubredditDraft(): SubredditDraft {
name: '',
enabled: true,
type: 'image',
targetingMode: 'post-author',
weight: '',
tone: 'default',
scripted: '',
@@ -147,6 +150,7 @@ export function validateSubredditDraft(draft: SubredditDraft, takenNames: readon
name,
enabled: draft.enabled,
type: draft.type,
targetingMode: draft.type === 'chat' ? 'post-author' : draft.targetingMode,
...(draft.weight.trim() === '' ? {} : { weight: Number(draft.weight) }),
tone: draft.tone,
...(draft.scripted.trim() === '' ? {} : { scripted: draft.scripted }),
@@ -319,6 +319,9 @@ export function SubredditsPage() {
<span className="subreddit-tags">
<span className={mode.isAutonomous ? 'pill warning' : 'pill neutral'}>{mode.badge}</span>
<span className="pill neutral">{subreddit.type === 'image' ? 'Image' : 'Chat'}</span>
{subreddit.targetingMode === 'comment-author'
? <span className="pill neutral">Commenters</span>
: null}
<span className="pill neutral">{subreddit.tone}</span>
{subreddit.scripted ? <span className="pill neutral">Scripted</span> : null}
</span>