feat(quick-7): wire frontend pin-default-playlist feature end-to-end

- Add pinDefault state, getter, setter to favorites-store
- Add pinDefault getter and setPinDefault to favorites-controller
- Update sortedEntries in playlist-view to pin default playlist to top
- Add Pin to Top toggle in config page Favorites section
- Add Wails bindings for GetPinDefaultPlaylist/SetPinDefaultPlaylist
- React to PinDefault in FavoritesConfigChanged event payload
This commit is contained in:
2026-03-01 10:06:56 -05:00
parent 6e123bd47f
commit e6378e1f0d
6 changed files with 90 additions and 4 deletions
@@ -69,6 +69,10 @@ export class FavoritesController
return favoritesStore.getPlaylistId();
}
get pinDefault(): boolean {
return favoritesStore.getPinDefault();
}
/**
* Returns the icon name for the current icon style.
*/
@@ -113,4 +117,10 @@ export class FavoritesController
): Promise<void> {
await favoritesStore.setDefaultPlaylist(id);
}
async setPinDefault(
pin: boolean,
): Promise<void> {
await favoritesStore.setPinDefault(pin);
}
}
+25 -4
View File
@@ -9,8 +9,10 @@ import {
import {
GetFavoritesIconStyle,
GetFavoritesPlaylistID,
GetPinDefaultPlaylist,
SetFavoritesIconStyle,
SetFavoritesPlaylistID,
SetPinDefaultPlaylist,
} from '@go/config/Config';
import { Events } from '../events';
@@ -29,6 +31,7 @@ class FavoritesStore {
private playlistId = 0;
private playlistName = 'Favorites';
private iconStyle: IconStyle = 'heart';
private pinDefault = true;
private favoritedPaths = new Set<string>();
private subscribers = new Set<Subscriber>();
private loading = false;
@@ -44,10 +47,13 @@ class FavoritesStore {
(data: {
PlaylistID: number;
IconStyle: string;
PinDefault: boolean;
}) => {
this.playlistId = data.PlaylistID;
this.iconStyle =
data.IconStyle as IconStyle;
this.pinDefault = data.PinDefault;
this.notify();
void this.loadPlaylistName();
void this.loadPaths();
},
@@ -119,6 +125,10 @@ class FavoritesStore {
return this.playlistId;
}
getPinDefault(): boolean {
return this.pinDefault;
}
isLoading(): boolean {
return this.loading;
}
@@ -203,6 +213,14 @@ class FavoritesStore {
await this.loadPaths();
}
async setPinDefault(
pin: boolean,
): Promise<void> {
this.pinDefault = pin;
this.notify();
await SetPinDefaultPlaylist(pin);
}
// ===============================================================
// SUBSCRIPTION SYSTEM
// ===============================================================
@@ -223,13 +241,16 @@ class FavoritesStore {
private async loadConfig(): Promise<void> {
try {
const [id, style] = await Promise.all([
GetFavoritesPlaylistID(),
GetFavoritesIconStyle(),
]);
const [id, style, pin] =
await Promise.all([
GetFavoritesPlaylistID(),
GetFavoritesIconStyle(),
GetPinDefaultPlaylist(),
]);
this.playlistId = id;
this.iconStyle = style as IconStyle;
this.pinDefault = pin;
await this.loadPlaylistName();
this.notify();
} catch {