Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sneljo1 committed Dec 16, 2018
1 parent 6baf137 commit a967fde
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]"
Expand Down
2 changes: 2 additions & 0 deletions src/common/store/objects/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ const objectGroup: Reducer<ObjectGroup> = (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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/store/objects/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 15 additions & 5 deletions src/common/store/player/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export function setCurrentPlaylist(playlistId: string, nextTrack: PlayingTrack |
const [items, originalItems] = await
dispatch<Promise<ProcessedQueueItems>>(processQueueItems(playlistObject.items, true, playlistId));

if (nextTrack && !nextTrack.id) {
await dispatch(fetchPlaylistIfNeeded(+nextTrack.playlistId));
}

return dispatch<Promise<any>>({
type: PlayerActionTypes.SET_PLAYLIST,
payload: {
Expand Down Expand Up @@ -312,23 +316,24 @@ export function addUpNext(track: SoundCloud.Track | SoundCloud.Playlist, remove?
un: Date.now()
};

let nextList;
let nextList: Array<PlayingTrack> = [];

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;
}

return {
id: t.id,
playlistId: track.id,
playlistId: track.id.toString(),
un: Date.now()
};
}).filter((t) => t != null);
}).filter((t) => t) as Array<PlayingTrack>;
}

if (queue.length) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -663,6 +668,11 @@ export function registerPlay(): ThunkResult<void> {
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)) {
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/_shared/WithHeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class WithHeaderComponent<P extends Props, S extends State> extends React.Compon

if (previousScrollTop && this.scroll) {
requestAnimationFrame(() => {
this.scroll!.updateScrollPosition(previousScrollTop);
if (this.scroll) {
this.scroll.updateScrollPosition(previousScrollTop);
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ class InputConfig extends React.PureComponent<Props> {
handleChange = (event: React.FormEvent<HTMLInputElement>) => {
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);
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a967fde

Please sign in to comment.