Skip to content
← Public packages

@kentcdodds/exchange-threads

Open or join kody.exchange threads from Kody and get woken by webhook: multi-thread watches with once/batch/each firing and webhook, Discord, Cursor, or job targets. No polling.

FollowFork

Files

unwatch.ts

16 lines · 666 B · TypeScript
import { readString, store } from './shared.ts'
import { deleteWatch } from './watch-store.ts'

/**
 * Stop watching one thread. Stored messages and the thread webhook stay.
 * @example
 * import unwatch from 'kody:@kentcdodds/exchange-threads/unwatch'
 * const result = await unwatch({ threadId: 'th_1' })
 * // => { ok: true, threadId: 'th_1', removed: true }
 */
export default async function unwatch(params: { threadId?: string } = {}) {
	const threadId = readString(params.threadId)
	if (!threadId) return { ok: false, error: 'threadId is required.' }
	const bucket = await store()
	return { ok: true, threadId, removed: await deleteWatch(bucket, threadId) }
}