aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-28 08:27:36 -0500
committerColin Okay <colin@cicadas.surf>2022-10-28 08:27:36 -0500
commitc734f6b9b9f5fe94e4e0ee8069ee06e44d2f6116 (patch)
tree44a756ceb95892c3366fa90a4eea2c3ce03da281
parentbdf67a20e2f21ba0da42787a3371252703a4c4b0 (diff)
Add: track addition syncrhonization; editor status held in ctl
-rw-r--r--playlist.lisp22
1 files changed, 11 insertions, 11 deletions
diff --git a/playlist.lisp b/playlist.lisp
index 6943c18..e23fb70 100644
--- a/playlist.lisp
+++ b/playlist.lisp
@@ -7,7 +7,7 @@
(defclass/std playlist-ctl ()
((playlist :std nil :doc "The playlist instance.")
-
+ (editorp :std nil)
(tracks :std nil :doc "A list of instances of track-ctl")
(now-playing-track :std nil :doc "An instance of track-ctl")
(np-title np-artist np-thumb np-dur np-time np-play
@@ -61,7 +61,9 @@
(defun install-new-playlist-ctl (playlist body)
(setf (cur-playlist-ctl body)
- (make-instance 'playlist-ctl :playlist playlist)))
+ (make-instance 'playlist-ctl
+ :playlist playlist
+ :editorp (can-edit-p (session-user body) playlist))))
;;; SYNCHRONIZATION
@@ -217,7 +219,6 @@
(place-after (container cur) (container next)))))))
-
;;; CLIENT UI
(defun playlist-title-content (playlist)
@@ -266,7 +267,7 @@
(princ " - " out))
(princ title out))))
-(defun create-track-list-item (list track ctl &optional editp)
+(defun create-track-list-item (list track ctl)
(with-clog-create list
(list-item (:bind container)
(div (:bind edit-controls)
@@ -288,7 +289,7 @@
(insert-nth track-ctl -1 (tracks ctl) t))
(cond
- (editp
+ ((editorp ctl)
(set-on-click delbtn (thunk* (remove-track track-ctl)))
(set-on-click downbtn (thunk* (move-track-down track-ctl)))
(set-on-click upbtn (thunk* (move-track-up track-ctl))))
@@ -301,20 +302,19 @@
(defun create-track-listing (parent pl)
(when-let (ctl (cur-playlist-ctl parent))
- (let ((ol (create-ordered-list parent))
- (editp (can-edit-p (session-user parent) pl)))
+ (let ((ol (create-ordered-list parent)))
(setf (pl-tracks ctl) ol)
(dolist (track (playlist-tracks pl))
- (create-track-list-item ol track ctl editp)))))
+ (create-track-list-item ol track ctl)))))
(defun append-track-list-item (obj track)
- (when-let (ctl (cur-playlist-ctl obj))
+ (for-playlist-viewers obj ctl
(create-track-list-item (pl-tracks ctl) track ctl)
(setf (text (pl-dur ctl))
(secs-to-hms (playlist-duration (playlist ctl))))))
(defun create-new-track-form (parent pl)
- (when (can-edit-p (session-user parent) pl)
+ (when (editorp (cur-playlist-ctl parent))
(with-clog-create parent
(div ()
(section (:h3 :content "Add A Track"))
@@ -415,7 +415,7 @@
(display input) "none"
(display title-elem) "inline")
- (when (can-edit-p (session-user body) pl)
+ (when (editorp ctl)
(set-on-blur
input
(thunk*