« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/play.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/play.js b/src/play.js
index b049a0d..d54004a 100755
--- a/src/play.js
+++ b/src/play.js
@@ -93,6 +93,16 @@ async function main(args) {
   // The file to output the playlist path to the current file.
   let trackDisplayFile
 
+  // Whether or not a playlist has been opened yet. This is just used to
+  // decide when exactly to load the default playlist. (We don't want to load
+  // it as soon as the process starts, since there might be an --open-playlist
+  // option that specifies opening a *different* playlist! But if we encounter
+  // an action that requires a playlist, and no playlist has yet been opened,
+  // we assume that the user probably wants to do something with the default
+  // playlist, and that's when we open it. See requiresOpenPlaylist for the
+  // implementation of this.)
+  let hasOpenedPlaylist = false
+
   const keybindings = [
     [['space'], 'togglePause'],
     [['left'], 'seek', -5],
@@ -187,8 +197,6 @@ async function main(args) {
     keybindings.unshift(...openedKeybindings)
   }
 
-  let hasOpenedPlaylist = false
-
   async function requiresOpenPlaylist() {
     if (activePlaylist === null) {
       if (hasOpenedPlaylist === false) {