« get me outta code hell

naughty hack for context menu in playlist sources - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-25 19:06:31 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-25 19:06:31 -0300
commita1aa060f848e7d8da29142954c4f642970fc3fab (patch)
tree7d3d03ccbf01a229a411d6d21f4bfd8c583d025d
parentf0874e35653b50aa59b362fa8c8d9bd7ab6e416a (diff)
naughty hack for context menu in playlist sources
...plus a todo detailing what should be better
-rw-r--r--socket.js1
-rw-r--r--todo.txt7
-rw-r--r--ui.js14
3 files changed, 22 insertions, 0 deletions
diff --git a/socket.js b/socket.js
index 7760334..bc35c76 100644
--- a/socket.js
+++ b/socket.js
@@ -927,6 +927,7 @@ function attachSocketServerToBackend(server, backend) {
 }
 
 Object.assign(module.exports, {
+  originalSymbol,
   makeSocketServer,
   makeSocketClient,
   attachBackendToSocketClient,
diff --git a/todo.txt b/todo.txt
index f115383..726e04f 100644
--- a/todo.txt
+++ b/todo.txt
@@ -592,3 +592,10 @@ TODO: The checks for "grouplike"/"track" have been super arbitrary for a long
 
 TODO: Synchronize items that have been shared with the party upon a new client
       joining. Should be next to (or part of) the initialize-backend command.
+
+TODO: We currently use a hack to access the original item in the context menu
+      for items in the party sources listing. This doesn't make, for example,
+      queuing by pressing enter on a track work. We should instead have a way
+      to specifically refer to the item "represented" by a line, rather than
+      the literal object it's associated with (i.e. the pseudo-track/group
+      shared in the sources array).
diff --git a/ui.js b/ui.js
index 38a365d..bd73bdc 100644
--- a/ui.js
+++ b/ui.js
@@ -58,6 +58,10 @@ const {
   }
 } = require('tui-lib')
 
+const {
+  originalSymbol
+} = require('./socket')
+
 /* text editor features disabled because theyre very much incomplete and havent
  * gotten much use from me or anyone afaik!
 const TuiTextEditor = require('tui-text-editor')
@@ -1148,6 +1152,16 @@ class AppElement extends FocusElement {
       }
 
       const rootGroup = getItemPath(item)[0]
+
+      // This is the hack mentioned in the todo!!!!
+      if (
+        this.config.showPartyControls &&
+        rootGroup.isPartySources &&
+        item[originalSymbol]
+      ) {
+        item = item[originalSymbol]
+      }
+
       const hasNotesFile = !!getCorrespondingFileForItem(item, '.txt')
 
       if (listing.grouplike.isTheQueue && isTrack(item)) {