« get me outta code hell

Support disabling process playback commands - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-07-07 16:50:59 -0300
committerFlorrie <towerofnix@gmail.com>2019-07-07 16:50:59 -0300
commit22c1ebc729c7f2a0b7245fd8b79f2ef360d42279 (patch)
treea15aa97ce001e1d94c5b3cf5fe2548e0e1300bb3
parent9ec90beb7ee50fc778665c58bf2805fc22dcc7ce (diff)
Support disabling process playback commands
-rw-r--r--telnet-server.js1
-rw-r--r--ui.js11
2 files changed, 9 insertions, 3 deletions
diff --git a/telnet-server.js b/telnet-server.js
index 93b4a5b..cda3323 100644
--- a/telnet-server.js
+++ b/telnet-server.js
@@ -29,6 +29,7 @@ class TelnetServer {
       appConfig: {
         canControlPlayback: false,
         canControlQueue: false,
+        canProcessMetadata: false,
         canSuspend: false,
         showLeftPane: true,
         stopPlayingUponQuit: false,
diff --git a/ui.js b/ui.js
index 766b4eb..0a1cbca 100644
--- a/ui.js
+++ b/ui.js
@@ -145,6 +145,7 @@ class AppElement extends FocusElement {
     this.config = Object.assign({
       canControlPlayback: true,
       canControlQueue: true,
+      canProcessMetadata: true,
       canSuspend: true,
       menubarColor: 4, // blue
       showLeftPane: true,
@@ -532,7 +533,7 @@ class AppElement extends FocusElement {
 
     const { item, isGroup, isMarked } = el
     const { editMode } = this
-    const { canControlQueue } = this.config
+    const { canControlQueue, canProcessMetadata } = this.config
     const anyMarked = editMode && this.markGrouplike.items.length > 0
 
     let items;
@@ -577,8 +578,8 @@ class AppElement extends FocusElement {
         canControlQueue && {label: 'Queue!', action: emitControls(false)},
         {divider: true},
 
-        {label: 'Process metadata (new entries)', action: () => this.processMetadata(item, false)},
-        {label: 'Process metadata (reprocess)', action: () => this.processMetadata(item, true)},
+        canProcessMetadata && {label: 'Process metadata (new entries)', action: () => this.processMetadata(item, false)},
+        canProcessMetadata && {label: 'Process metadata (reprocess)', action: () => this.processMetadata(item, true)},
         canControlQueue && {label: 'Remove from queue', action: () => this.unqueue(item)}
       ]
     }
@@ -868,6 +869,10 @@ class AppElement extends FocusElement {
   }
 
   async processMetadata(item) {
+    if (!this.config.canProcessMetadata) {
+      return
+    }
+
     if (this.clearMetadataStatusTimeout) {
       clearTimeout(this.clearMetadataStatusTimeout)
     }