diff options
author | dan <dan.abramov@gmail.com> | 2024-07-25 19:53:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 19:53:12 +0100 |
commit | 4291711f1d4bf3921b1e805d7726b0764757f257 (patch) | |
tree | 37e9a0c20dbe2b723fe2bcf722b3550a94b5b8d8 /src/state/queries/threadgate.ts | |
parent | fac1af43b0300e9d9be16641afc4fbeef0a91ccf (diff) | |
download | voidsky-4291711f1d4bf3921b1e805d7726b0764757f257.tar.zst |
Fix sloppy filter(Boolean) types (#4830)
* Fix sloppy filter(Boolean) in threadgate * Fix sloppy filter(Boolean) in Explore * Fix sloppy filter(Boolean) in post-feed * Harden FeedPostSliceItem.reason type def * Harden parentAuthor types * Fix lying component types, handle blocks
Diffstat (limited to 'src/state/queries/threadgate.ts')
-rw-r--r-- | src/state/queries/threadgate.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/state/queries/threadgate.ts b/src/state/queries/threadgate.ts index 67c6f8c08..c05d1f564 100644 --- a/src/state/queries/threadgate.ts +++ b/src/state/queries/threadgate.ts @@ -4,7 +4,7 @@ export type ThreadgateSetting = | {type: 'nobody'} | {type: 'mention'} | {type: 'following'} - | {type: 'list'; list: string} + | {type: 'list'; list: unknown} export function threadgateViewToSettings( threadgate: AppBskyFeedDefs.ThreadgateView | undefined, @@ -21,18 +21,18 @@ export function threadgateViewToSettings( if (!record.allow?.length) { return [{type: 'nobody'}] } - return record.allow + const settings: ThreadgateSetting[] = record.allow .map(allow => { + let setting: ThreadgateSetting | undefined if (allow.$type === 'app.bsky.feed.threadgate#mentionRule') { - return {type: 'mention'} + setting = {type: 'mention'} + } else if (allow.$type === 'app.bsky.feed.threadgate#followingRule') { + setting = {type: 'following'} + } else if (allow.$type === 'app.bsky.feed.threadgate#listRule') { + setting = {type: 'list', list: allow.list} } - if (allow.$type === 'app.bsky.feed.threadgate#followingRule') { - return {type: 'following'} - } - if (allow.$type === 'app.bsky.feed.threadgate#listRule') { - return {type: 'list', list: allow.list} - } - return undefined + return setting }) - .filter(Boolean) as ThreadgateSetting[] + .filter(<T>(n?: T): n is T => Boolean(n)) + return settings } |