From 202c529db43aa9113a09b93ebcb35a024a4336b2 Mon Sep 17 00:00:00 2001 From: thsparks Date: Fri, 9 Feb 2024 10:46:35 -0800 Subject: [PATCH] Consolidate calls to set rubric so they go through the transform. --- teachertool/src/transforms/addCriteriaToRubric.ts | 6 ++---- teachertool/src/transforms/removeCriteriaFromRubric.ts | 6 ++---- teachertool/src/transforms/setRubricName.ts | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/teachertool/src/transforms/addCriteriaToRubric.ts b/teachertool/src/transforms/addCriteriaToRubric.ts index a61c8db77da..e124a207ca3 100644 --- a/teachertool/src/transforms/addCriteriaToRubric.ts +++ b/teachertool/src/transforms/addCriteriaToRubric.ts @@ -1,11 +1,10 @@ import { stateAndDispatch } from "../state"; -import * as Actions from "../state/actions"; import { getCatalogCriteriaWithId } from "../state/helpers"; import { logDebug, logError } from "../services/loggingService"; import { CriteriaInstance, CriteriaParameterValue } from "../types/criteria"; import { nanoid } from "nanoid"; import { ErrorCode } from "../types/errorCode"; -import * as AutorunService from "../services/autorunService"; +import { setRubric } from "./setRubric"; export function addCriteriaToRubric(catalogCriteriaIds: string[]) { const { state: teacherTool, dispatch } = stateAndDispatch(); @@ -45,8 +44,7 @@ export function addCriteriaToRubric(catalogCriteriaIds: string[]) { newRubric.criteria.push(criteriaInstance); } - dispatch(Actions.setRubric(newRubric)); - AutorunService.poke(); + setRubric(newRubric); pxt.tickEvent("teachertool.addcriteria", { ids: JSON.stringify(catalogCriteriaIds), diff --git a/teachertool/src/transforms/removeCriteriaFromRubric.ts b/teachertool/src/transforms/removeCriteriaFromRubric.ts index 6d372e39330..34c5ed681e9 100644 --- a/teachertool/src/transforms/removeCriteriaFromRubric.ts +++ b/teachertool/src/transforms/removeCriteriaFromRubric.ts @@ -1,8 +1,7 @@ import { stateAndDispatch } from "../state"; -import * as Actions from "../state/actions"; import { logDebug } from "../services/loggingService"; import { CriteriaInstance } from "../types/criteria"; -import * as AutorunService from "../services/autorunService"; +import { setRubric } from "./setRubric"; export function removeCriteriaFromRubric(instance: CriteriaInstance) { const { state: teacherTool, dispatch } = stateAndDispatch(); @@ -14,8 +13,7 @@ export function removeCriteriaFromRubric(instance: CriteriaInstance) { criteria: teacherTool.rubric.criteria.filter(c => c.instanceId !== instance.instanceId), }; - dispatch(Actions.setRubric(newRubric)); - AutorunService.poke(); + setRubric(newRubric); pxt.tickEvent("teachertool.removecriteria", { catalogCriteriaId: instance.catalogCriteriaId }); } diff --git a/teachertool/src/transforms/setRubricName.ts b/teachertool/src/transforms/setRubricName.ts index 6d43a74f4fe..c18bf9e0387 100644 --- a/teachertool/src/transforms/setRubricName.ts +++ b/teachertool/src/transforms/setRubricName.ts @@ -1,8 +1,8 @@ import { stateAndDispatch } from "../state"; -import * as Actions from "../state/actions"; +import { setRubric } from "./setRubric"; export function setRubricName(name: string) { - const { state: teacherTool, dispatch } = stateAndDispatch(); + const { state: teacherTool } = stateAndDispatch(); const oldName = teacherTool.rubric.name; @@ -14,5 +14,5 @@ export function setRubricName(name: string) { ...teacherTool.rubric, name, }; - dispatch(Actions.setRubric(newRubric)); + setRubric(newRubric); }