diff --git a/package.json b/package.json index 730555ee..a9b68b5e 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "repository": "Superjo149/auryo", "homepage": "http://auryo.com", "productName": "Auryo", - "version": "2.3.0", + "version": "2.3.1", "author": { "name": "Jonas Snellinckx", "email": "jonas.snellinckx@gmail.com" diff --git a/src/common/store/objects/reducer.ts b/src/common/store/objects/reducer.ts index 9bdc5708..9a60eda3 100755 --- a/src/common/store/objects/reducer.ts +++ b/src/common/store/objects/reducer.ts @@ -122,11 +122,13 @@ const objectGroup: Reducer = (state = initialObjectGroupState, acti case onSuccess(ObjectsActionTypes.SET_TRACKS): case isLoading(ObjectsActionTypes.SET_TRACKS): case ObjectsActionTypes.UNSET_TRACK: + if (!payload.objectId) return state; return { ...state, [String(payload.objectId)]: objectState(state[String(payload.objectId)], action) }; case onSuccess(AuthActionTypes.SET_LIKE): + if (!payload.playlist) return state; return { ...state, [playlistName]: objectState(state[playlistName], action) diff --git a/src/common/store/objects/selectors.ts b/src/common/store/objects/selectors.ts index b9b73f03..2bb0d283 100644 --- a/src/common/store/objects/selectors.ts +++ b/src/common/store/objects/selectors.ts @@ -23,7 +23,7 @@ export const getPlaylistName = (id: string, playlistType: PlaylistTypes) => [id, export const getPlaylistType = (objectId: string): PlaylistTypes | null => { - if (!objectId) return null; + if (!objectId || typeof objectId !== 'string') return null; if (objectId in PlaylistTypes) { return objectId as PlaylistTypes; diff --git a/src/common/store/player/actions.ts b/src/common/store/player/actions.ts index f354c108..b6095328 100755 --- a/src/common/store/player/actions.ts +++ b/src/common/store/player/actions.ts @@ -146,6 +146,10 @@ export function setCurrentPlaylist(playlistId: string, nextTrack: PlayingTrack | const [items, originalItems] = await dispatch>(processQueueItems(playlistObject.items, true, playlistId)); + if (nextTrack && !nextTrack.id) { + await dispatch(fetchPlaylistIfNeeded(+nextTrack.playlistId)); + } + return dispatch>({ type: PlayerActionTypes.SET_PLAYLIST, payload: { @@ -312,12 +316,13 @@ export function addUpNext(track: SoundCloud.Track | SoundCloud.Playlist, remove? un: Date.now() }; - let nextList; + let nextList: Array = []; if (isPlaylist) { const playlist = track as SoundCloud.Playlist; + const { tracks = [] } = playlist; - nextList = playlist.tracks.map((t) => { + nextList = tracks.map((t): PlayingTrack | null => { if (!SC.isStreamable(t)) { return null; @@ -325,10 +330,10 @@ export function addUpNext(track: SoundCloud.Track | SoundCloud.Playlist, remove? return { id: t.id, - playlistId: track.id, + playlistId: track.id.toString(), un: Date.now() }; - }).filter((t) => t != null); + }).filter((t) => t) as Array; } if (queue.length) { @@ -565,7 +570,7 @@ export function playTrack(playlistId: string, next: Next, force_set_playlist: bo playlistEntitity.track_count !== 0 ) { throw new Error('This playlist is empty or not available via a third party!'); - } else { + } else if (trackPlaylistObject.items.length) { // If queue doesn't contain playlist yet if (force_set_playlist) { @@ -663,6 +668,11 @@ export function registerPlay(): ThunkResult { track_urn: `soundcloud:tracks:${id}` }; + import('../../../common/utils/universalAnalytics') + .then(({ ua }) => { + ua.event('SoundCloud', 'Play', '', id).send(); + }); + const type = getPlaylistType(playlistId); if (!type || !(type in PlaylistTypes)) { diff --git a/src/renderer/_shared/WithHeaderComponent.tsx b/src/renderer/_shared/WithHeaderComponent.tsx index 1a8ad655..68ca4a43 100644 --- a/src/renderer/_shared/WithHeaderComponent.tsx +++ b/src/renderer/_shared/WithHeaderComponent.tsx @@ -34,7 +34,9 @@ class WithHeaderComponent

extends React.Compon if (previousScrollTop && this.scroll) { requestAnimationFrame(() => { - this.scroll!.updateScrollPosition(previousScrollTop); + if (this.scroll) { + this.scroll.updateScrollPosition(previousScrollTop); + } }); } } diff --git a/src/renderer/app/components/modals/UtilitiesModel/SettingsTab/components/InputConfig.tsx b/src/renderer/app/components/modals/UtilitiesModel/SettingsTab/components/InputConfig.tsx index 1c1f9efd..47ff79d9 100644 --- a/src/renderer/app/components/modals/UtilitiesModel/SettingsTab/components/InputConfig.tsx +++ b/src/renderer/app/components/modals/UtilitiesModel/SettingsTab/components/InputConfig.tsx @@ -35,12 +35,14 @@ class InputConfig extends React.PureComponent { handleChange = (event: React.FormEvent) => { const { configKey, onChange, setConfigKey } = this.props; + const value = event.currentTarget.value; + if (onChange) { - onChange(event.currentTarget.value, () => { - setConfigKey(configKey, event.currentTarget.value); + onChange(value, () => { + setConfigKey(configKey, value); }); } else { - setConfigKey(configKey, event.currentTarget.value); + setConfigKey(configKey, value); } } diff --git a/src/renderer/index.tsx b/src/renderer/index.tsx index 2b9406ad..309fb6eb 100755 --- a/src/renderer/index.tsx +++ b/src/renderer/index.tsx @@ -29,19 +29,20 @@ if (!process.env.TOKEN && process.env.NODE_ENV === 'production') { const { config: { app: { analytics } } } = store.getState(); - if (analytics) { - import('../common/utils/universalAnalytics') - .then(({ ua }) => { - ua.set('version', app.getVersion()); - ua.set('anonymizeIp', true); + import('../common/utils/universalAnalytics') + .then(({ ua }) => { + ua.set('version', app.getVersion()); + ua.set('anonymizeIp', true); + if (analytics) { ua.pv('/').send(); history.listen((location) => { ua.pv(location.pathname).send(); }); - }); - } + } + }); + } const { config: { token } } = store.getState();