Skip to content

Commit

Permalink
Upgrading spotify.user.id storage syntax (fixes #147); New playlist n…
Browse files Browse the repository at this point in the history
…g-if breaks ng-bind
  • Loading branch information
jaedb committed Sep 26, 2016
1 parent ab3b5b7 commit 2406849
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 79 deletions.
29 changes: 13 additions & 16 deletions mopidy_spotmop/static/app-annotated.js
Original file line number Diff line number Diff line change
Expand Up @@ -29867,7 +29867,7 @@ angular.module('spotmop', [
$scope.playlists = function(){
return PlaylistManagerService.myPlaylists();
}
$scope.spotifyUser = {};
$scope.settings = SettingsService;
$scope.menuCollapsable = false;
$scope.reloadApp = function(){
window.location.reload();
Expand Down Expand Up @@ -30611,7 +30611,7 @@ angular.module('spotmop.browse.artist', [])
// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){

var spotifyuserid = SettingsService.getSetting('spotifyuser.id');
var spotifyuserid = SettingsService.getSetting('spotify.user.id');
if( !spotifyuserid ) return false;

SpotifyService.isFollowingArtist( $stateParams.uri, spotifyuserid )
Expand Down Expand Up @@ -31200,7 +31200,7 @@ angular.module('spotmop.browse.playlist', [])
if( $scope.origin == 'm3u' ) return true;
if( $scope.origin == 'spotify' ){
if( typeof( $scope.playlist ) !== 'undefined' && typeof( $scope.playlist.owner ) !== 'undefined' ){
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotifyuser.id') );
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotify.user.id') );
}
}
return false;
Expand All @@ -31219,23 +31219,20 @@ angular.module('spotmop.browse.playlist', [])
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Following playlist' );
$scope.updatePlaylists();
});
}
$scope.unfollowPlaylist = function(){
SpotifyService.unfollowPlaylist( uri )
.then( function(response){
$scope.following = false;
NotifyService.notify( 'Playlist removed' );
$scope.updatePlaylists();
});
}
$scope.recoverPlaylist = function(){
SpotifyService.followPlaylist( uri )
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Playlist recovered' );
$scope.updatePlaylists();
});
}
$scope.editPlaylist = function(){
Expand Down Expand Up @@ -31293,7 +31290,7 @@ angular.module('spotmop.browse.playlist', [])

// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotifyuser',{id: null}).id )
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotify.user.id') )
.then( function( isFollowing ){
$scope.following = $.parseJSON(isFollowing);
});
Expand Down Expand Up @@ -31385,7 +31382,7 @@ angular.module('spotmop.browse.playlist', [])

var playlisturi = $state.params.uri;
var playlistOwnerID = SpotifyService.getFromUri('userid', playlisturi);
var currentUserID = SettingsService.getSetting('spotifyuser.id');
var currentUserID = SettingsService.getSetting('spotify.user.id');

if( $scope.origin == 'spotify' ){
if( playlistOwnerID != currentUserID ){
Expand Down Expand Up @@ -33882,7 +33879,7 @@ angular.module('spotmop.library', [])
$scope.tracklist = {tracks: [], type: 'track'};

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyTracks( userid )
.then( function( response ){ // successful
Expand Down Expand Up @@ -34015,7 +34012,7 @@ angular.module('spotmop.library', [])
$scope.artists = [];

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyArtists( userid )
.then( function( response ){
Expand Down Expand Up @@ -34103,7 +34100,7 @@ angular.module('spotmop.library', [])
$scope.albums = { items: [] };

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuser.id');
var userid = SettingsService.getSetting('spotif.user.id');

// if we have full spotify authorization
if( $scope.spotify.isAuthorized() ){
Expand Down Expand Up @@ -35833,7 +35830,7 @@ angular.module('spotmop.services.dialog', [])
// spotify playlist
if( $scope.scheme == 'spotify' ){
SpotifyService.createPlaylist(
$scope.$parent.spotifyUser.id,
SettingsService.getSetting('spotify.user.id'),
{ name: $scope.playlistName, public: $scope.playlistPublic }
)
.then( function(response){
Expand Down Expand Up @@ -36476,7 +36473,7 @@ angular.module('spotmop.services.mopidy', [
if( !name ) name = 'User';

var icon = '';
var spotifyuser = SettingsService.getSetting('spotifyuser');
var spotifyuser = SettingsService.getSetting('spotify.user');
if( spotifyuser ) icon = spotifyuser.images[0].url;

PusherService.broadcast({
Expand Down Expand Up @@ -36777,7 +36774,7 @@ angular.module('spotmop.services.playlistManager', [])
digestSpotifyPlaylists( response );
});
}else{
var userid = SettingsService.getSetting('spotifyuser.id');
var userid = SettingsService.getSetting('spotify.user.id');
SpotifyService.getPlaylists( userid, 50 )
.then( function(response){
digestSpotifyPlaylists( response );
Expand Down Expand Up @@ -36831,7 +36828,7 @@ angular.module('spotmop.services.playlistManager', [])
var playlist = playlists[i];
var origin = $filter('assetOrigin')(playlist.uri);
if( origin == 'spotify' ){
var user = SettingsService.getSetting('spotifyuser.id');
var user = SettingsService.getSetting('spotify.user.id');
if( SpotifyService.isAuthorized() && playlist.uri.startsWith('spotify:user:'+user) ){
myPlaylists.push( playlist );
}
Expand Down Expand Up @@ -36955,7 +36952,7 @@ angular.module('spotmop.services.playlistManager', [])
case 'spotify':

var playlistOwnerID = SpotifyService.getFromUri('userid', uri);
var currentUserID = SettingsService.getSetting('spotifyuser.id');
var currentUserID = SettingsService.getSetting('spotify.user.id');

if( playlistOwnerID != currentUserID ){
NotifyService.error('Cannot modify to a playlist you don\'t own');
Expand Down
29 changes: 13 additions & 16 deletions mopidy_spotmop/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29867,7 +29867,7 @@ angular.module('spotmop', [
$scope.playlists = function(){
return PlaylistManagerService.myPlaylists();
}
$scope.spotifyUser = {};
$scope.settings = SettingsService;
$scope.menuCollapsable = false;
$scope.reloadApp = function(){
window.location.reload();
Expand Down Expand Up @@ -30611,7 +30611,7 @@ angular.module('spotmop.browse.artist', [])
// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){

var spotifyuserid = SettingsService.getSetting('spotifyuser.id');
var spotifyuserid = SettingsService.getSetting('spotify.user.id');
if( !spotifyuserid ) return false;

SpotifyService.isFollowingArtist( $stateParams.uri, spotifyuserid )
Expand Down Expand Up @@ -31200,7 +31200,7 @@ angular.module('spotmop.browse.playlist', [])
if( $scope.origin == 'm3u' ) return true;
if( $scope.origin == 'spotify' ){
if( typeof( $scope.playlist ) !== 'undefined' && typeof( $scope.playlist.owner ) !== 'undefined' ){
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotifyuser.id') );
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotify.user.id') );
}
}
return false;
Expand All @@ -31219,23 +31219,20 @@ angular.module('spotmop.browse.playlist', [])
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Following playlist' );
$scope.updatePlaylists();
});
}
$scope.unfollowPlaylist = function(){
SpotifyService.unfollowPlaylist( uri )
.then( function(response){
$scope.following = false;
NotifyService.notify( 'Playlist removed' );
$scope.updatePlaylists();
});
}
$scope.recoverPlaylist = function(){
SpotifyService.followPlaylist( uri )
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Playlist recovered' );
$scope.updatePlaylists();
});
}
$scope.editPlaylist = function(){
Expand Down Expand Up @@ -31293,7 +31290,7 @@ angular.module('spotmop.browse.playlist', [])

// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotifyuser',{id: null}).id )
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotify.user.id') )
.then( function( isFollowing ){
$scope.following = $.parseJSON(isFollowing);
});
Expand Down Expand Up @@ -31385,7 +31382,7 @@ angular.module('spotmop.browse.playlist', [])

var playlisturi = $state.params.uri;
var playlistOwnerID = SpotifyService.getFromUri('userid', playlisturi);
var currentUserID = SettingsService.getSetting('spotifyuser.id');
var currentUserID = SettingsService.getSetting('spotify.user.id');

if( $scope.origin == 'spotify' ){
if( playlistOwnerID != currentUserID ){
Expand Down Expand Up @@ -33882,7 +33879,7 @@ angular.module('spotmop.library', [])
$scope.tracklist = {tracks: [], type: 'track'};

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyTracks( userid )
.then( function( response ){ // successful
Expand Down Expand Up @@ -34015,7 +34012,7 @@ angular.module('spotmop.library', [])
$scope.artists = [];

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyArtists( userid )
.then( function( response ){
Expand Down Expand Up @@ -34103,7 +34100,7 @@ angular.module('spotmop.library', [])
$scope.albums = { items: [] };

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuser.id');
var userid = SettingsService.getSetting('spotif.user.id');

// if we have full spotify authorization
if( $scope.spotify.isAuthorized() ){
Expand Down Expand Up @@ -35833,7 +35830,7 @@ angular.module('spotmop.services.dialog', [])
// spotify playlist
if( $scope.scheme == 'spotify' ){
SpotifyService.createPlaylist(
$scope.$parent.spotifyUser.id,
SettingsService.getSetting('spotify.user.id'),
{ name: $scope.playlistName, public: $scope.playlistPublic }
)
.then( function(response){
Expand Down Expand Up @@ -36476,7 +36473,7 @@ angular.module('spotmop.services.mopidy', [
if( !name ) name = 'User';

var icon = '';
var spotifyuser = SettingsService.getSetting('spotifyuser');
var spotifyuser = SettingsService.getSetting('spotify.user');
if( spotifyuser ) icon = spotifyuser.images[0].url;

PusherService.broadcast({
Expand Down Expand Up @@ -36777,7 +36774,7 @@ angular.module('spotmop.services.playlistManager', [])
digestSpotifyPlaylists( response );
});
}else{
var userid = SettingsService.getSetting('spotifyuser.id');
var userid = SettingsService.getSetting('spotify.user.id');
SpotifyService.getPlaylists( userid, 50 )
.then( function(response){
digestSpotifyPlaylists( response );
Expand Down Expand Up @@ -36831,7 +36828,7 @@ angular.module('spotmop.services.playlistManager', [])
var playlist = playlists[i];
var origin = $filter('assetOrigin')(playlist.uri);
if( origin == 'spotify' ){
var user = SettingsService.getSetting('spotifyuser.id');
var user = SettingsService.getSetting('spotify.user.id');
if( SpotifyService.isAuthorized() && playlist.uri.startsWith('spotify:user:'+user) ){
myPlaylists.push( playlist );
}
Expand Down Expand Up @@ -36955,7 +36952,7 @@ angular.module('spotmop.services.playlistManager', [])
case 'spotify':

var playlistOwnerID = SpotifyService.getFromUri('userid', uri);
var currentUserID = SettingsService.getSetting('spotifyuser.id');
var currentUserID = SettingsService.getSetting('spotify.user.id');

if( playlistOwnerID != currentUserID ){
NotifyService.error('Cannot modify to a playlist you don\'t own');
Expand Down
12 changes: 6 additions & 6 deletions mopidy_spotmop/static/app.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mopidy_spotmop/static/app.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mopidy_spotmop/static/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ angular.module('spotmop', [
$scope.playlists = function(){
return PlaylistManagerService.myPlaylists();
}
$scope.spotifyUser = {};
$scope.settings = SettingsService;
$scope.menuCollapsable = false;
$scope.reloadApp = function(){
window.location.reload();
Expand Down
2 changes: 1 addition & 1 deletion mopidy_spotmop/static/app/browse/artist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ angular.module('spotmop.browse.artist', [])
// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){

var spotifyuserid = SettingsService.getSetting('spotifyuser.id');
var spotifyuserid = SettingsService.getSetting('spotify.user.id');
if( !spotifyuserid ) return false;

SpotifyService.isFollowingArtist( $stateParams.uri, spotifyuserid )
Expand Down
9 changes: 3 additions & 6 deletions mopidy_spotmop/static/app/browse/playlist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ angular.module('spotmop.browse.playlist', [])
if( $scope.origin == 'm3u' ) return true;
if( $scope.origin == 'spotify' ){
if( typeof( $scope.playlist ) !== 'undefined' && typeof( $scope.playlist.owner ) !== 'undefined' ){
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotifyuser.id') );
return ( $scope.playlist.owner.id == SettingsService.getSetting('spotify.user.id') );
}
}
return false;
Expand All @@ -50,23 +50,20 @@ angular.module('spotmop.browse.playlist', [])
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Following playlist' );
$scope.updatePlaylists();
});
}
$scope.unfollowPlaylist = function(){
SpotifyService.unfollowPlaylist( uri )
.then( function(response){
$scope.following = false;
NotifyService.notify( 'Playlist removed' );
$scope.updatePlaylists();
});
}
$scope.recoverPlaylist = function(){
SpotifyService.followPlaylist( uri )
.then( function(response){
$scope.following = true;
NotifyService.notify( 'Playlist recovered' );
$scope.updatePlaylists();
});
}
$scope.editPlaylist = function(){
Expand Down Expand Up @@ -124,7 +121,7 @@ angular.module('spotmop.browse.playlist', [])

// figure out if we're following this playlist
if( $scope.spotify.isAuthorized() ){
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotifyuser',{id: null}).id )
SpotifyService.isFollowingPlaylist( $stateParams.uri, SettingsService.getSetting('spotify.user.id') )
.then( function( isFollowing ){
$scope.following = $.parseJSON(isFollowing);
});
Expand Down Expand Up @@ -216,7 +213,7 @@ angular.module('spotmop.browse.playlist', [])

var playlisturi = $state.params.uri;
var playlistOwnerID = SpotifyService.getFromUri('userid', playlisturi);
var currentUserID = SettingsService.getSetting('spotifyuser.id');
var currentUserID = SettingsService.getSetting('spotify.user.id');

if( $scope.origin == 'spotify' ){
if( playlistOwnerID != currentUserID ){
Expand Down
2 changes: 1 addition & 1 deletion mopidy_spotmop/static/app/browse/user/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>User</h1>
<h1>
<span ng-if="user.display_name" ng-bind="user.display_name"></span>
<span ng-if="!user.display_name" ng-bind="user.id"></span>
<span class="flag blue" ng-show="user.id == spotifyUser.id"><i class="fa fa-star"></i> You</span>
<span class="flag blue" ng-show="user.id == settings.state().spotify.user.id"><i class="fa fa-star"></i> You</span>
</h1>
<div class="info-text">
<span ng-bind="user.id"></span>
Expand Down
6 changes: 3 additions & 3 deletions mopidy_spotmop/static/app/library/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ angular.module('spotmop.library', [])
$scope.tracklist = {tracks: [], type: 'track'};

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyTracks( userid )
.then( function( response ){ // successful
Expand Down Expand Up @@ -177,7 +177,7 @@ angular.module('spotmop.library', [])
$scope.artists = [];

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuserid',$scope.$parent.spotifyUser.id);
var userid = SettingsService.getSetting('spotify.user.id');

SpotifyService.getMyArtists( userid )
.then( function( response ){
Expand Down Expand Up @@ -265,7 +265,7 @@ angular.module('spotmop.library', [])
$scope.albums = { items: [] };

// if we've got a userid already in storage, use that
var userid = SettingsService.getSetting('spotifyuser.id');
var userid = SettingsService.getSetting('spotif.user.id');

// if we have full spotify authorization
if( $scope.spotify.isAuthorized() ){
Expand Down
2 changes: 1 addition & 1 deletion mopidy_spotmop/static/app/library/playlists.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1>
</div>
<div class="info animate">
<div class="name" ng-bind="playlist.name"></div>
<div class="secondary tracks" ng-if="playlist.tracks"><span ng-bind="playlist.tracks.total"></span> tracks <span ng-if="playlist.owner.id != spotifyUser.id">&nbsp;<i class="fa fa-lock"></i></span></div>
<div class="secondary tracks" ng-if="playlist.tracks"><span ng-bind="playlist.tracks.total"></span> tracks <span ng-if="playlist.owner.id != settings.state().spotify.user.id">&nbsp;<i class="fa fa-lock"></i></span></div>
</div>
</a>
</div>
Expand Down
Loading

0 comments on commit 2406849

Please sign in to comment.