Skip to content

Commit

Permalink
Type casts to work around new electron-store typings
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Jan 18, 2025
1 parent 3926041 commit a350ef8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/services/@linux/system-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class LinuxMediaService extends MprisService implements NuclearApi {

this.tracks = [];
const storedPlaylists = this.store.get('playlists');
this.setPlaylists(storedPlaylists ? storedPlaylists.map(this.playlistMapper) : []);
this.setPlaylists(storedPlaylists ? (storedPlaylists as []).map(this.playlistMapper) : []);
}

private getPlayingStatus(): Promise<NuclearStatus> {
Expand Down
15 changes: 14 additions & 1 deletion packages/main/src/services/http/server/api/equalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ import { IpcEvents } from '@nuclear/core';

const { validate } = new Validator({ allErrors: true });

type Preset = {
label: string
id: string
values: number[]
preAmp: number
}

type EqualizerPresetList = {
presets: {
[id: string]: Preset;
}
}

export function equalizerRouter(store: Store, rendererWindow: BrowserWindow['webContents']): ISwaggerizedRouter {
const router = express.Router() as ISwaggerizedRouter;

Expand All @@ -33,7 +46,7 @@ export function equalizerRouter(store: Store, rendererWindow: BrowserWindow['web
}));

router.post('/:eqName/set', (req, res) => {
const equalizerNames = Object.keys(store.get('equalizer').presets);
const equalizerNames = Object.keys((store.get('equalizer') as EqualizerPresetList).presets);

if (!equalizerNames.includes(req.params.eqName)) {
res.status(400).send(`name should be one of ${equalizerNames.toString()}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/services/http/server/api/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function playlistRouter(store: Store, rendererWindow: BrowserWindow['webC
router
.delete('/:name', (req, res, next) => {
try {
const playlists: NuclearPlaylist[] = store.get('playlists');
const playlists: NuclearPlaylist[] = store.get('playlists') as NuclearPlaylist[];

store.set('playlists', playlists.filter(({ name }) => name !== req.params.name));
rendererWindow.send(IpcEvents.PLAYLIST_REFRESH);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/services/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Store extends ElectronStore {
}

getLastThumbCleanDate(): Date | undefined {
const time = this.get('last-thumb-clean-date');
const time = this.get('last-thumb-clean-date') as number;

if (time) {
return new Date(time);
Expand Down

0 comments on commit a350ef8

Please sign in to comment.