round floats before comparing against default values
tabbing through the Advanced section was marking things like 'easy bonus' as modified
This commit is contained in:
parent
999fe98159
commit
f56c241702
@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import * as tr from "lib/i18n";
|
||||
import { revertIcon } from "./icons";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { isEqual, cloneDeep } from "lodash-es";
|
||||
import { isEqual as isEqualLodash, cloneDeep } from "lodash-es";
|
||||
// import { onMount } from "svelte";
|
||||
// import Tooltip from "bootstrap/js/dist/tooltip";
|
||||
|
||||
@ -26,6 +26,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function isEqual(a: unknown, b: unknown): boolean {
|
||||
if (typeof a === "number" && typeof b === "number") {
|
||||
// round to .01 precision before comparing,
|
||||
// so the values coming out of the UI match
|
||||
// the originals
|
||||
return isEqualLodash(Math.round(a * 100) / 100, Math.round(b * 100) / 100);
|
||||
} else {
|
||||
return isEqualLodash(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
let modified: boolean;
|
||||
$: modified = !isEqual(value, defaultValue);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user