(
session: GoalQueueSession,
input: { readonly goalId: string; readonly objective: string },
)
| 63 | } |
| 64 | |
| 65 | export async function updateGoalQueueItem( |
| 66 | session: GoalQueueSession, |
| 67 | input: { readonly goalId: string; readonly objective: string }, |
| 68 | ): Promise<GoalQueueSnapshot> { |
| 69 | const objective = normalizeObjective(input.objective); |
| 70 | return withQueueMutationLock(session, async () => { |
| 71 | const state = await readQueueFile(session); |
| 72 | const index = findGoalIndex(state, input.goalId); |
| 73 | const current = state.goals[index]!; |
| 74 | const updatedAt = timestampAfter(current.updatedAt); |
| 75 | const goals = state.goals.map((goal, goalIndex) => |
| 76 | goalIndex === index ? { ...goal, objective, updatedAt } : goal, |
| 77 | ); |
| 78 | const next: GoalQueueFile = { version: GOAL_QUEUE_VERSION, goals }; |
| 79 | await writeQueueFile(session, next); |
| 80 | return toSnapshot(next); |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | export async function removeGoalQueueItem( |
| 85 | session: GoalQueueSession, |
no test coverage detected