« get me outta code hell

basic working backend save/restore & socket server - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2020-07-10 11:28:34 -0300
committerFlorrie <towerofnix@gmail.com>2020-07-10 11:28:34 -0300
commit503a37ba4d7550f9c2ed1602e589a0142a20d10d (patch)
treebadb7a7638672c14ddea4f4c28a6c232f1c4a0f4 /ui.js
parentc625099a05f4e4dd8b998a9469f016d649982b50 (diff)
basic working backend save/restore & socket server
Backend save/restore code (living in serialized-backend.js) has been
well tested and shouldn't need much change going forward. Now we get to
begin working on the actual synchronized-over-socket-server commands!
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index de0b214..1e48877 100644
--- a/ui.js
+++ b/ui.js
@@ -32,6 +32,11 @@ const {
 } = require('./playlist-utils')
 
 const {
+  updateRestoredTracksUsingPlaylists,
+  getWaitingTrackData
+} = require('./serialized-backend')
+
+const {
   ui: {
     Dialog,
     DisplayElement,
@@ -189,6 +194,8 @@ class AppElement extends FocusElement {
     this.isPartyHost = false
     this.enableAutoDJ = false
 
+    this.playlistSources = []
+
     this.config = Object.assign({
       canControlPlayback: true,
       canControlQueue: true,
@@ -1124,6 +1131,9 @@ class AppElement extends FocusElement {
 
     grouplike = await processSmartPlaylist(grouplike)
 
+    this.playlistSources.push(grouplike)
+    updateRestoredTracksUsingPlaylists(this.backend, this.playlistSources)
+
     if (!this.tabber.currentElement || newTab && this.tabber.currentElement.grouplike) {
       const grouplikeListing = this.newGrouplikeListing()
       grouplikeListing.loadGrouplike(grouplike)
@@ -3379,6 +3389,7 @@ class PlaybackInfoElement extends FocusElement {
 
   refreshTrackText(maxNameWidth = Infinity) {
     const { playingTrack } = this.queuePlayer
+    const waitingTrackData = getWaitingTrackData(this.queuePlayer)
     if (playingTrack) {
       this.currentTrack = playingTrack
       const { name } = playingTrack
@@ -3390,6 +3401,11 @@ class PlaybackInfoElement extends FocusElement {
       this.progressBarLabel.text = ''
       this.progressTextLabel.text = '(Starting..)'
       this.timeData = {}
+    } else if (waitingTrackData) {
+      const { name } = waitingTrackData
+      this.clearInfoText()
+      this.trackNameLabel.text = name
+      this.progressTextLabel.text = '(Waiting to play, once found in playlist source.)'
     } else {
       this.clearInfoText()
     }