mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
playlists(#37): "Add to playlist" create/edit flow + enable FEATURE_PLAYLISTS
The create path — makes playlists actually usable end-to-end. - js/ui/playlistPicker.js: an "Add to playlist" dialog (modeled on confirmDialog) listing the signed-in user's playlists as checkboxes (checked when the video is already in them) + a "Create new playlist" input. On Save it diffs the checkboxes and publishes only changed playlists (add/remove the video) plus any new one, via the facade (active signer). Reads the current pubkey from nostrClient, so callers pass only the video coordinate. - videoMenuRenderers.js: "Add to playlist" item in the video ⋯ menu, gated by a new canManagePlaylists param. - moreMenuController.js: computes canManagePlaylists (FEATURE_PLAYLISTS && logged in), threads it into the panel context, and adds the add-to-playlist handler (resolves the video → coordinate via buildVideoAddressPointer, closes the popover, opens the picker; success/error routed to the app's toasts). - constants.js: FEATURE_PLAYLISTS flipped ON now that the core loop (create / add / remove / channel section / playlist view) works. Rollback: set false. Owner controls on the playlist view (rename / drag-reorder / hard-delete) are a follow-up; removing every video empties a playlist (drops from the listing). Syntax + lint + build clean; more-menu-controller tests 9/9. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
291d55d966
commit
f4fe4982bd
4 files changed
+292
-1
No files matched your search
@@ -6,6 +6,9 @@ import {
|
||||
} from "./components/videoMenuRenderers.js";
|
||||
import createPopover from "./overlay/popoverEngine.js";
|
||||
import { handleBlacklistEventAction } from "./moreMenu/blacklistEventAction.js";
|
||||
import { openPlaylistPicker } from "./playlistPicker.js";
|
||||
import { buildVideoAddressPointer } from "../utils/videoPointer.js";
|
||||
import { FEATURE_PLAYLISTS } from "../constants.js";
|
||||
import {
|
||||
prepareStaticModal,
|
||||
openStaticModal,
|
||||
@@ -731,6 +734,7 @@ export default class MoreMenuController {
|
||||
playbackUrl: entry.context.playbackUrl,
|
||||
playbackMagnet: entry.context.playbackMagnet,
|
||||
canManageBlacklist: entry.context.canManageBlacklist,
|
||||
canManagePlaylists: entry.context.canManagePlaylists,
|
||||
context: entry.context.context || "card",
|
||||
designSystem: entry.context.designSystem || this.designSystem,
|
||||
});
|
||||
@@ -906,6 +910,8 @@ export default class MoreMenuController {
|
||||
playbackMagnet = "",
|
||||
context = "card",
|
||||
canManageBlacklist = this.callbacks.canCurrentUserManageBlacklist(),
|
||||
canManagePlaylists = FEATURE_PLAYLISTS &&
|
||||
!!this.callbacks.getCurrentUserPubkey?.(),
|
||||
designSystem = null,
|
||||
onAction = null,
|
||||
onClose = null,
|
||||
@@ -924,6 +930,7 @@ export default class MoreMenuController {
|
||||
playbackUrl,
|
||||
playbackMagnet,
|
||||
canManageBlacklist,
|
||||
canManagePlaylists,
|
||||
context,
|
||||
designSystem: designSystem || this.designSystem,
|
||||
onAction,
|
||||
@@ -1199,6 +1206,40 @@ export default class MoreMenuController {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "add-to-playlist": {
|
||||
let targetVideo = video || null;
|
||||
if (!targetVideo && dataset?.eventId) {
|
||||
targetVideo =
|
||||
this.callbacks.getVideoByEventId(dataset.eventId) || null;
|
||||
}
|
||||
if (!targetVideo && context === "modal") {
|
||||
targetVideo = currentVideo || null;
|
||||
}
|
||||
if (!targetVideo) {
|
||||
this.callbacks.showError("No video selected.");
|
||||
break;
|
||||
}
|
||||
const coordinate = buildVideoAddressPointer(targetVideo);
|
||||
if (!coordinate) {
|
||||
this.callbacks.showError("Couldn’t identify this video.");
|
||||
break;
|
||||
}
|
||||
try {
|
||||
this.activePopover?.close?.();
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
openPlaylistPicker({
|
||||
videoCoordinate: coordinate,
|
||||
notify: (kind, message) =>
|
||||
kind === "success"
|
||||
? this.callbacks.showSuccess(message)
|
||||
: this.callbacks.showError(message),
|
||||
}).catch((error) => {
|
||||
userLogger.warn("[MoreMenu] Add-to-playlist failed:", error);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "remove-history": {
|
||||
await this.callbacks.handleRemoveHistoryAction(dataset);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user