diff options
Diffstat (limited to 'playlist.lisp')
-rw-r--r-- | playlist.lisp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/playlist.lisp b/playlist.lisp index f7f0b04..7a2884b 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -3,7 +3,7 @@ (in-package :vampire) -;;; CLIENT STATE +;;; CLIENT STATE (defclass/std playlist-ctl () ((playlist :std nil :doc "The playlist instance.") @@ -14,7 +14,6 @@ :std nil :doc "Now Playing Elements") (pl-title pl-tracks pl-dur :std nil :doc "Playlist Elements") - (zipped :std nil :doc "Path to the zipped playlist, if it exists.")) (:documentation "Holds the complete state for this session's viewing of a particular playlist.")) (defclass/std track-ctl () @@ -49,7 +48,7 @@ (when (plusp pos) (nth (1- pos) (tracks ctl))))) -;;; SESSION UTIL +;;; SESSION UTIL (defparameter +playlist-connection-key+ "playlist-connection-key" "Stored in the clog connection object") @@ -65,6 +64,7 @@ (setf (cur-playlist-ctl body) (make-instance 'playlist-ctl :playlist playlist + :zipped-tracks (when (zipped-playlist-exists-p playlist) (zipped-playlist-url playlist)) :editorp (can-edit-p (session-user body) playlist)))) ;;; SYNCHRONIZATION @@ -189,10 +189,11 @@ (curctl (cur-playlist-ctl container)) (pos (position track-ctl (tracks curctl)))) - (when (delete-track-at (playlist curctl) pos) + (when (delete-track-at (playlist curctl) pos) + (delete-zipped-playlist (playlist curctl)) (for-playlist-viewers container ctl (let ((track-ctl (nth pos (tracks ctl)))) - (destroy (container track-ctl)) + (destroy (container track-ctl)) (setf (tracks ctl) (delete track-ctl (tracks ctl)) (text (pl-dur ctl)) (secs-to-hms (playlist-duration (playlist ctl))))))))) @@ -200,6 +201,7 @@ (when-let* ((curctl (cur-playlist-ctl (container track-ctl))) (pos (position track-ctl (tracks curctl)))) (when (swap-tracks (playlist curctl) pos (1+ pos)) + (delete-zipped-playlist (playlist curctl)) (for-playlist-viewers (container track-ctl) ctl (let* ((cur (nth pos (tracks ctl))) @@ -215,6 +217,7 @@ (when-let* ((curctl (cur-playlist-ctl (container track-ctl))) (pos (position track-ctl (tracks curctl)))) (when (swap-tracks (playlist curctl) pos (1- pos)) + (delete-zipped-playlist (playlist curctl)) (for-playlist-viewers (container track-ctl) ctl (let* ((cur (nth pos (tracks ctl))) @@ -348,13 +351,14 @@ (on-ok (lambda (track) (destroy notice) + (delete-zipped-playlist pl) (append-track pl track) (append-track-list-item parent track)))) (setf (value url-input) "") (if-let (track (track-with-source url)) (funcall on-ok track) (add-fetch-track-job - url on-ok + url on-ok (lambda (err) (destroy notice) (format t "~a" err) @@ -393,7 +397,7 @@ (thunk* (let ((user (user-with-name (value userinput)))) (cond - (user + (user (add-editor playlist user) (setf (value userinput) "" (text username-status) "") @@ -439,20 +443,17 @@ (div (:class "row") (div () - (button (:content "Create Playlist Zip" :bind download)) - (a (:link (zipped ctl) :content "Download" :bind dl-link))) + (button (:content "Download Zipped Playlist" :bind zip-download-button))) (div () (new-track-form (pl)) (editor-managment (pl))))) - (set-on-click download (thunk* - (setf (zipped ctl) (zip-playlist pl) - (link dl-link) (zipped ctl) - (display dl-link) "inline"))) + (set-on-click zip-download-button + (thunk* (zip-playlist pl) + (setf (url (location body)) (zipped-playlist-url pl)))) (setf (pl-title ctl) title-elem (pl-dur ctl) dur-elem (display input) "none" - (display dl-link) "none" (display title-elem) "inline") (when (playlist-editors pl) @@ -471,6 +472,7 @@ input (thunk* (when (plusp (length (value input))) + (delete-zipped-playlist pl) ;; must happen first (update-playlist-title pl (value input)) (setf (text title-elem) (value input))) (setf (display input) "none" |