Questions without cache in db fix

This commit is contained in:
mrfry 2021-03-29 14:59:05 +02:00
parent 070defecb6
commit 2d81a76ef0
3 changed files with 17 additions and 11 deletions

View file

@ -42,7 +42,11 @@ import {
} from '../../utils/actions'
import dbtools from '../../utils/dbtools'
import auth from '../../middlewares/auth.middleware'
import { dataToString, getSubjNameWithoutYear } from '../../utils/classes'
import {
dataToString,
getSubjNameWithoutYear,
createQuestion,
} from '../../utils/classes'
import {
initWorkerPool,
doALongTask,
@ -1625,7 +1629,7 @@ function GetApp(): ModuleType {
logger.Log(
`User #${user.id} deleted '${file}' from subject '${subj}'`,
logger.GetColor('cyanbg')
logger.GetColor('cyan')
)
res.json({
res: 'ok',
@ -1710,7 +1714,7 @@ function GetApp(): ModuleType {
logger.Log(
`User #${user.id} deleted a question from '${subjName}'`,
logger.GetColor('cyanbg')
logger.GetColor('cyan')
)
utils.AppendToFile(
`${date}: User ${user.id} deleted a question from '${subjName}' (index: ${index})`,
@ -1770,7 +1774,7 @@ function GetApp(): ModuleType {
Questions: subj.Questions.map((question, i) => {
if (index === i) {
oldVal = question
return newVal
return createQuestion(newVal)
} else {
return question
}
@ -1781,7 +1785,7 @@ function GetApp(): ModuleType {
logger.Log(
`User #${user.id} edited a question in '${subjName}'`,
logger.GetColor('cyanbg')
logger.GetColor('cyan')
)
utils.AppendToFile(
`${date}: User ${user.id} edited a question in '${subjName}' (index: ${index})`,
@ -1859,7 +1863,7 @@ function GetApp(): ModuleType {
oldVal: question,
newVal: changedTo.value,
})
return changedTo.value
return createQuestion(changedTo.value)
} else {
return question
}
@ -1890,7 +1894,7 @@ function GetApp(): ModuleType {
logger.Log(
`User #${user.id} modified '${subjName}'. Edited: ${deletedQuestionsToWrite.length}, deleted: ${deletedQuestionsToWrite.length}`,
logger.GetColor('cyanbg')
logger.GetColor('cyan')
)
utils.AppendToFile(
`${date} User #${user.id} modified '${subjName}'. Edited: ${deletedQuestionsToWrite.length}, deleted: ${deletedQuestionsToWrite.length}`,