Skip to content

Commit bcfd1d9

Browse files
committed
refactor: small code optimizations
1 parent 8d95b79 commit bcfd1d9

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

src/auto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Snapshot, Settings, AutoMode, QueueUpdateEvent, OnProgressEvent } from "./types";
1+
import type { Snapshot, Settings, AutoMode, QueueUpdateEvent, OnProgressEvent } from "./types";
22
import { getQueueFromSpicetify } from "./queue";
33
import { areQueuesEqual, generateId } from "./utils";
44
import { addSnapshot, getSortedSnapshots, loadSnapshots, saveSnapshots, saveSettings } from "./storage";

src/dialogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ButtonTone } from "./types";
1+
import type { ButtonTone } from "./types";
22
import { t } from "./i18n";
33

44
type ConfirmDialogOptions = {

src/exporter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Snapshot } from "./types";
1+
import type { Snapshot } from "./types";
22
import { getSnapshotDisplayName, getSnapshotGeneratedNameFor } from "./names";
33
import { getQueueFromSpicetify } from "./queue";
44
import { addSnapshot, loadSettings } from "./storage";
@@ -202,17 +202,17 @@ export async function appendSnapshotToQueue(snapshot: Snapshot, buttonEl?: HTMLB
202202
}
203203
}
204204

205-
export async function replaceQueueWithSnapshot(snapshot: Snapshot, buttonEl?: HTMLButtonElement, uiHandlers?: UIHandlers): Promise<boolean> {
205+
export async function replaceQueueWithSnapshot(snapshot: Snapshot, buttonEl?: HTMLButtonElement, uiHandlers?: UIHandlers): Promise<void> {
206206
try {
207207
if (!snapshot.items.length) {
208208
showWarningToast(t('toasts.snapshotEmpty'));
209-
return false;
209+
return;
210210
}
211211

212212
// Check if the current queue already matches the snapshot - if so, skip replacement
213213
const currentQueue = getQueueFromSpicetify();
214214
if (areQueuesEqual(currentQueue, snapshot.items)) {
215-
return false;
215+
return;
216216
}
217217

218218
// Prompt to save current queue before activation if this is a synced snapshot being activated
@@ -228,7 +228,7 @@ export async function replaceQueueWithSnapshot(snapshot: Snapshot, buttonEl?: HT
228228
tone: "primary",
229229
});
230230
if (shouldSave === "extra") {
231-
return false;
231+
return;
232232
}
233233
if (shouldSave === "confirm") {
234234
await createManualSnapshot();

src/importer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { showConfirmDialog } from "./dialogs";
22
import { loadSnapshots, saveSnapshots } from "./storage";
33
import { showErrorToast, showSuccessToast } from "./toast";
4-
import { Settings, Snapshot } from "./types";
4+
import type { Settings, Snapshot } from "./types";
55
import { uploadJson } from "./utils";
66
import { renderList, renderSettings } from "./ui";
7-
import { UIHandlers } from "./ui";
7+
import type { UIHandlers } from "./ui";
88
import { t } from "./i18n";
99

1010
function isValidSnapshot(s: any): s is Snapshot {

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Settings } from "./types";
1+
import type { Settings } from "./types";
22
import { loadSettings, saveSettings } from "./storage";
3-
import { openManagerModal, UIHandlers } from "./ui";
3+
import { openManagerModal, type UIHandlers } from "./ui";
44
import { createAutoManager, createQueueCapacityWatcher, createQueueSyncManager } from "./auto";
55
import { APP_NAME } from "./appInfo";
66
import { t } from "./i18n";

src/queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function getQueueFromSpicetify(): string[] {
2828
if (current) list.push(current);
2929

3030
const nextArr = q?.nextTracks || [];
31-
let queuedCount = 0;
31+
// let queuedCount = 0;
3232
for (const it of Array.isArray(nextArr) ? nextArr : []) {
3333
const provider: string | undefined = it?.provider;
3434
const meta = it?.contextTrack?.metadata || it?.metadata;
@@ -38,7 +38,7 @@ export function getQueueFromSpicetify(): string[] {
3838
const uri = getTrackUri(it);
3939
if (uri) {
4040
list.push(uri);
41-
queuedCount++;
41+
// queuedCount++;
4242
}
4343
}
4444
const out = list.length ? dedupeConsecutive(list) : [];

src/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Settings, Snapshot } from "./types";
1+
import type { Settings, Snapshot } from "./types";
22

33
const SETTINGS_KEY = "queue-manager:settings";
44
const DEFAULT_SETTINGS: Settings = {

src/ui.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./ui.css";
22

3-
import { Snapshot, Settings, ButtonRenderOptions, BadgeVariant } from "./types";
3+
import type { Snapshot, Settings, ButtonRenderOptions, BadgeVariant } from "./types";
44
import { loadSnapshots, pruneAutosToMax, saveSnapshots, clearAutoSnapshots, loadSettings, saveSettings, getSyncedSnapshots } from "./storage";
55
import { getSnapshotItemNames, getSnapshotDisplayName, getSnapshotGeneratedNameFor } from "./names";
66
import { escapeHtml, downloadJson, setButtonLabel, getIconMarkup, setButtonIcon, generateId, areQueuesEqual } from "./utils";
@@ -9,7 +9,7 @@ import { createManualSnapshot, exportSnapshotToPlaylist, replaceQueueWithSnapsho
99
import { APP_CHANNEL, APP_NAME, APP_NAME_SLUG, APP_VERSION } from "./appInfo";
1010
import { getSortedSnapshots } from "./storage";
1111
import { showConfirmDialog, showPromptDialog } from "./dialogs";
12-
import { createQueueSyncManager } from "./auto";
12+
import type { createQueueSyncManager } from "./auto";
1313
import { importSettings, importSnapshots } from "./importer";
1414
import { t, refreshLocale } from "./i18n";
1515
import { getQueueFromSpicetify } from "./queue";

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { APP_NAME } from "./appInfo";
2-
import { showErrorToast, showSuccessToast, showWarningToast } from "./toast";
2+
import { showErrorToast, showSuccessToast } from "./toast";
33
import { t } from "./i18n";
44
export const DEFAULT_ICON_SIZE = 16;
55

0 commit comments

Comments
 (0)