Added extra nesting .data and rename callback to be response not data

This commit is contained in:
Kegan Dougal 2014-08-14 15:43:16 +01:00
parent db3e1d73c6
commit 24bd133d9d
2 changed files with 31 additions and 31 deletions

View File

@ -68,7 +68,7 @@ angular.module('LoginController', ['matrixService'])
// try to login // try to login
matrixService.login($scope.account.user_id, $scope.account.password).then( matrixService.login($scope.account.user_id, $scope.account.password).then(
function(response) { function(response) {
if ("access_token" in response) { if ("access_token" in response.data) {
$scope.feedback = "Login successful."; $scope.feedback = "Login successful.";
matrixService.setConfig({ matrixService.setConfig({
homeserver: $scope.account.homeserver, homeserver: $scope.account.homeserver,
@ -79,7 +79,7 @@ angular.module('LoginController', ['matrixService'])
$location.path("rooms"); $location.path("rooms");
} }
else { else {
$scope.feedback = "Failed to login: " + JSON.stringify(response); $scope.feedback = "Failed to login: " + JSON.stringify(response.data);
} }
}, },
function(error) { function(error) {

View File

@ -75,18 +75,18 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
// List all rooms joined or been invited to // List all rooms joined or been invited to
$scope.rooms = matrixService.rooms(); $scope.rooms = matrixService.rooms();
matrixService.rooms().then( matrixService.rooms().then(
function(data) { function(response) {
data = assignRoomAliases(data); var data = assignRoomAliases(response.data);
$scope.feedback = "Success"; $scope.feedback = "Success";
$scope.rooms = data; $scope.rooms = data;
}, },
function(reason) { function(error) {
$scope.feedback = "Failure: " + reason; $scope.feedback = "Failure: " + error.data;
}); });
matrixService.publicRooms().then( matrixService.publicRooms().then(
function(data) { function(response) {
$scope.public_rooms = assignRoomAliases(data.chunk); $scope.public_rooms = assignRoomAliases(response.data.chunk);
} }
); );
}; };
@ -101,14 +101,14 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
matrixService.create(room_id, visibility).then( matrixService.create(room_id, visibility).then(
function(response) { function(response) {
// This room has been created. Refresh the rooms list // This room has been created. Refresh the rooms list
console.log("Created room " + response.room_alias + " with id: "+ console.log("Created room " + response.data.room_alias + " with id: "+
response.room_id); response.data.room_id);
matrixService.createRoomIdToAliasMapping( matrixService.createRoomIdToAliasMapping(
response.room_id, response.room_alias); response.data.room_id, response.data.room_alias);
$scope.refresh(); $scope.refresh();
}, },
function(reason) { function(error) {
$scope.feedback = "Failure: " + reason; $scope.feedback = "Failure: " + error.data;
}); });
}; };
@ -118,17 +118,17 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
//$location.path("room/" + room_id); //$location.path("room/" + room_id);
matrixService.join(room_id).then( matrixService.join(room_id).then(
function(response) { function(response) {
if (response.hasOwnProperty("room_id")) { if (response.data.hasOwnProperty("room_id")) {
if (response.room_id != room_id) { if (response.data.room_id != room_id) {
$location.path("room/" + response.room_id); $location.path("room/" + response.data.room_id);
return; return;
} }
} }
$location.path("room/" + room_id); $location.path("room/" + room_id);
}, },
function(reason) { function(error) {
$scope.feedback = "Can't join room: " + reason; $scope.feedback = "Can't join room: " + error.data;
} }
); );
}; };
@ -136,15 +136,15 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
$scope.joinAlias = function(room_alias) { $scope.joinAlias = function(room_alias) {
matrixService.joinAlias(room_alias).then( matrixService.joinAlias(room_alias).then(
function(response) { function(response) {
if (response.hasOwnProperty("room_id")) { if (response.data.hasOwnProperty("room_id")) {
$location.path("room/" + response.room_id); $location.path("room/" + response.data.room_id);
return; return;
} else { } else {
// TODO (erikj): Do something here? // TODO (erikj): Do something here?
} }
}, },
function(reason) { function(error) {
$scope.feedback = "Can't join room: " + reason; $scope.feedback = "Can't join room: " + error.data;
} }
); );
}; };
@ -158,8 +158,8 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
matrixService.setConfig(config); matrixService.setConfig(config);
matrixService.saveConfig(); matrixService.saveConfig();
}, },
function(reason) { function(error) {
$scope.feedback = "Can't update display name: " + reason; $scope.feedback = "Can't update display name: " + error.data;
} }
); );
}; };
@ -182,8 +182,8 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
matrixService.setConfig(config); matrixService.setConfig(config);
matrixService.saveConfig(); matrixService.saveConfig();
}, },
function(reason) { function(error) {
$scope.feedback = "Can't update avatar: " + reason; $scope.feedback = "Can't update avatar: " + error.data;
} }
); );
}; };
@ -191,8 +191,8 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
$scope.linkEmail = function(email) { $scope.linkEmail = function(email) {
matrixService.linkEmail(email).then( matrixService.linkEmail(email).then(
function(response) { function(response) {
if (response.success === true) { if (response.data.success === true) {
$scope.linkedEmails.authTokenId = response.tokenId; $scope.linkedEmails.authTokenId = response.data.tokenId;
$scope.emailFeedback = "You have been sent an email."; $scope.emailFeedback = "You have been sent an email.";
$scope.linkedEmails.emailBeingAuthed = email; $scope.linkedEmails.emailBeingAuthed = email;
} }
@ -200,8 +200,8 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
$scope.emailFeedback = "Failed to send email."; $scope.emailFeedback = "Failed to send email.";
} }
}, },
function(reason) { function(error) {
$scope.emailFeedback = "Can't send email: " + reason; $scope.emailFeedback = "Can't send email: " + error.data;
} }
); );
}; };
@ -214,7 +214,7 @@ angular.module('RoomsController', ['matrixService', 'mFileInput'])
} }
matrixService.authEmail(matrixService.config().user_id, tokenId, code).then( matrixService.authEmail(matrixService.config().user_id, tokenId, code).then(
function(response) { function(response) {
if ("success" in response && response.success === false) { if ("success" in response.data && response.data.success === false) {
$scope.emailFeedback = "Failed to authenticate email."; $scope.emailFeedback = "Failed to authenticate email.";
return; return;
} }