From 88172024d84fdf7c0f77eed107628676612e067c Mon Sep 17 00:00:00 2001 From: jeroentvb <36192730+jeroentvb@users.noreply.github.com> Date: Tue, 3 May 2022 20:32:38 +0200 Subject: [PATCH 1/2] feat: option to add to queue instead of play using modifier key --- README.md | 3 ++- src/components/PowerBar.tsx | 19 +++++++++++++++++-- src/constants/index.ts | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 827a175..e942d46 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,5 @@ Settings for the power bar can be found on spotify's settings page. There are se * Control * Alt * Cmd/Windows -* **Amount of suggestions per category**. How many suggestions to show per per category. Default is 3. Technically this can be set to 50, but in the power bar it's limited to 10 per category due to it being a better user experience. \ No newline at end of file +* **Amount of suggestions per category**. How many suggestions to show per per category. Default is 3. Technically this can be set to 50, but in the power bar it's limited to 10 per category due to it being a better user experience. +* **Add to queue**. Add the selected suggestion to the queue instead of playing it. When enabled hold `ctrl` (windows/linux) or `cmd` (macOs) when selecting the suggestion to add it to the playback queue. diff --git a/src/components/PowerBar.tsx b/src/components/PowerBar.tsx index 3044e04..9d9bf8b 100644 --- a/src/components/PowerBar.tsx +++ b/src/components/PowerBar.tsx @@ -11,7 +11,7 @@ import Suggestions from './Suggestions'; import type { ICategorizedSuggestion, ISuggestion } from '../types/suggestions.model'; import type { SuggestionClickEmitEvent } from '../types/custom-events.model'; -import { IS_INPUT_REGEX, KEY_COMBO, MODIFIER_KEYS, RESULTS_PER_CATEGORY } from '../constants'; +import { ADD_TO_QUEUE, IS_INPUT_REGEX, KEY_COMBO, MODIFIER_KEYS, RESULTS_PER_CATEGORY } from '../constants'; interface LocalState { active: boolean; @@ -79,6 +79,11 @@ export default class PowerBar extends React.Component, L } } }, + [ADD_TO_QUEUE]: { + type: 'toggle', + description: 'Add suggestion to queue instead of playing it when holding ctrl (windows/linux) or cmd (mac)', + defaultValue: false, + } }); this.settings.pushSettings(); @@ -107,8 +112,18 @@ export default class PowerBar extends React.Component, L this.onSelectSuggestion(uri, e); }; - onSelectSuggestion(uri: string, { metaKey, ctrlKey }: KeyboardEvent | MouseEvent) { + async onSelectSuggestion(uri: string, { metaKey, ctrlKey }: KeyboardEvent | MouseEvent) { + // Play item/add to queue if modifier key is held if (this.isMac && metaKey || !this.isMac && ctrlKey) { + const addToQueue = this.settings.getFieldValue(ADD_TO_QUEUE); + if (addToQueue) { + await Spicetify.CosmosAsync.post(`https://api.spotify.com/v1/me/player/queue?uri=${uri}`); + + this.togglePowerBar(); + Spicetify.showNotification('Added to queue'); + return; + } + Spicetify.Player.playUri(uri); return; } diff --git a/src/constants/index.ts b/src/constants/index.ts index a8cec62..c6707ce 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -7,4 +7,6 @@ export const RESULTS_PER_CATEGORY = 'results-per-category'; export const KEY_COMBO = 'key-combo'; +export const ADD_TO_QUEUE = 'add-to-queue'; + export const MODIFIER_KEYS: ['Shift', 'Control', 'Alt', 'Meta'] = ['Shift', 'Control', 'Alt', 'Meta']; From 8d68f2b089302a4209bfd8706d76356b52ad3ab8 Mon Sep 17 00:00:00 2001 From: jeroentvb <36192730+jeroentvb@users.noreply.github.com> Date: Tue, 3 May 2022 20:37:48 +0200 Subject: [PATCH 2/2] v1.5.0 --- package.json | 2 +- src/constants/change-notes.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 53b828f..7005556 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "power-bar", - "version": "1.4.0", + "version": "1.5.0", "author": { "name": "jeroentvb", "url": "https://github.com/jeroentvb" diff --git a/src/constants/change-notes.ts b/src/constants/change-notes.ts index 4c9dca5..636a121 100644 --- a/src/constants/change-notes.ts +++ b/src/constants/change-notes.ts @@ -1,7 +1,8 @@ const CHANGE_NOTES = ` -* Remove 'play immediately' setting +* Remove 'play immediately' setting in favour of 'add to queue' - Default behaviour is navigating to the selected suggestion - To just play and not navigate, hold \`ctrl\` (windows/linux) or \`cmd\` (mac) when selecting it + - To add to queue instad of playing the item, enable 'add to queue' and hold hold \`ctrl\` (windows/linux) or \`cmd\` (mac) `; export default CHANGE_NOTES;