Validate and deduplicate custom difficulty presets
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m4s
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m4s
This commit is contained in:
13
shared/difficulty-presets.ts
Normal file
13
shared/difficulty-presets.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { DifficultyPreset } from "./protocol";
|
||||
|
||||
// A list fetched before a save must not remove the newly saved preset.
|
||||
export function mergeDifficultyPresets(
|
||||
current: DifficultyPreset[],
|
||||
incoming: DifficultyPreset[],
|
||||
) {
|
||||
return [
|
||||
...new Map(
|
||||
[...current, ...incoming].map((preset) => [preset.id, preset]),
|
||||
).values(),
|
||||
].sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
Reference in New Issue
Block a user