diff --git a/src/index.js b/src/index.js index c26204ea5..af8cb63e6 100644 --- a/src/index.js +++ b/src/index.js @@ -11,16 +11,6 @@ import {createSuperUser} from './services/superuser'; import './style/styles.scss'; import './style/index.scss'; -/** - * If the app is online, we keep one reference to the lessons and chapters - * to avoid reintantiating it multiple times throughout the app - */ -export let tutorialData = {} -if (process.env.REACT_APP_ENV === "offline") { - tutorialData.lessons = lessons; - tutorialData.chapters = chapters; -} - export function initLocalStorage() { localStorage.setItem("hasBeenSetup", true); localStorage.setItem("users", JSON.stringify([])); diff --git a/src/services/index.js b/src/services/index.js index 0f490a634..98ccfe89f 100644 --- a/src/services/index.js +++ b/src/services/index.js @@ -2,7 +2,6 @@ import axios from "axios"; import uuid from "uuid"; import {api_url} from "../constants"; -import {tutorialData} from ".."; import {applyTextTransformer} from "../middleware/requestTextConverter"; const sendPostReq = (url, data) => { @@ -303,8 +302,8 @@ class OnlineTutorialService { class OfflineTutorialService { constructor() { - this.lessons = tutorialData.lessons; - this.chapters = tutorialData.chapters; + this.lessons = getLocalStorageVal("lessons"); + this.chapters = getLocalStorageVal("chapters"); } lastLessonInChapter = { @@ -568,9 +567,6 @@ class OnlineChapterService { } class OfflineChapterService { - constructor() { - this.tutorialChapters = tutorialData.chapters; - } getChapterRecordsForUser(uid) { const { chapterRecords } = getLocalStorageVal("records"); @@ -580,8 +576,9 @@ class OfflineChapterService { } getChapterProgressPercentage(uid) { + const chapters = getLocalStorageVal("chapters"); return new Promise((res, rej) => { - res(Number(this.getChapterRecordsForUser(uid).length / this.tutorialChapters.length)); + res(Number(this.getChapterRecordsForUser(uid).length / chapters.length)); }) }