« get me outta code hell

data: Contribution.{previous,next}BySameArtist - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-17 21:16:41 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:14 -0300
commit5c5ffda914d9a7411932822366ed6aeaa71fe934 (patch)
tree28c6e85540ac3ee0468c47801a85ec572aa43a0f /src/data
parent0c871cf8e58fc6bc81ecb9a690411c60050f9f1a (diff)
data: Contribution.{previous,next}BySameArtist
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/contribution.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/data/things/contribution.js b/src/data/things/contribution.js
index b542dcf3..79acf1e1 100644
--- a/src/data/things/contribution.js
+++ b/src/data/things/contribution.js
@@ -8,7 +8,7 @@ import Thing from '#thing';
 import {isStringNonEmpty, isThing, validateReference} from '#validators';
 
 import {exitWithoutDependency, exposeDependency} from '#composite/control-flow';
-import {withPropertyFromObject} from '#composite/data';
+import {withNearbyItemFromList, withPropertyFromObject} from '#composite/data';
 import {withResolvedReference} from '#composite/wiki-data';
 import {flag, simpleDate} from '#composite/wiki-properties';
 
@@ -16,6 +16,7 @@ import {
   inheritFromContributionPresets,
   thingPropertyMatches,
   thingReferenceTypeMatches,
+  withContainingReverseContributionList,
   withContributionArtist,
   withContributionContext,
   withMatchingContributionPresets,
@@ -160,6 +161,46 @@ export class Contribution extends Thing {
     isForFlash: thingReferenceTypeMatches({
       value: input.value('flash'),
     }),
+
+    previousBySameArtist: [
+      withContainingReverseContributionList().outputs({
+        '#containingReverseContributionList': '#list',
+      }),
+
+      exitWithoutDependency({
+        dependency: '#list',
+      }),
+
+      withNearbyItemFromList({
+        list: '#list',
+        item: input.myself(),
+        offset: input.value(-1),
+      }),
+
+      exposeDependency({
+        dependency: '#nearbyItem',
+      }),
+    ],
+
+    nextBySameArtist: [
+      withContainingReverseContributionList().outputs({
+        '#containingReverseContributionList': '#list',
+      }),
+
+      exitWithoutDependency({
+        dependency: '#list',
+      }),
+
+      withNearbyItemFromList({
+        list: '#list',
+        item: input.myself(),
+        offset: input.value(+1),
+      }),
+
+      exposeDependency({
+        dependency: '#nearbyItem',
+      }),
+    ],
   });
 
   [inspect.custom](depth, options, inspect) {