Skip to content

Commit

Permalink
Updated to v2.1.0-stable.20230503
Browse files Browse the repository at this point in the history
- Added a new design for the song cards in Home page.
- Fixed a possible bug where media control buttons doesn't work as expected. Fixes #166.
- Removed predictive search when searching for artists, albums and genres in the SongTagsEditingPage.
  • Loading branch information
Sandakan committed May 3, 2023
1 parent 356f408 commit 0d0d39c
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 136 deletions.
Binary file modified assets/installer_assets/sidebar.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nora",
"productName": "Nora",
"description": "An elegant music player built using Electron and React. Inspired by Oto Music for Android by Piyush Mamidwar.",
"version": "2.1.0-stable.20230426",
"version": "2.1.0-stable.20230503",
"license": "MIT",
"appPreferences": {
"removeReactStrictMode": false,
Expand Down
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nora",
"productName": "Nora",
"version": "2.1.0-stable.20230426",
"version": "2.1.0-stable.20230503",
"description": "An elegant music player built using Electron and React. Inspired by Oto Music for Android by Piyush Mamidwar.",
"main": "./dist/main/main.js",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion release/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nora",
"productName": "Nora",
"version": "2.1.0-stable.20230426",
"version": "2.1.0-stable.20230503",
"description": "An elegant music player built using Electron and React. Inspired by Oto Music for Android by Piyush Mamidwar.",
"main": "./dist/main/main.js",
"author": {
Expand Down
101 changes: 57 additions & 44 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1297,50 +1297,6 @@ export default function App() {
};
}, [displayMessageFromMain]);

React.useEffect(() => {
if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: contentRef.current.currentSongData.title,
artist: Array.isArray(contentRef.current.currentSongData.artists)
? contentRef.current.currentSongData.artists
.map((artist) => artist.name)
.join(', ')
: `Unknown Artist`,
album: contentRef.current.currentSongData.album
? contentRef.current.currentSongData.album.name || 'Unknown Album'
: 'Unknown Album',
artwork: [
{
src: `data:;base64,${contentRef.current.currentSongData.artwork}`,
sizes: '300x300',
type: 'image/webp',
},
],
});
const handleSkipForwardClickWithParams = () =>
handleSkipForwardClick('PLAYER_SKIP');

navigator.mediaSession.setActionHandler('pause', () =>
toggleSongPlayback(false)
);
navigator.mediaSession.setActionHandler('play', () =>
toggleSongPlayback(true)
);
navigator.mediaSession.setActionHandler(
'previoustrack',
handleSkipBackwardClick
);
navigator.mediaSession.setActionHandler(
`nexttrack`,
handleSkipForwardClickWithParams
);
navigator.mediaSession.playbackState = content.player.isCurrentSongPlaying
? 'playing'
: 'paused';
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [content.currentSongData, content.player.isCurrentSongPlaying]);

const handleContextMenuVisibilityUpdate = React.useCallback(() => {
if (contentRef.current.contextMenuData.isVisible) {
dispatch({
Expand Down Expand Up @@ -1743,6 +1699,63 @@ export default function App() {
[toggleSongPlayback, changeQueueCurrentSongIndex]
);

React.useEffect(() => {
navigator.mediaSession.metadata = new MediaMetadata({
title: contentRef.current.currentSongData.title,
artist: Array.isArray(contentRef.current.currentSongData.artists)
? contentRef.current.currentSongData.artists
.map((artist) => artist.name)
.join(', ')
: `Unknown Artist`,
album: contentRef.current.currentSongData.album
? contentRef.current.currentSongData.album.name || 'Unknown Album'
: 'Unknown Album',
artwork: [
{
src: `data:;base64,${contentRef.current.currentSongData.artwork}`,
sizes: '300x300',
type: 'image/webp',
},
],
});
const handleSkipForwardClickWithParams = () =>
handleSkipForwardClick('PLAYER_SKIP');

navigator.mediaSession.setActionHandler('pause', () =>
toggleSongPlayback(false)
);
navigator.mediaSession.setActionHandler('play', () =>
toggleSongPlayback(true)
);
navigator.mediaSession.setActionHandler(
'previoustrack',
handleSkipBackwardClick
);
navigator.mediaSession.setActionHandler(
`nexttrack`,
handleSkipForwardClickWithParams
);
navigator.mediaSession.playbackState = content.player.isCurrentSongPlaying
? 'playing'
: 'paused';
return () => {
navigator.mediaSession.metadata = null;
navigator.mediaSession.playbackState = 'none';
navigator.mediaSession.setActionHandler('play', null);
navigator.mediaSession.setActionHandler('pause', null);
navigator.mediaSession.setActionHandler('seekbackward', null);
navigator.mediaSession.setActionHandler('seekforward', null);
navigator.mediaSession.setActionHandler('previoustrack', null);
navigator.mediaSession.setActionHandler('nexttrack', null);
};
}, [
content.currentSongData,
content.player.isCurrentSongPlaying,
handleSkipBackwardClick,
handleSkipForwardClick,
toggleSongPlayback,
]);

const toggleShuffling = React.useCallback((isShuffling?: boolean) => {
dispatch({ type: 'TOGGLE_SHUFFLE_STATE', data: isShuffling });
if (isShuffling !== undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function SongTagsEditingPage() {
React.useEffect(() => {
if (artistKeyword.trim()) {
window.api
.search('Artists', artistKeyword, false)
.search('Artists', artistKeyword, false, false)
.then((res) => {
console.log(res);
if (res.artists.length > 0)
Expand All @@ -141,7 +141,7 @@ function SongTagsEditingPage() {
React.useEffect(() => {
if (albumKeyword.trim()) {
window.api
.search('Albums', albumKeyword, false)
.search('Albums', albumKeyword, false, false)
.then((res) => {
console.log(res);
if (res.albums.length > 0)
Expand All @@ -165,7 +165,7 @@ function SongTagsEditingPage() {
React.useEffect(() => {
if (genreKeyword.trim()) {
window.api
.search('Genres', genreKeyword, false)
.search('Genres', genreKeyword, false, false)
.then((res) => {
console.log(res);
if (res.genres.length > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ const CurrentlyPlayingSongInfoContainer = () => {
currentSongData.isKnownSource,
]);

const contextMenuCurrrentSongData =
const contextMenuCurrentSongData =
React.useMemo((): ContextMenuAdditionalData => {
const { title, artworkPath, artists } = currentSongData;
return {
title,
artworkPath: artworkPath ?? DefaultSongCover,
subTitle:
artists?.map((artist) => artist.name).join(', ') ?? 'Unknonwn artist',
artists?.map((artist) => artist.name).join(', ') || 'Unknown artist',
// subTitle2: album?.name,
};
}, [currentSongData]);
Expand Down Expand Up @@ -302,7 +302,7 @@ const CurrentlyPlayingSongInfoContainer = () => {
contextMenuItems,
e.pageX,
e.pageY,
contextMenuCurrrentSongData
contextMenuCurrentSongData
);
}}
/>
Expand All @@ -327,7 +327,7 @@ const CurrentlyPlayingSongInfoContainer = () => {
contextMenuItems,
e.pageX,
e.pageY,
contextMenuCurrrentSongData
contextMenuCurrentSongData
);
}}
tabIndex={0}
Expand Down
Loading

0 comments on commit 0d0d39c

Please sign in to comment.