mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-24 23:45:41 +00:00
fde7ab432f
* feat(playback): add transition-mode helper Centralise the crossfade/AutoDJ/gapless mutual exclusivity in one place instead of the scattered setter combinations across the toolbar, mini player and settings. AutoDJ stays encoded as crossfade + trim-silence, so the persisted flags and the audio engine are unchanged. * feat(queue): split AutoDJ into its own toolbar button + playlist submenu - AutoDJ becomes a standalone toolbar button (Blend icon) next to crossfade, driven by the shared transition-mode helper. The crossfade right-click popover drops the mode switch and keeps only the seconds slider. - Save + load playlist collapse into one Playlist button opening a small submenu, freeing up toolbar space. - queueToolbarStore gains a position-preserving rehydrate migration (legacy save/load -> playlist, autodj inserted after crossfade) with unit tests. - Toolbar customizer and all 9 queue locales updated to match. * feat(mini-player): standalone AutoDJ button, shared transition helper Mirror the queue toolbar: AutoDJ gets its own Blend button, the crossfade popover keeps only the seconds slider. The mini player now drives all three transitions through a single additive `mini:set-transition-mode` event handled by the shared helper, replacing the per-flag mini events. Drop the now-dead crossfade-mode CSS. * feat(settings): segmented track-transition picker, regroup playback Replace the crossfade toggle + inner crossfade/AutoDJ switch with a single Off | Gapless | Crossfade | AutoDJ segmented control (mirroring the Normalization picker above), driven by the shared transition helper — the mutual exclusivity now reads at a glance. Crossfade keeps its seconds slider; AutoDJ shows its content-driven explainer. The block is regrouped under "Track transitions" and "Queue behaviour" headings. Drops the now unused crossfade/gapless description and not-available i18n keys across all 9 locales and adds the new transition strings. * fix(queue): open the playlist submenu inward The playlist submenu inherited the crossfade popover's right:0 anchor and, sitting on the left of the toolbar, opened out under the main container. Anchor it left:0 so it stays inside the queue panel. Update the toolbar test for the new playlist submenu (save/load moved off the toolbar). * feat(settings): box playback sub-sections into panels Wrap Normalization, Track transitions and Queue behaviour each in their own bordered panel with an accent uppercase header (new reusable .settings-group classes), so the sections read as distinct blocks instead of one wall of text. Drops the thin divider that separated them. * docs: changelog, credits and what's new for AutoDJ standalone Fold the standalone-AutoDJ changes into the existing AutoDJ entry in the changelog and the in-app What's New, and add the credit (#1124).
88 lines
3.2 KiB
TypeScript
88 lines
3.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
DEFAULT_QUEUE_TOOLBAR_BUTTONS,
|
|
migrateQueueToolbarButtons,
|
|
type QueueToolbarButtonConfig,
|
|
} from './queueToolbarStore';
|
|
|
|
const ids = (b: QueueToolbarButtonConfig[]) => b.map(x => x.id);
|
|
const vis = (b: QueueToolbarButtonConfig[], id: string) => b.find(x => x.id === id)?.visible;
|
|
|
|
describe('migrateQueueToolbarButtons', () => {
|
|
it('passes the current default through unchanged', () => {
|
|
expect(migrateQueueToolbarButtons(DEFAULT_QUEUE_TOOLBAR_BUTTONS)).toEqual(DEFAULT_QUEUE_TOOLBAR_BUTTONS);
|
|
});
|
|
|
|
it('collapses legacy save + load into a single playlist button at the earlier position', () => {
|
|
const legacy = [
|
|
{ id: 'shuffle', visible: true },
|
|
{ id: 'save', visible: true },
|
|
{ id: 'load', visible: true },
|
|
{ id: 'share', visible: true },
|
|
{ id: 'clear', visible: true },
|
|
{ id: 'separator', visible: true },
|
|
{ id: 'gapless', visible: true },
|
|
{ id: 'crossfade', visible: true },
|
|
{ id: 'infinite', visible: true },
|
|
];
|
|
const out = migrateQueueToolbarButtons(legacy);
|
|
expect(ids(out)).toEqual([
|
|
'shuffle', 'playlist', 'share', 'clear', 'separator', 'gapless', 'crossfade', 'autodj', 'infinite',
|
|
]);
|
|
});
|
|
|
|
it('keeps playlist visible if either legacy save or load was visible', () => {
|
|
const out = migrateQueueToolbarButtons([
|
|
{ id: 'save', visible: false },
|
|
{ id: 'load', visible: true },
|
|
]);
|
|
expect(vis(out, 'playlist')).toBe(true);
|
|
|
|
const hidden = migrateQueueToolbarButtons([
|
|
{ id: 'save', visible: false },
|
|
{ id: 'load', visible: false },
|
|
]);
|
|
expect(vis(hidden, 'playlist')).toBe(false);
|
|
});
|
|
|
|
it('inserts autodj right after crossfade and inherits its visibility', () => {
|
|
const out = migrateQueueToolbarButtons([
|
|
{ id: 'crossfade', visible: false },
|
|
{ id: 'infinite', visible: true },
|
|
]);
|
|
const i = ids(out);
|
|
expect(i.indexOf('autodj')).toBe(i.indexOf('crossfade') + 1);
|
|
expect(vis(out, 'autodj')).toBe(false);
|
|
});
|
|
|
|
it('preserves a customised order', () => {
|
|
const out = migrateQueueToolbarButtons([
|
|
{ id: 'crossfade', visible: true },
|
|
{ id: 'shuffle', visible: true },
|
|
{ id: 'playlist', visible: true },
|
|
]);
|
|
// autodj follows crossfade, leading items keep their order, missing defaults appended.
|
|
expect(ids(out).slice(0, 4)).toEqual(['crossfade', 'autodj', 'shuffle', 'playlist']);
|
|
// every default id is present exactly once
|
|
for (const d of DEFAULT_QUEUE_TOOLBAR_BUTTONS) {
|
|
expect(ids(out).filter(x => x === d.id)).toHaveLength(1);
|
|
}
|
|
});
|
|
|
|
it('drops corrupt entries and tolerates non-array input', () => {
|
|
const out = migrateQueueToolbarButtons([
|
|
null,
|
|
{ id: 'shuffle', visible: true },
|
|
{ id: 123, visible: true },
|
|
{ id: 'bogus', visible: true },
|
|
{ visible: true },
|
|
]);
|
|
expect(ids(out)).toContain('shuffle');
|
|
expect(ids(out)).not.toContain('bogus');
|
|
// unknown/corrupt gone, defaults filled in
|
|
expect(ids(out).sort()).toEqual(DEFAULT_QUEUE_TOOLBAR_BUTTONS.map(b => b.id).sort());
|
|
|
|
expect(migrateQueueToolbarButtons(undefined)).toEqual(DEFAULT_QUEUE_TOOLBAR_BUTTONS);
|
|
});
|
|
});
|