fix: stage re-execute

This commit is contained in:
Lin, Hung-Shin committed 2023-11-26 23:43:44 +08:00
1 parent d4446186cd
commit c7d18ad95e
2 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ export default class CommandHandler extends SessionHandler {
async run() {
try {
this.quest = await Quest.findById(this.session.quest)
const stages = this.getUnlockedComponents(this.quest.stages)
const stages = this.getStages()
if (stages.length === 0) {
logger.warn('stage not found', { session: this.session.id })
return {}
+6 -1
View File
@@ -25,8 +25,13 @@ export default class SessionHandler {
)
}
getStages() {
const unlockedStages = this.getUnlockedComponents(this.quest.stages)
return unlockedStages.filter((s) => !this.isCompleted(s))
}
getNewTasks() {
const stages = this.getUnlockedComponents(this.quest.stages)
const stages = this.getStages()
return stages
.filter((s) => s.task)
.filter((s) => !this.session.tasks.some((t) => t.id === s.id))