Skip to content
Snippets Groups Projects
Commit 94547f25 authored by Isaac Evavold's avatar Isaac Evavold
Browse files

fix termcode factory reinitialization error

Error caused when user loaded the degree planner (thus initializing the termcode factory), switched to the dars view (which doesn't reset the termcode factory), then switched back to the degree planner (which attempted to initialize an already initialized termcode factory).

This fixes the bug by only attempting to initialize the termcode factory if the termcode factory is uninitialized
parent 9f3dd806
No related branches found
No related tags found
No related merge requests found
......@@ -23,14 +23,18 @@ export class TermCodeFactory {
}
private requireInitialization() {
if (this.state !== 'initialized') {
if (this.isNotInitialized()) {
throw new Error('cannot use TermCodeFactory without active terms');
}
}
public isNotInitialized(): boolean {
return this.state !== 'initialized';
}
public setActiveTermCodes(active: RawTermCode[]) {
if (this.state !== 'uninitialized') {
throw new Error('the TermCodeFactory was not uninitialized');
if (this.isNotInitialized() === false) {
throw new Error('the TermCodeFactory was already initialized');
} else if (active.length === 0) {
throw new Error('app cannot have 0 active terms, must have at least 1');
}
......
......@@ -68,7 +68,10 @@ export class DegreePlanEffects {
}),
flatMap(({ allDegreePlans, activeTermCodes, userPreferences }) => {
this.termCodeService.setActiveTermCodes(activeTermCodes);
if (this.termCodeService.isNotInitialized()) {
this.termCodeService.setActiveTermCodes(activeTermCodes);
}
const savedForLaterCourses = this.api.getSavedForLaterCourses();
const visibleDegreePlan = userPreferences.degreePlannerSelectedPlan
? pickDegreePlanById(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment