From 4bee8ad4fc1c315055d0d3377f8140b02cd51621 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 25 Apr 2021 19:06:31 -0300 Subject: naughty hack for context menu in playlist sources ...plus a todo detailing what should be better --- socket.js | 2 +- todo.txt | 7 +++++++ ui.js | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/socket.js b/socket.js index 33269ee..e02285c 100644 --- a/socket.js +++ b/socket.js @@ -42,7 +42,7 @@ import { // clients / the server otherwise. const DEFAULT_NICKNAME = '(Unnamed)' -const originalSymbol = Symbol('Original item') +export const originalSymbol = Symbol('Original item') function serializePartySource(item) { // Turn an item into a sanitized, compact format for sharing with the server diff --git a/todo.txt b/todo.txt index 1371aa8..2cf7f66 100644 --- a/todo.txt +++ b/todo.txt @@ -704,6 +704,13 @@ TODO: The checks for "grouplike"/"track" have been super arbitrary for a long TODO: Synchronize items that have been shared with the party upon a new client joining. Should be next to (or part of) the initialize-backend command. +TODO: We currently use a hack to access the original item in the context menu + for items in the party sources listing. This doesn't make, for example, + queuing by pressing enter on a track work. We should instead have a way + to specifically refer to the item "represented" by a line, rather than + the literal object it's associated with (i.e. the pseudo-track/group + shared in the sources array). + TODO: Pressing escape while you've got items selected should deselect those items, rather than stop playback! ...Or SHOULD IT??? Well, yes. But it's still handy to not be locked out of stopping playback altogether. diff --git a/ui.js b/ui.js index b64763b..7e36858 100644 --- a/ui.js +++ b/ui.js @@ -19,6 +19,7 @@ import unic from 'tui-lib/util/unichars' import {getAllCrawlersForArg} from './crawlers.js' import processSmartPlaylist from './smart-playlist.js' +import {originalSymbol} from './socket.js' import UndoManager from './undo-manager.js' import { @@ -1498,6 +1499,16 @@ export default class AppElement extends FocusElement { // const isMarked = false const rootGroup = getItemPath(item)[0] + + // This is the hack mentioned in the todo!!!! + if ( + this.config.showPartyControls && + rootGroup.isPartySources && + item[originalSymbol] + ) { + item = item[originalSymbol] + } + // const hasNotesFile = !!getCorrespondingFileForItem(item, '.txt') const timestampsItem = this.hasTimestampsFile(item) && (this.timestampsExpanded(item, listing) ? {label: 'Collapse saved timestamps', action: () => this.collapseTimestamps(item, listing)} -- cgit 1.3.0-6-gf8a5