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
|
@ -4,10 +4,10 @@
|
|||
* Manages the playing queue. Gives access to the player service's queue-related functions,
|
||||
* like adding, removing and shuffling the queue.
|
||||
*/
|
||||
angular.module('jamstash.queue.controller', ['jamstash.player.service', 'jamstash.settings.service'])
|
||||
angular.module('jamstash.queue.controller', ['jamstash.player.service', 'jamstash.settings.service', 'jamstash.selectedsongs'])
|
||||
|
||||
.controller('QueueController', ['$scope', 'globals', 'player',
|
||||
function ($scope, globals, player) {
|
||||
.controller('QueueController', ['$scope', 'globals', 'player', 'SelectedSongs',
|
||||
function ($scope, globals, player, SelectedSongs) {
|
||||
'use strict';
|
||||
$scope.settings = globals.settings;
|
||||
$scope.player = player;
|
||||
|
@ -37,7 +37,7 @@ angular.module('jamstash.queue.controller', ['jamstash.player.service', 'jamstas
|
|||
};
|
||||
|
||||
$scope.removeSelectedSongsFromQueue = function () {
|
||||
player.removeSongs($scope.selectedSongs);
|
||||
player.removeSongs(SelectedSongs.get());
|
||||
};
|
||||
|
||||
$scope.isPlayingSong = function (song) {
|
||||
|
@ -65,4 +65,8 @@ angular.module('jamstash.queue.controller', ['jamstash.player.service', 'jamstas
|
|||
end = ui.item.index();
|
||||
player.queue.splice(end, 0, player.queue.splice(start, 1)[0]);
|
||||
};
|
||||
|
||||
$scope.toggleSelection = function (song) {
|
||||
SelectedSongs.toggle(song);
|
||||
};
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue