Skip to content

Commit 75b2aa5

Browse files
committed
feat: allow setting difficulty when using a custom level
1 parent 9ab7c19 commit 75b2aa5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/components/editor/OperationEditor.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,18 @@ const DifficultyPicker: FC<{
196196

197197
const stageName = useWatch({ control, name: 'stageName' })
198198
const { data: levels } = useLevels()
199-
const invalid = useMemo(
200-
() => !hasHardMode(levels, stageName),
201-
[levels, stageName],
202-
)
199+
const invalid = useMemo(() => {
200+
// if the stageName is a custom level, we always allow setting difficulty
201+
if (!findLevelByStageName(levels, stageName)) {
202+
return false
203+
}
204+
205+
if (hasHardMode(levels, stageName)) {
206+
return false
207+
}
208+
209+
return true
210+
}, [levels, stageName])
203211

204212
useEffect(() => {
205213
if (invalid && value !== OpDifficulty.UNKNOWN) {

0 commit comments

Comments
 (0)