( session: GoalQueueSession, goal: UpcomingGoal, )
| 96 | } |
| 97 | |
| 98 | export async function restoreGoalQueueItem( |
| 99 | session: GoalQueueSession, |
| 100 | goal: UpcomingGoal, |
| 101 | ): Promise<GoalQueueSnapshot> { |
| 102 | return withQueueMutationLock(session, async () => { |
| 103 | const state = await readQueueFile(session); |
| 104 | if (state.goals.some((item) => item.id === goal.id)) { |
| 105 | return toSnapshot(state); |
| 106 | } |
| 107 | const next: GoalQueueFile = { version: GOAL_QUEUE_VERSION, goals: [goal, ...state.goals] }; |
| 108 | await writeQueueFile(session, next); |
| 109 | return toSnapshot(next); |
| 110 | }); |
| 111 | } |
| 112 | |
| 113 | export async function moveGoalQueueItem( |
| 114 | session: GoalQueueSession, |
no test coverage detected