« get me outta code hell

Revert "contracts: highly dysfunctional ContractManager" - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-05-25 08:54:28 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-05-25 08:54:28 -0300
commitb11cd3418188b8c4e4c8346577f9f7577736f807 (patch)
tree93ea9f2986fc378e7054c99f7e59c536cc2d5e20 /src/content
parent403c63afd7a9cc7ec2995d5200a6df8527fa3558 (diff)
Revert "contracts: highly dysfunctional ContractManager"
This reverts commit 63b1b5b6fd14d3bacdcb979298b4fa669de4f20b.
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateAlbumSidebarGroupBox.js68
-rw-r--r--src/content/dependencies/generateAlbumTrackList.js103
2 files changed, 30 insertions, 141 deletions
diff --git a/src/content/dependencies/generateAlbumSidebarGroupBox.js b/src/content/dependencies/generateAlbumSidebarGroupBox.js
index b3ee0abe..4e46c931 100644
--- a/src/content/dependencies/generateAlbumSidebarGroupBox.js
+++ b/src/content/dependencies/generateAlbumSidebarGroupBox.js
@@ -5,53 +5,45 @@ export default {
   extraDependencies: ['html', 'language', 'transformMultiline'],
 
   contracts: {
-    relations: {
-      hook(contract, [relation, album, group]) {
-        contract.provide({
-          group, album,
-
-          urls: contract.selectProperty(group, 'urls'),
-          adjacentAlbums: contract.subcontract('adjacentAlbumsInGroup', album, group),
-        });
-      },
+    relations(contract, [album, group]) {
+      contract.provide({
+        group, album,
 
-      compute({relation, group, album, urls, adjacentAlbums}) {
-        const relations = {};
+        urls: contract.selectProperty(group, 'urls'),
+        adjacentAlbums: contract.subcontract('adjacentAlbumsInGroup', album, group),
+      });
+    },
+  },
 
-        relations.groupLink =
-          relation('linkGroup', group);
+  relations(relation, {group, album, urls, adjacentAlbums}) {
+    const relations = {};
 
-        relations.externalLinks =
-          urls.map(url =>
-            relation('linkExternal', urls));
+    relations.groupLink =
+      relation('linkGroup', group);
 
-        const {previousAlbum, nextAlbum} = adjacentAlbums;
+    relations.externalLinks =
+      urls.map(url =>
+        relation('linkExternal', urls));
 
-        if (previousAlbum) {
-          relations.previousAlbumLink =
-            relation('linkAlbum', previousAlbum);
-        }
+    const {previousAlbum, nextAlbum} = adjacentAlbums;
 
-        if (nextAlbum) {
-          relations.nextAlbumLink =
-            relation('linkAlbum', nextAlbum);
-        }
+    if (previousAlbum) {
+      relations.previousAlbumLink =
+        relation('linkAlbum', previousAlbum);
+    }
 
-        return relations;
-      },
-    },
+    if (nextAlbum) {
+      relations.nextAlbumLink =
+        relation('linkAlbum', nextAlbum);
+    }
 
-    data: {
-      hook(contract, [album, group]) {
-        contract.provide({
-          description: contract.selectProperty(group, 'descriptionShort'),
-        });
-      },
+    return relations;
+  },
 
-      compute({description}) {
-        return {description};
-      },
-    },
+  data(album, group) {
+    return {
+      description: group.descriptionShort,
+    };
   },
 
   generate(data, relations, {html, language, transformMultiline}) {
diff --git a/src/content/dependencies/generateAlbumTrackList.js b/src/content/dependencies/generateAlbumTrackList.js
index a0fad460..f2f2279d 100644
--- a/src/content/dependencies/generateAlbumTrackList.js
+++ b/src/content/dependencies/generateAlbumTrackList.js
@@ -44,109 +44,6 @@ export default {
     'language',
   ],
 
-  contracts: {
-    length: {
-      hook(contract, [array]) {
-        contract.provide({
-          length: contract.selectProperty(array, 'length'),
-        });
-      },
-
-      compute({length}) {
-        return length;
-      },
-    },
-
-    isDefault: {
-      hook(contract, [trackSection]) {
-        contract.provide({
-          isDefault: contract.selectProperty(trackSection, 'isDefaultTrackSection', false),
-        });
-      },
-
-      compute({isDefault}) {
-        return isDefault;
-      },
-    },
-
-    firstIsDefault: {
-      hook(contract, [trackSections]) {
-        contract.provide({
-          isDefault: contract.subcontract('#isDefault', contract.selectProperty(trackSections, '0')),
-        });
-      },
-
-      compute({isDefault}) {
-        return isDefault;
-      },
-    },
-
-    displayTrackSections: {
-      hook(contract, [album]) {
-        contract.provide({
-          numTrackSections: contract.subcontract('#length', contract.selectProperty(album, 'trackSections')),
-          firstIsDefault: contract.subcontract('#firstIsDefault', contract.selectProperty(album, 'trackSections')),
-        });
-      },
-
-      compute({numTrackSections, firstIsDefault}) {
-        return numTrackSections >= 2 || firstIsDefault;
-      },
-    },
-
-    displayTracks: {
-      hook(contract, [album]) {
-        contract.provide({
-          numTracks: contract.subcontract('#length', contract.selectProperty(album, 'tracks')),
-        });
-      },
-
-      compute({numTracks}) {
-        return numTracks >= 1;
-      },
-    },
-
-    displayMode: {
-      hook(contract, [album]) {
-        contract.provide({
-          displayTrackSections: contract.subcontract('#displayTrackSections', album),
-          displayTracks: contract.subcontract('#displayTracks', album),
-        });
-      },
-
-      compute({displayTrackSections, displayTracks}) {
-        if (displayTrackSections) {
-          return 'trackSections';
-        } else if (displayTracks) {
-          return 'tracks';
-        } else {
-          return 'none';
-        }
-      },
-    },
-
-    relations: {
-      hook(contract, [relation, album]) {
-        contract.branch({
-          subcontract: ['#displayMode', album],
-          branches: {
-            trackSections() {
-              contract.provide({
-                trackSections: contract.selectProperty(album, 'trackSections'),
-              });
-            },
-
-            tracks() {
-              contract.provide({
-                tracks: contract.selectProperty(album, 'tracks'),
-              });
-            },
-          },
-        });
-      },
-    },
-  },
-
   relations(relation, album) {
     const relations = {};