Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/states/not-authed.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,21 @@ var setupIntent = function(request, response) {
if (result === 'authorized') {
db.updateAuthToken(app.user, app.plex.pinAuth.token).then(function() {
app.user.setupDefaults(true).then(function() {
response.say("Congratulations! I am now linked to your Plex account. To save you some time, I went ahead and made some " +
"assumptions about which server and which player you want to use. For the server, I picked " + app.user.serverName +
". And for the player, I picked " + app.user.playerName + ". If you'd like to change this, simply say 'Alexa, ask " +
"" + app.INVOCATION_NAME + " to change some settings.");
var responseText = "Congratulations! I am now linked to your Plex account. To save you some time, I went ahead and made some " +
"assumptions about which server and which player you want to use.";

if (app.user.serverName) {
responseText += " For the server, I picked " + app.user.serverName + "."
}

if (app.user.playerName) {
responseText += " And for the player, I picked " + app.user.playerName + ".";
}

responseText += " If you'd like to change this, simply say 'Alexa, ask " +
"" + app.INVOCATION_NAME + " to change some settings.";

response.say(responseText);
return response.send();
});
}).catch(function(err) {
Expand Down
18 changes: 13 additions & 5 deletions lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ var User = function(app, dbobject) {

Object.defineProperty(this, 'playerName', {
get: function() {
return context.dbobject.player.name;
if (context.dbobject.player) {
return context.dbobject.player.name;
} else {
return null;
}
}
});

Expand Down Expand Up @@ -199,10 +203,14 @@ User.prototype.setDefaultPlayer = function(forceReset) {
if (!this.player || forceReset) {
return plexutils.getPlayers(context._app)
.then(function(players) {
return db.updateUserPlayer(context, players[0])
.then(function() {
return true;
})
if (players && players.length) {
return db.updateUserPlayer(context, players[0])
.then(function() {
return true;
})
} else {
return Q.resolve(true);
}
})
}

Expand Down