(changes: TuneChange[])
| 54 | }); |
| 55 | |
| 56 | const 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 | |
| 88 | export interface UseFeedTuneState { |
| 89 | /** The open tab; Tune is closed without one. */ |
no test coverage detected