( tag: string, controls: FeedControls | undefined, profile: FeedProfile | undefined, )
| 404 | |
| 405 | /** The level the reader set on a topic. */ |
| 406 | export const getTopicLevel = ( |
| 407 | tag: string, |
| 408 | controls: FeedControls | undefined, |
| 409 | profile: FeedProfile | undefined, |
| 410 | ): FeedTopicMode | undefined => { |
| 411 | if (controls) { |
| 412 | return ( |
| 413 | controls.topics.find(({ keyword }) => keyword === tag)?.mode ?? undefined |
| 414 | ); |
| 415 | } |
| 416 | // The profile lags a change behind the controls, so it only stands in |
| 417 | // until they load. |
| 418 | if (profile?.muted.includes(tag)) { |
| 419 | return FeedTopicMode.Off; |
| 420 | } |
| 421 | const interest = profile?.interests.find((item) => item.tag === tag); |
| 422 | return interest?.control === TopicControl.Demote |
| 423 | ? FeedTopicMode.Demote |
| 424 | : undefined; |
| 425 | }; |
| 426 | |
| 427 | export const getTopicWeight = ( |
| 428 | tag: string, |
no outgoing calls
no test coverage detected