-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kevin Frei
committed
Jun 23, 2024
1 parent
64dba39
commit a4e73a3
Showing
17 changed files
with
176 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FlatAudioDatabase } from '@freik/audiodb'; | ||
import { | ||
Album, | ||
AlbumKey, | ||
Artist, | ||
ArtistKey, | ||
Song, | ||
SongKey, | ||
} from '@freik/media-core'; | ||
import { | ||
chkArrayOf, | ||
chkObjectOfType, | ||
isArrayOfString, | ||
isNumber, | ||
isString, | ||
} from '@freik/typechk'; | ||
|
||
export type SongMap = Map<SongKey, Song>; | ||
export type AlbumMap = Map<AlbumKey, Album>; | ||
export type ArtistMap = Map<ArtistKey, Artist>; | ||
export type MusicLibrary = { | ||
songs: SongMap; | ||
albums: AlbumMap; | ||
artists: ArtistMap; | ||
}; | ||
|
||
const isSong = chkObjectOfType<Song & { path?: string }>( | ||
{ | ||
key: isString, | ||
track: isNumber, | ||
title: isString, | ||
albumId: isString, | ||
artistIds: isArrayOfString, | ||
secondaryIds: isArrayOfString, | ||
}, | ||
{ path: isString, variations: isArrayOfString }, | ||
); | ||
|
||
const isAlbum = chkObjectOfType<Album>( | ||
{ | ||
key: isString, | ||
year: isNumber, | ||
title: isString, | ||
primaryArtists: isArrayOfString, | ||
songs: isArrayOfString, | ||
vatype: (o: unknown) => o === '' || o === 'ost' || o === 'va', | ||
}, | ||
{ | ||
diskNames: isArrayOfString, | ||
}, | ||
); | ||
|
||
const isArtist = chkObjectOfType<Artist>({ | ||
key: isString, | ||
name: isString, | ||
albums: isArrayOfString, | ||
songs: isArrayOfString, | ||
}); | ||
|
||
export const isFlatAudioDatabase = chkObjectOfType<FlatAudioDatabase>({ | ||
songs: chkArrayOf(isSong), | ||
albums: chkArrayOf(isAlbum), | ||
artists: chkArrayOf(isArtist), | ||
}); | ||
|
||
export const emptyLibrary = { | ||
songs: new Map<SongKey, Song>(), | ||
albums: new Map<AlbumKey, Album>(), | ||
artists: new Map<ArtistKey, Artist>(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Effects } from '@freik/electron-render'; | ||
import { atom } from 'recoil'; | ||
|
||
// const log = MakeLogger('ReadWrite'); | ||
// const err = MakeError('ReadWrite-err'); | ||
export const shuffleState = atom<boolean>({ | ||
key: 'shuffle', | ||
default: false, | ||
effects: [Effects.syncWithMain<boolean>()], | ||
}); | ||
|
||
export const repeatState = atom<boolean>({ | ||
key: 'repeat', | ||
default: false, | ||
effects: [Effects.syncWithMain<boolean>()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Effects } from '@freik/electron-render'; | ||
import { atom } from 'recoil'; | ||
|
||
// Only show artists in the list who appear on full albums | ||
|
||
export const showArtistsWithFullAlbumsState = atom({ | ||
key: 'FullAlbumsOnly', | ||
default: false, | ||
effects: [Effects.syncWithMain<boolean>()], | ||
}); | ||
// The minimum # of songs an artist needs to show up in the artist list | ||
|
||
export const minSongCountForArtistListState = atom({ | ||
key: 'MinSongCount', | ||
default: 1, | ||
effects: [Effects.syncWithMain<number>()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { AlbumKey, SongKey } from '@freik/media-core'; | ||
|
||
export type MetadataProps = { | ||
forSong?: SongKey; | ||
forSongs?: SongKey[]; | ||
artist?: string; | ||
album?: string; | ||
track?: string; | ||
title?: string; | ||
year?: string; | ||
va?: string; | ||
variations?: string; | ||
moreArtists?: string; | ||
albumId?: AlbumKey; | ||
diskName?: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Keys } from '@freik/emp-shared'; | ||
|
||
const HostOs: 'mac' | 'windows' | 'linux' = (() => { | ||
const ua = window.navigator.userAgent; | ||
if (ua.indexOf('Mac') >= 0) { | ||
return 'mac'; | ||
} | ||
if (ua.indexOf('Windows') >= 0) { | ||
return 'windows'; | ||
} | ||
return 'linux'; | ||
})(); | ||
|
||
const accPrefix = HostOs === 'mac' ? '⌘' : 'Ctrl'; | ||
|
||
export function GetHelperText(key: Keys) { | ||
if (key.length === 1) { | ||
return `${accPrefix}-${key}`; | ||
} | ||
if (key === Keys.PreviousTrack) { | ||
return accPrefix + '-←'; | ||
} | ||
if (key === Keys.NextTrack) { | ||
return accPrefix + '-→'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.