« get me outta code hell

Disallow suspending on telnet clients - 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-06 13:22:44 -0300
committerFlorrie <towerofnix@gmail.com>2019-07-06 13:23:20 -0300
commit2487c806b3ca2f4a9ab25bc24f55efbfccc02bfb (patch)
tree087a7d6a6fbbe056c0448c37d9785ff450d6e01a
parentbcc5120befd74ff583333f78a75729a87d13515c (diff)
Disallow suspending on telnet clients
Suspending doesn't really mean anything unless you're an actual process!
-rw-r--r--telnet-server.js1
-rw-r--r--ui.js9
2 files changed, 7 insertions, 3 deletions
diff --git a/telnet-server.js b/telnet-server.js
index d12e649..4e87499 100644
--- a/telnet-server.js
+++ b/telnet-server.js
@@ -27,6 +27,7 @@ class TelnetServer {
       writable: socket,
       interfacer,
       appConfig: {
+        canSuspend: false,
         showLeftPane: false,
         stopPlayingUponQuit: false,
         menubarColor: 2
diff --git a/ui.js b/ui.js
index 21b5844..2ec13fa 100644
--- a/ui.js
+++ b/ui.js
@@ -143,8 +143,9 @@ class AppElement extends FocusElement {
     this.attachListeners()
 
     this.config = Object.assign({
-      showLeftPane: true,
+      canSuspend: true,
       menubarColor: 4, // blue
+      showLeftPane: true,
       stopPlayingUponQuit: true
     }, config)
 
@@ -241,7 +242,7 @@ class AppElement extends FocusElement {
         {label: 'mtui (perpetual development)'},
         {divider: true},
         {label: 'Quit', action: () => this.shutdown()},
-        {label: 'Suspend', action: () => this.suspend()}
+        this.config.canSuspend && {label: 'Suspend', action: () => this.suspend()}
       ]},
       {text: 'Playback', menuFn: () => {
         const { playingTrack } = this.backend
@@ -631,7 +632,9 @@ class AppElement extends FocusElement {
   }
 
   suspend() {
-    this.emit('suspendRequested')
+    if (this.config.canSuspend) {
+      this.emit('suspendRequested')
+    }
   }
 
   fixLayout() {