mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Make let, not var
This commit is contained in:
parent
ddfe9ccb03
commit
f6d0db1b4f
26 changed files with 86 additions and 86 deletions
|
@ -55,7 +55,7 @@
|
|||
|
||||
ready() {
|
||||
// The app has just been initialized, check if we can get the user data with an already existing token
|
||||
var token = ls.get('jwt-token');
|
||||
let token = ls.get('jwt-token');
|
||||
if (token) {
|
||||
this.authenticated = true;
|
||||
this.init();
|
||||
|
@ -285,7 +285,7 @@
|
|||
return arr;
|
||||
}
|
||||
|
||||
var order = (reverse && reverse < 0) ? -1 : 1;
|
||||
let order = (reverse && reverse < 0) ? -1 : 1;
|
||||
|
||||
// sort on a copy to avoid mutating original array
|
||||
return arr.slice().sort((a, b) => {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
// Re-init the app.
|
||||
this.$root.init();
|
||||
}, error => {
|
||||
var msg = 'Unknown error.';
|
||||
let msg = 'Unknown error.';
|
||||
|
||||
if (error.status === 422) {
|
||||
msg = utils.parseValidationError(error.data)[0];
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
var songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
|
||||
let songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
|
||||
|
||||
if (!songs.length) {
|
||||
return false;
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
var songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
|
||||
let songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
|
||||
|
||||
if (!songs.length) {
|
||||
return false;
|
||||
|
|
|
@ -59,12 +59,12 @@
|
|||
* Allow dragging the album (actually, its songs).
|
||||
*/
|
||||
dragStart(e) {
|
||||
var songIds = _.pluck(this.album.songs, 'id');
|
||||
let songIds = _.pluck(this.album.songs, 'id');
|
||||
e.dataTransfer.setData('text/plain', songIds);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
|
||||
// Set a fancy drop image using our ghost element.
|
||||
var $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} in ${this.album.name}`);
|
||||
let $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} in ${this.album.name}`);
|
||||
e.dataTransfer.setDragImage($ghost[0], 0, 0);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -49,12 +49,12 @@
|
|||
* Allow dragging the artist (actually, their songs).
|
||||
*/
|
||||
dragStart(e) {
|
||||
var songIds = _.pluck(artistStore.getSongsByArtist(this.artist), 'id');
|
||||
let songIds = _.pluck(artistStore.getSongsByArtist(this.artist), 'id');
|
||||
e.dataTransfer.setData('text/plain', songIds);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
|
||||
// Set a fancy drop image using our ghost element.
|
||||
var $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} by ${this.artist.name}`);
|
||||
let $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} by ${this.artist.name}`);
|
||||
e.dataTransfer.setDragImage($ghost[0], 0, 0);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
* Execute the corresponding reaction(s) when the user presses Delete.
|
||||
*/
|
||||
handleDelete() {
|
||||
var songs = this.selectedSongs;
|
||||
let songs = this.selectedSongs;
|
||||
|
||||
if (!songs.length) {
|
||||
return;
|
||||
|
@ -151,7 +151,7 @@
|
|||
* @param {Object} e The keydown event.
|
||||
*/
|
||||
handleEnter(e) {
|
||||
var songs = this.selectedSongs;
|
||||
let songs = this.selectedSongs;
|
||||
|
||||
if (!songs.length) {
|
||||
return;
|
||||
|
@ -240,8 +240,8 @@
|
|||
* @return {Array.<Object>} An array of Song objects
|
||||
*/
|
||||
gatherSelected() {
|
||||
var selectedRows = _.where(this.$refs.rows, { selected: true });
|
||||
var ids = _.map(selectedRows, row => row.song.id);
|
||||
let selectedRows = _.where(this.$refs.rows, { selected: true });
|
||||
let ids = _.map(selectedRows, row => row.song.id);
|
||||
|
||||
this.selectedSongs = songStore.byIds(ids);
|
||||
},
|
||||
|
@ -261,7 +261,7 @@
|
|||
* @param {Object} e
|
||||
*/
|
||||
rowClick(songId, e) {
|
||||
var row = this.getComponentBySongId(songId);
|
||||
let row = this.getComponentBySongId(songId);
|
||||
|
||||
// If we're on a touch device, or if Ctrl/Cmd key is pressed, just toggle selection.
|
||||
if (isMobile.any) {
|
||||
|
@ -302,9 +302,9 @@
|
|||
selectRowsBetweenIndexes(indexes) {
|
||||
indexes.sort((a, b) => a - b);
|
||||
|
||||
var rows = $(this.$els.wrapper).find('tbody tr');
|
||||
let rows = $(this.$els.wrapper).find('tbody tr');
|
||||
|
||||
for (var i = indexes[0]; i <= indexes[1]; ++i) {
|
||||
for (let i = indexes[0]; i <= indexes[1]; ++i) {
|
||||
this.getComponentBySongId($(rows[i - 1]).data('song-id')).select();
|
||||
}
|
||||
},
|
||||
|
@ -326,7 +326,7 @@
|
|||
*/
|
||||
dragStart(songId, e) {
|
||||
// If the user is dragging an unselected row, clear the current selection.
|
||||
var currentRow = this.getComponentBySongId(songId);
|
||||
let currentRow = this.getComponentBySongId(songId);
|
||||
if (!currentRow.selected) {
|
||||
this.clearSelection();
|
||||
currentRow.select();
|
||||
|
@ -336,12 +336,12 @@
|
|||
this.$nextTick(() => {
|
||||
// We can opt for something like application/x-koel.text+plain here to sound fancy,
|
||||
// but forget it.
|
||||
var songIds = _.pluck(this.selectedSongs, 'id');
|
||||
let songIds = _.pluck(this.selectedSongs, 'id');
|
||||
e.dataTransfer.setData('text/plain', songIds);
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
|
||||
// Set a fancy drop image using our ghost element.
|
||||
var $ghost = $('#dragGhost').text(`${songIds.length} song${songIds.length === 1 ? '' : 's'}`);
|
||||
let $ghost = $('#dragGhost').text(`${songIds.length} song${songIds.length === 1 ? '' : 's'}`);
|
||||
e.dataTransfer.setDragImage($ghost[0], 0, 0);
|
||||
});
|
||||
},
|
||||
|
@ -378,7 +378,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
var songs = this.selectedSongs;
|
||||
let songs = this.selectedSongs;
|
||||
|
||||
if (!songs.length) {
|
||||
return false;
|
||||
|
@ -400,7 +400,7 @@
|
|||
|
||||
openContextMenu(songId, e) {
|
||||
// If the user is right-click an unselected row, clear the current selection and select it instead.
|
||||
var currentRow = this.getComponentBySongId(songId);
|
||||
let currentRow = this.getComponentBySongId(songId);
|
||||
if (!currentRow.selected) {
|
||||
this.clearSelection();
|
||||
currentRow.select();
|
||||
|
@ -427,8 +427,8 @@
|
|||
|
||||
// Scroll the item into view if it's lost into oblivion.
|
||||
if (this.type === 'queue') {
|
||||
var $wrapper = $(this.$els.wrapper);
|
||||
var $row = $wrapper.find(`.song-item[data-song-id="${song.id}"]`);
|
||||
let $wrapper = $(this.$els.wrapper);
|
||||
let $row = $wrapper.find(`.song-item[data-song-id="${song.id}"]`);
|
||||
|
||||
if (!$row.length) {
|
||||
return;
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
*/
|
||||
ready() {
|
||||
$(this.$el).find('.has-sub').hover(e => {
|
||||
var $submenu = $(e.target).find('.submenu:first');
|
||||
let $submenu = $(e.target).find('.submenu:first');
|
||||
if (!$submenu.length) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* Navigate down the result list.
|
||||
*/
|
||||
down(e) {
|
||||
var selected = $(this.$el).find('.result li.selected');
|
||||
let selected = $(this.$el).find('.result li.selected');
|
||||
|
||||
if (!selected.length || !selected.removeClass('selected').next('li').addClass('selected').length) {
|
||||
$(this.$el).find('.result li:first').addClass('selected');
|
||||
|
@ -56,7 +56,7 @@
|
|||
* Navigate up the result list.
|
||||
*/
|
||||
up(e) {
|
||||
var selected = $(this.$el).find('.result li.selected');
|
||||
let selected = $(this.$el).find('.result li.selected');
|
||||
|
||||
if (!selected.length || !selected.removeClass('selected').prev('li').addClass('selected').length) {
|
||||
$(this.$el).find('.result li:last').addClass('selected');
|
||||
|
@ -121,13 +121,13 @@
|
|||
* @param {boolean} alignTop Whether the item should be aligned to top of its container.
|
||||
*/
|
||||
scrollSelectedIntoView(alignTop) {
|
||||
var elem = $(this.$el).find('.result li.selected')[0];
|
||||
let elem = $(this.$el).find('.result li.selected')[0];
|
||||
if (!elem) {
|
||||
return;
|
||||
}
|
||||
|
||||
var elemRect = elem.getBoundingClientRect();
|
||||
var containerRect = elem.offsetParent.getBoundingClientRect();
|
||||
let elemRect = elem.getBoundingClientRect();
|
||||
let containerRect = elem.offsetParent.getBoundingClientRect();
|
||||
|
||||
if (elemRect.bottom > containerRect.bottom || elemRect.top < containerRect.top) {
|
||||
elem.scrollIntoView(alignTop);
|
||||
|
|
|
@ -66,27 +66,27 @@
|
|||
* @param {Element} player The audio player's DOM.
|
||||
*/
|
||||
init(player) {
|
||||
var settings = equalizerStore.get();
|
||||
let settings = equalizerStore.get();
|
||||
|
||||
var AudioContext = window.AudioContext || window.webkitAudioContext || false;
|
||||
let AudioContext = window.AudioContext || window.webkitAudioContext || false;
|
||||
|
||||
if (!AudioContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
var context = new AudioContext();
|
||||
let context = new AudioContext();
|
||||
|
||||
this.preampGainNode = context.createGain();
|
||||
this.changePreampGain(settings.preamp);
|
||||
|
||||
var source = context.createMediaElementSource(player);
|
||||
let source = context.createMediaElementSource(player);
|
||||
source.connect(this.preampGainNode);
|
||||
|
||||
var prevFilter = null;
|
||||
let prevFilter = null;
|
||||
|
||||
// Create 10 bands with the frequencies similar to those of Winamp and connect them together.
|
||||
[60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000].forEach((f, i) => {
|
||||
var filter = context.createBiquadFilter();
|
||||
let filter = context.createBiquadFilter();
|
||||
|
||||
if (i === 0) {
|
||||
filter.type = 'lowshelf';
|
||||
|
@ -185,7 +185,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var preset = this.presets[this.selectedPresetIndex];
|
||||
let preset = this.presets[this.selectedPresetIndex];
|
||||
|
||||
$('#equalizer input[type=range]').each((i, input) => {
|
||||
// We treat our preamp slider differently.
|
||||
|
|
|
@ -8,7 +8,7 @@ export default function (value) {
|
|||
return;
|
||||
}
|
||||
|
||||
var el = this.el;
|
||||
let el = this.el;
|
||||
|
||||
Vue.nextTick(() => el.focus());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,14 +2,14 @@ import Vue from 'vue';
|
|||
import ls from './services/ls';
|
||||
import NProgress from 'nprogress';
|
||||
|
||||
var app = new Vue(require('./app.vue'));
|
||||
let app = new Vue(require('./app.vue'));
|
||||
|
||||
Vue.config.debug = false;
|
||||
Vue.use(require('vue-resource'));
|
||||
Vue.http.options.root = '/api';
|
||||
Vue.http.interceptors.push({
|
||||
request(r) {
|
||||
var token = ls.get('jwt-token');
|
||||
let token = ls.get('jwt-token');
|
||||
|
||||
if (token) {
|
||||
Vue.http.headers.common.Authorization = `Bearer ${token}`;
|
||||
|
|
|
@ -17,7 +17,7 @@ export default {
|
|||
|
||||
methods: {
|
||||
scrolling(e) {
|
||||
var $wrapper = $(this.$els.wrapper);
|
||||
let $wrapper = $(this.$els.wrapper);
|
||||
|
||||
// Here we check if the user has scrolled to the end of the wrapper (or 32px to the end).
|
||||
// If that's true, load more items.
|
||||
|
|
|
@ -2,7 +2,7 @@ import ls from 'local-storage';
|
|||
|
||||
export default {
|
||||
get(key, defaultVal = null) {
|
||||
var val = ls(key);
|
||||
let val = ls(key);
|
||||
|
||||
return val ? val : defaultVal;
|
||||
},
|
||||
|
|
|
@ -67,12 +67,12 @@ export default {
|
|||
}
|
||||
|
||||
// The current song has only 10 seconds left to play.
|
||||
var nextSong = queueStore.getNextSong();
|
||||
let nextSong = queueStore.getNextSong();
|
||||
if (!nextSong || nextSong.preloaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $preloader = $('<audio>');
|
||||
let $preloader = $('<audio>');
|
||||
$preloader.attr('src', songStore.getSourceUrl(nextSong));
|
||||
|
||||
nextSong.preloaded = true;
|
||||
|
@ -138,7 +138,7 @@ export default {
|
|||
* Restart playing a song.
|
||||
*/
|
||||
restart() {
|
||||
var song = queueStore.current();
|
||||
let song = queueStore.current();
|
||||
|
||||
// Record the UNIX timestamp the song start playing, for scrobbling purpose
|
||||
song.playStartTime = Math.floor(Date.now() / 1000);
|
||||
|
@ -157,7 +157,7 @@ export default {
|
|||
}
|
||||
|
||||
try {
|
||||
var notification = new Notification(`♫ ${song.title}`, {
|
||||
let notification = new Notification(`♫ ${song.title}`, {
|
||||
icon: song.album.cover,
|
||||
body: `${song.album.name} – ${song.album.artist.name}`
|
||||
});
|
||||
|
@ -179,7 +179,7 @@ export default {
|
|||
* @return {Object} The song
|
||||
*/
|
||||
nextSong() {
|
||||
var next = queueStore.getNextSong();
|
||||
let next = queueStore.getNextSong();
|
||||
|
||||
if (next) {
|
||||
return next;
|
||||
|
@ -197,7 +197,7 @@ export default {
|
|||
* @return {Object} The song
|
||||
*/
|
||||
prevSong() {
|
||||
var prev = queueStore.getPrevSong();
|
||||
let prev = queueStore.getPrevSong();
|
||||
|
||||
if (prev) {
|
||||
return prev;
|
||||
|
@ -213,7 +213,7 @@ export default {
|
|||
* The selected mode will be stored into local storage as well.
|
||||
*/
|
||||
changeRepeatMode() {
|
||||
var i = this.repeatModes.indexOf(preferenceStore.get('repeatMode')) + 1;
|
||||
let i = this.repeatModes.indexOf(preferenceStore.get('repeatMode')) + 1;
|
||||
|
||||
if (i >= this.repeatModes.length) {
|
||||
i = 0;
|
||||
|
@ -235,7 +235,7 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
var prev = this.prevSong();
|
||||
let prev = this.prevSong();
|
||||
|
||||
if (!prev && preferenceStore.get('repeatMode') === 'NO_REPEAT') {
|
||||
this.stop();
|
||||
|
@ -251,7 +251,7 @@ export default {
|
|||
* If the next song is not found and the current mode is NO_REPEAT, we stop completely.
|
||||
*/
|
||||
playNext() {
|
||||
var next = this.nextSong();
|
||||
let next = this.nextSong();
|
||||
|
||||
if (!next && preferenceStore.get('repeatMode') === 'NO_REPEAT') {
|
||||
// Nothing lasts forever, even cold November rain.
|
||||
|
|
|
@ -8,19 +8,19 @@ export default {
|
|||
secondsToHis(d) {
|
||||
d = parseInt(d, 10);
|
||||
|
||||
var s = d % 60;
|
||||
let s = d % 60;
|
||||
|
||||
if (s < 10) {
|
||||
s = '0' + s;
|
||||
}
|
||||
|
||||
var i = Math.floor((d / 60) % 60);
|
||||
let i = Math.floor((d / 60) % 60);
|
||||
|
||||
if (i < 10) {
|
||||
i = '0' + i;
|
||||
}
|
||||
|
||||
var h = Math.floor(d / 3600);
|
||||
let h = Math.floor(d / 3600);
|
||||
|
||||
if (h < 10) {
|
||||
h = '0' + h;
|
||||
|
@ -51,7 +51,7 @@ export default {
|
|||
return false;
|
||||
}
|
||||
|
||||
var AudioContext = (window.AudioContext ||
|
||||
let AudioContext = (window.AudioContext ||
|
||||
window.webkitAudioContext ||
|
||||
window.mozAudioContext ||
|
||||
window.oAudioContext ||
|
||||
|
|
|
@ -148,7 +148,7 @@ export default {
|
|||
*/
|
||||
getMostPlayed(n = 6) {
|
||||
// Only non-unknown albums with actually play count are applicable.
|
||||
var applicable = _.filter(this.state.albums, album => {
|
||||
let applicable = _.filter(this.state.albums, album => {
|
||||
return album.playCount && album.id !== 1;
|
||||
});
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ export default {
|
|||
*/
|
||||
getMostPlayed(n = 6) {
|
||||
// Only non-unknown artists with actually play count are applicable.
|
||||
var applicable = _.filter(this.state.artists, artist => {
|
||||
let applicable = _.filter(this.state.artists, artist => {
|
||||
return artist.playCount && artist.id !== 1;
|
||||
});
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ export default {
|
|||
NProgress.start();
|
||||
|
||||
http.post('playlist', { name, songs }, response => {
|
||||
var playlist = response.data;
|
||||
let playlist = response.data;
|
||||
playlist.songs = songs;
|
||||
this.getSongs(playlist);
|
||||
this.state.playlists.push(playlist);
|
||||
|
@ -89,7 +89,7 @@ export default {
|
|||
* @param {?Function} cb
|
||||
*/
|
||||
addSongs(playlist, songs, cb = null) {
|
||||
var count = playlist.songs.length;
|
||||
let count = playlist.songs.length;
|
||||
playlist.songs = _.union(playlist.songs, songs);
|
||||
|
||||
if (count === playlist.songs.length) {
|
||||
|
|
|
@ -103,7 +103,7 @@ export default {
|
|||
return this.queue(songs);
|
||||
}
|
||||
|
||||
var head = this.state.songs.splice(0, this.indexOf(this.state.current) + 1);
|
||||
let head = this.state.songs.splice(0, this.indexOf(this.state.current) + 1);
|
||||
this.state.songs = head.concat(songs, this.state.songs);
|
||||
},
|
||||
|
||||
|
@ -123,7 +123,7 @@ export default {
|
|||
* @param {Object} target The target song object
|
||||
*/
|
||||
move(songs, target) {
|
||||
var $targetIndex = this.indexOf(target);
|
||||
let $targetIndex = this.indexOf(target);
|
||||
|
||||
songs.forEach(song => {
|
||||
this.state.songs.splice(this.indexOf(song), 1);
|
||||
|
@ -166,7 +166,7 @@ export default {
|
|||
return _.first(this.state.songs);
|
||||
}
|
||||
|
||||
var i = _.pluck(this.state.songs, 'id').indexOf(this.current().id) + 1;
|
||||
let i = _.pluck(this.state.songs, 'id').indexOf(this.current().id) + 1;
|
||||
|
||||
return i >= this.state.songs.length ? null : this.state.songs[i];
|
||||
},
|
||||
|
@ -181,7 +181,7 @@ export default {
|
|||
return _.last(this.state.songs);
|
||||
}
|
||||
|
||||
var i = _.pluck(this.state.songs, 'id').indexOf(this.current().id) - 1;
|
||||
let i = _.pluck(this.state.songs, 'id').indexOf(this.current().id) - 1;
|
||||
|
||||
return i < 0 ? null : this.state.songs[i];
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@ export default {
|
|||
this.reset();
|
||||
|
||||
http.get('data', response => {
|
||||
var data = response.data;
|
||||
let data = response.data;
|
||||
|
||||
assign(this.state, data);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ export default {
|
|||
favoriteStore.clear();
|
||||
|
||||
interactions.forEach(interaction => {
|
||||
var song = this.byId(interaction.song_id);
|
||||
let song = this.byId(interaction.song_id);
|
||||
|
||||
if (!song) {
|
||||
return;
|
||||
|
@ -94,7 +94,7 @@ export default {
|
|||
* @return {Float|String}
|
||||
*/
|
||||
getLength(songs, toHis) {
|
||||
var duration = songs.reduce((length, song) => length + song.length, 0);
|
||||
let duration = songs.reduce((length, song) => length + song.length, 0);
|
||||
|
||||
if (toHis) {
|
||||
return utils.secondsToHis(duration);
|
||||
|
@ -141,7 +141,7 @@ export default {
|
|||
* @param {?Function} cb
|
||||
*/
|
||||
registerPlay(song, cb = null) {
|
||||
var oldCount = song.playCount;
|
||||
let oldCount = song.playCount;
|
||||
|
||||
http.post('interaction/play', { song: song.id }, response => {
|
||||
// Use the data from the server to make sure we don't miss a play from another device.
|
||||
|
@ -185,7 +185,7 @@ export default {
|
|||
}
|
||||
|
||||
http.get(`${song.id}/info`, response => {
|
||||
var data = response.data;
|
||||
let data = response.data;
|
||||
|
||||
song.lyrics = data.lyrics;
|
||||
|
||||
|
@ -295,15 +295,15 @@ export default {
|
|||
// 2.b. Artist changes as well. Note that an artist might have been created.
|
||||
|
||||
// Find the original song,
|
||||
var originalSong = this.byId(updatedSong.id);
|
||||
let originalSong = this.byId(updatedSong.id);
|
||||
|
||||
if (!originalSong) {
|
||||
return;
|
||||
}
|
||||
|
||||
// and keep track of original album/artist.
|
||||
var originalAlbumId = originalSong.album.id;
|
||||
var originalArtistId = originalSong.album.artist.id;
|
||||
let originalAlbumId = originalSong.album.id;
|
||||
let originalArtistId = originalSong.album.artist.id;
|
||||
|
||||
// First, we update the title and the lyrics
|
||||
originalSong.title = updatedSong.title;
|
||||
|
@ -315,8 +315,8 @@ export default {
|
|||
// First, remove it from its old album
|
||||
albumStore.removeSongsFromAlbum(originalSong.album, originalSong);
|
||||
|
||||
var existingAlbum = albumStore.byId(updatedSong.album.id);
|
||||
var newAlbumCreated = !existingAlbum;
|
||||
let existingAlbum = albumStore.byId(updatedSong.album.id);
|
||||
let newAlbumCreated = !existingAlbum;
|
||||
|
||||
if (!newAlbumCreated) {
|
||||
// The song changed to an existing album. We now add it to such album.
|
||||
|
@ -336,7 +336,7 @@ export default {
|
|||
}
|
||||
} else { // case 2.b
|
||||
// The artist changes.
|
||||
var existingArtist = artistStore.byId(updatedSong.album.artist.id);
|
||||
let existingArtist = artistStore.byId(updatedSong.album.artist.id);
|
||||
|
||||
if (!existingArtist) {
|
||||
// New artist created. We:
|
||||
|
@ -394,7 +394,7 @@ export default {
|
|||
* @return {Array.<Object>}
|
||||
*/
|
||||
getMostPlayed(n = 10) {
|
||||
var songs = _.take(_.sortByOrder(this.state.songs, 'playCount', 'desc'), n);
|
||||
let songs = _.take(_.sortByOrder(this.state.songs, 'playCount', 'desc'), n);
|
||||
|
||||
// Remove those with playCount=0
|
||||
_.remove(songs, song => !song.playCount);
|
||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
|||
NProgress.start();
|
||||
|
||||
http.post('user', { name, email, password }, response => {
|
||||
var user = response.data;
|
||||
let user = response.data;
|
||||
|
||||
this.setAvatar(user);
|
||||
this.state.users.push(user);
|
||||
|
|
|
@ -161,7 +161,7 @@ export default [
|
|||
}
|
||||
];
|
||||
|
||||
export var singleAlbum = {
|
||||
export let singleAlbum = {
|
||||
id: 9999,
|
||||
artist_id: 99,
|
||||
name: "Foo bar",
|
||||
|
@ -183,7 +183,7 @@ export var singleAlbum = {
|
|||
]
|
||||
};
|
||||
|
||||
export var singleArtist = {
|
||||
export let singleArtist = {
|
||||
id: 999,
|
||||
name: "John Cena",
|
||||
albums: [
|
||||
|
@ -204,7 +204,7 @@ export var singleArtist = {
|
|||
]
|
||||
};
|
||||
|
||||
export var singleSong = {
|
||||
export let singleSong = {
|
||||
id: "dccb0d4d4803ebbcb61000a5b6a868f5",
|
||||
album_id: 1193,
|
||||
title: "Foo and Bar",
|
||||
|
|
|
@ -61,7 +61,7 @@ describe('stores/artist', () => {
|
|||
});
|
||||
|
||||
it('correctly sets the album artist', () => {
|
||||
var addedAlbum = _.last(artistStore.state.artists[0].albums);
|
||||
let addedAlbum = _.last(artistStore.state.artists[0].albums);
|
||||
addedAlbum.artist.should.equal(artistStore.state.artists[0]);
|
||||
addedAlbum.artist_id.should.equal(artistStore.state.artists[0].id);
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ describe('stores/song', () => {
|
|||
describe('#syncUpdatedSong', () => {
|
||||
beforeEach(() => artistStore.init(artists));
|
||||
|
||||
var updatedSong = {
|
||||
let updatedSong = {
|
||||
id: "39189f4545f9d5671fb3dc964f0080a0",
|
||||
album_id: 1193,
|
||||
title: "I Swear A Lot",
|
||||
|
@ -79,7 +79,7 @@ describe('stores/song', () => {
|
|||
});
|
||||
|
||||
it ('correctly syncs an updated song into an existing album of same artist', () => {
|
||||
var song = _.cloneDeep(updatedSong);
|
||||
let song = _.cloneDeep(updatedSong);
|
||||
song.album_id = 1194;
|
||||
song.album = {
|
||||
id: 1194,
|
||||
|
@ -95,7 +95,7 @@ describe('stores/song', () => {
|
|||
});
|
||||
|
||||
it ('correctly syncs an updated song into a new album of same artist', () => {
|
||||
var song = _.cloneDeep(updatedSong);
|
||||
let song = _.cloneDeep(updatedSong);
|
||||
song.album_id = 9999;
|
||||
song.album = {
|
||||
id: 9999,
|
||||
|
@ -117,7 +117,7 @@ describe('stores/song', () => {
|
|||
});
|
||||
|
||||
it ('correctly syncs an updated song into a new album of a new artist', () => {
|
||||
var song = _.cloneDeep(updatedSong);
|
||||
let song = _.cloneDeep(updatedSong);
|
||||
song.album_id = 10000;
|
||||
song.album = {
|
||||
id: 10000,
|
||||
|
@ -132,11 +132,11 @@ describe('stores/song', () => {
|
|||
songStore.syncUpdatedSong(song);
|
||||
|
||||
// A new artist should be created...
|
||||
var lastArtist = _.last(artistStore.all());
|
||||
let lastArtist = _.last(artistStore.all());
|
||||
lastArtist.name.should.equal('John Cena');
|
||||
|
||||
// A new album should be created
|
||||
var lastAlbum = _.last(albumStore.all());
|
||||
let lastAlbum = _.last(albumStore.all());
|
||||
lastAlbum.name.should.equal("It's... John Cena!!!");
|
||||
|
||||
// The album must belong to John Cena of course!
|
||||
|
|
Loading…
Reference in a new issue