Refactor song selection across the app
- Added a new SelectedSongs service. Its purpose is to store an array of selected songs and all behaviour associated with it : adding songs to it, removing them, toggling a song, etc. It also changes each song's selected property. - Removed selectAll, selectNone, playAll, playFrom, addSongsToQueue and selectSong from main-controller.js. Those are now defined either in queue.js, subsonic.js or archive.js, depending on where they are used. I know it does add some duplication between archive.js and subsonic.js, but this will be addressed in a later commit (maybe by creating a shared service). - Refactored subsonic-service.js' addToPlaylist() and split it between subsonic-service.js and subsonic.js (like all the other playlist-related functions). - Moved subsonic-service.js' songsRemoveSelected() to subsonic.js since it only removes songs from the scope. - Removed $rootScope and utils (unused dependencies) from subsonic-service.js
This commit is contained in:
parent
7e0c5a176a
commit
5d385149f3
16 changed files with 658 additions and 276 deletions
|
@ -2,12 +2,14 @@
|
|||
describe("Queue controller", function () {
|
||||
'use strict';
|
||||
|
||||
var player, scope;
|
||||
var player, scope, SelectedSongs;
|
||||
var song;
|
||||
|
||||
beforeEach(function () {
|
||||
module('jamstash.queue.controller');
|
||||
|
||||
SelectedSongs = jasmine.createSpyObj("SelectedSongs", ["get"]);
|
||||
|
||||
inject(function ($controller, $rootScope, globals, _player_) {
|
||||
scope = $rootScope.$new();
|
||||
player = _player_;
|
||||
|
@ -15,7 +17,8 @@ describe("Queue controller", function () {
|
|||
$controller('QueueController', {
|
||||
$scope: scope,
|
||||
globals: globals,
|
||||
player: player
|
||||
player: player,
|
||||
SelectedSongs: SelectedSongs
|
||||
});
|
||||
});
|
||||
song = { id: 7310 };
|
||||
|
@ -62,7 +65,7 @@ describe("Queue controller", function () {
|
|||
it("When I remove all the selected songs from the queue, it calls removeSongs in the player service", function () {
|
||||
spyOn(player, "removeSongs");
|
||||
var secondSong = { id: 6791 };
|
||||
scope.selectedSongs = [song, secondSong];
|
||||
SelectedSongs.get.and.returnValue([song, secondSong]);
|
||||
scope.removeSelectedSongsFromQueue();
|
||||
expect(player.removeSongs).toHaveBeenCalledWith([song, secondSong]);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue