« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/things/Track.js11
-rw-r--r--src/data/yaml.js8
2 files changed, 11 insertions, 8 deletions
diff --git a/src/data/things/Track.js b/src/data/things/Track.js
index b0c8d955..dbff849b 100644
--- a/src/data/things/Track.js
+++ b/src/data/things/Track.js
@@ -21,6 +21,7 @@ import {
 } from '#validators';
 
 import {
+  flipBoolean,
   parseAdditionalFiles,
   parseAdditionalNames,
   parseAlwaysReferenceByDirectory,
@@ -1029,18 +1030,12 @@ export class Track extends Thing {
 
       'Has Cover Art': {
         property: 'disableUniqueCoverArt',
-        transform: value =>
-          (typeof value === 'boolean'
-            ? !value
-            : value),
+        transform: flipBoolean,
       },
 
       'Has Date': {
         property: 'disableDate',
-        transform: value =>
-          (typeof value === 'boolean'
-            ? !value
-            : value),
+        transform: flipBoolean,
       },
 
       // General metadata
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 60017b3d..cce2bbf0 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -621,6 +621,14 @@ export class SubdocAggregateError extends AggregateError {
   }
 }
 
+export function flipBoolean(value) {
+  if (typeof value === 'boolean') {
+    return !value;
+  } else {
+    return value;
+  }
+}
+
 export function parseDate(date) {
   return new Date(date);
 }