(
{ mode, weight, duration }: ControlValue<Mode>,
off?: Mode,
)
| 63 | |
| 64 | // Mirrors how the API stores it: an exact weight of 0 is the off level. |
| 65 | const toStored = <Mode>( |
| 66 | { mode, weight, duration }: ControlValue<Mode>, |
| 67 | off?: Mode, |
| 68 | ): FeedControl<Mode> | null => { |
| 69 | if (weight === undefined && !mode) { |
| 70 | return null; |
| 71 | } |
| 72 | return { |
| 73 | mode: weight === 0 && off ? off : (mode ?? null), |
| 74 | weight: weight || null, |
| 75 | expiresAt: getExpiresAt(duration), |
| 76 | }; |
| 77 | }; |
| 78 | |
| 79 | const applyChange = ( |
| 80 | controls: FeedControls, |
no test coverage detected