MCPcopy Create free account
hub / github.com/dailydotdev/apps / getTopicLevel

Function getTopicLevel

packages/shared/src/features/feedExplain/describe.ts:406–425  ·  view source on GitHub ↗
(
  tag: string,
  controls: FeedControls | undefined,
  profile: FeedProfile | undefined,
)

Source from the content-addressed store, hash-verified

404
405/** The level the reader set on a topic. */
406export 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
427export const getTopicWeight = (
428 tag: string,

Callers 2

FeedExplanationModalFunction · 0.90
getTopicMetaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected