Skip to content

Commit 2a10a97

Browse files
committed
refactor: move BadgeVariant to types
1 parent e254841 commit 2a10a97

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export type Settings = {
2222
promptManualBeforeReplace: boolean;
2323
};
2424

25+
export type BadgeVariant = "default" | "accent" | "version" | "channel";
26+
2527
export type ButtonTone = "primary" | "danger" | "subtle" | "default";
2628

2729
export type ButtonRenderOptions = {

src/ui.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Snapshot, Settings, ButtonTone, ButtonRenderOptions } from "./types";
2-
import { loadSnapshots, pruneAutosToMax, saveSettings, saveSnapshots } from "./storage";
1+
import "./ui.css";
2+
3+
import { Snapshot, Settings, ButtonRenderOptions, BadgeVariant } from "./types";
4+
import { loadSnapshots, pruneAutosToMax, saveSnapshots } from "./storage";
35
import { getSnapshotItemNames, getSnapshotDisplayName } from "./names";
46
import { escapeHtml, downloadJson, setButtonLabel } from "./utils";
57
import { createManualSnapshot, exportSnapshotToPlaylist } from "./exporter";
68
import { replaceQueueWithSnapshot } from "./exporter";
79
import { APP_CHANNEL, APP_NAME, APP_VERSION } from "./appInfo";
8-
import "./ui.css";
910
import { getSortedSnapshots } from "./storage";
1011

1112
export type UIHandlers = {
@@ -45,8 +46,6 @@ function renderActionIconButton(action: string, icon: Spicetify.Icon, title: str
4546
return `<button type="button" class="qs-icon-btn" data-action="${escapeHtml(action)}" title="${escapeHtml(title)}">${getIconMarkup(icon)}</button>`;
4647
}
4748

48-
type BadgeVariant = "default" | "accent" | "version" | "channel";
49-
5049
function renderBadge(text: string, variant: BadgeVariant = "default"): string {
5150
const classes = ["qs-pill"];
5251
if (variant !== "default") {
@@ -345,7 +344,6 @@ export function openManagerModal(ui: UIHandlers): void {
345344
if (!action) return;
346345

347346
if (action === "toggle-items") {
348-
e.preventDefault();
349347
const itemsEl = rowEl.nextElementSibling as HTMLElement | null;
350348
const btn = clickedButton;
351349
if (!itemsEl || !itemsEl.classList.contains("qs-items")) return;
@@ -371,19 +369,16 @@ export function openManagerModal(ui: UIHandlers): void {
371369
}
372370
return;
373371
}
374-
375372
if (action === "export") {
376373
if (exportingIds.has(id)) return;
377374
exportingIds.add(id);
378-
const btn = clickedButton;
379-
await exportSnapshotToPlaylist(snap, btn);
375+
await exportSnapshotToPlaylist(snap, clickedButton);
380376
exportingIds.delete(id);
381377
return;
382378
}
383379
if (action === "replace-queue") {
384380
if (exportingIds.has(id)) return;
385381
exportingIds.add(id);
386-
const btn = clickedButton;
387382
try {
388383
const settings = ui.getSettings();
389384
if (settings.promptManualBeforeReplace) {
@@ -393,7 +388,7 @@ export function openManagerModal(ui: UIHandlers): void {
393388
renderList();
394389
}
395390
}
396-
await replaceQueueWithSnapshot(snap, btn);
391+
await replaceQueueWithSnapshot(snap, clickedButton);
397392
} finally {
398393
exportingIds.delete(id);
399394
}

0 commit comments

Comments
 (0)