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

Function toDraft

packages/shared/src/features/feedExplain/useFeedTuneState.ts:56–86  ·  view source on GitHub ↗
(changes: TuneChange[])

Source from the content-addressed store, hash-verified

54});
55
56const toDraft = (changes: TuneChange[]): FeedControlsDraft =>
57 latestChanges(changes).reduce<FeedControlsDraft>((draft, change) => {
58 switch (change.kind) {
59 case 'topic':
60 return {
61 ...draft,
62 topics: [
63 ...(draft.topics ?? []),
64 { keyword: change.keyword, ...toDraftEntry(change.value) },
65 ],
66 };
67 case 'source':
68 return {
69 ...draft,
70 sources: [
71 ...(draft.sources ?? []),
72 { sourceId: change.sourceId, ...toDraftEntry(change.value) },
73 ],
74 };
75 case 'author':
76 return {
77 ...draft,
78 authors: [
79 ...(draft.authors ?? []),
80 { userId: change.userId, ...toDraftEntry(change.value) },
81 ],
82 };
83 default:
84 return { ...draft, learning: change.enabled };
85 }
86 }, {});
87
88export interface UseFeedTuneState {
89 /** The open tab; Tune is closed without one. */

Callers 1

useFeedTuneStateFunction · 0.70

Calls 2

latestChangesFunction · 0.85
toDraftEntryFunction · 0.85

Tested by

no test coverage detected