in src/views/agile-board/board-actions.ts [264:326]
export function loadSprint(
agileId: string,
sprintId: string,
query: string,
): ReduxAction {
return async (
dispatch: ReduxThunkDispatch,
getState: ReduxStateGetter,
getApi: ReduxAPIGetter,
) => {
const api: Api = getApi();
dispatch(setError(null));
dispatch(setGlobalInProgress(true));
destroySSE();
try {
const sprint = await api.agile.getSprint(
agileId,
sprintId,
PAGE_SIZE,
0,
query,
);
const state: AppState = getState();
async function loadSEETicket(): Promise<string | null> {
const [error, eventSourceTicket] = await until(
api.agile.loadSprintSSETicket(
sprint.agile?.id || state.agile.id,
sprint.id,
encodeURIComponent(getStorageState().agileQuery || ''),
),
);
return error ? null : eventSourceTicket;
}
if (sprint && !sprint.eventSourceTicket) {
const eventSourceTicket: string | null = await loadSEETicket();
if (eventSourceTicket) {
sprint.eventSourceTicket = eventSourceTicket;
}
}
if (!state?.agile?.sprint) {
dispatch(receiveSprint(sprint));
}
dispatch(loadSprintIssues(sprint));
dispatch(updateAgileUserProfileLastVisitedSprint(sprint.id));
log.info(`Agile Actions: Sprint has been loaded`);
} catch (e) {
const message: string = 'Could not load requested sprint';
const error: CustomError = (new Error(message) as any) as CustomError;
error.error_description = 'Check that the sprint exists';
dispatch(setError(error));
dispatch(receiveSprint(null));
trackError('Load sprint');
log.info(message, e);
dispatch(setGlobalInProgress(false));
}
};
}