From 4bb86ec7f1e34921e9a87dd6f703bd46649345dd Mon Sep 17 00:00:00 2001 From: John Thomson Date: Mon, 26 Aug 2024 11:10:18 -0500 Subject: [PATCH] fix: make require right/wrongAnswer.mp3 work in production AND storybook (With Andrew) --- src/activities/ActivityContext.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/activities/ActivityContext.ts b/src/activities/ActivityContext.ts index 4ec78f8a..f952c181 100644 --- a/src/activities/ActivityContext.ts +++ b/src/activities/ActivityContext.ts @@ -75,13 +75,15 @@ export class ActivityContext { // NB: if this stops working in storybook; the file should be found because the package.json // script that starts storybook has a "--static-dir" option that should include the folder // containing the standard activity sounds. - // require on an mp3 gives us some sort of module object where the url of the sound is its 'default' - this.playSound(rightAnswer.default); + // require on an mp3 in storybook gives us some sort of module object where the url of the sound is its 'default' + // whatever we're doing to build the production version, require on the mp3 gives us the url directly. + this.playSound(rightAnswer.default ?? rightAnswer); } public playWrong() { // require on an mp3 gives us some sort of module object where the url of the sound is its 'default' - this.playSound(wrongAnswer.default); + // whatever we're doing to build the production version, require on the mp3 gives us the url directly. + this.playSound(wrongAnswer.default ?? wrongAnswer); } private getPagePlayer(): any {