Skip to content

Commit

Permalink
⬆️ angular@1.6.3
Browse files Browse the repository at this point in the history
replace deprecated http.success callbacks with .then
  • Loading branch information
soygul committed Mar 14, 2017
1 parent 2d7fb1d commit 0e4c634
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
16 changes: 8 additions & 8 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"name": "koan",
"version": "1.0.0",
"dependencies": {
"angular": "1.5.8",
"angular-animate": "1.5.8",
"angular": "1.6.3",
"angular-animate": "1.6.3",
"angular-elastic": "2.5.1",
"angular-loading-bar": "0.9.0",
"angular-route": "1.5.8",
"angular-route": "1.6.3",
"bootstrap": "3.3.7",
"bootstrap-social": "5.0.0",
"font-awesome": "4.5.0",
"jquery": "3.1.0",
"lodash": "4.15"
"bootstrap-social": "5.1.1",
"font-awesome": "4.7.0",
"jquery": "3.1.1",
"lodash": "4.17.4"
},
"devDependencies": {
"angular-mocks": "1.5.8"
"angular-mocks": "1.6.3"
}
}
2 changes: 1 addition & 1 deletion client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ angular
},
clearDatabase: function () {
var self = this;
api.debug.clearDatabase().success(function () {
api.debug.clearDatabase().then(function () {
self.logout();
});
}
Expand Down
18 changes: 11 additions & 7 deletions client/modules/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ angular.module('koan.home').component('home', {
ctrl.postBox = {message: null, disabled: false};

// retrieve posts from server
api.posts.list().success(function (posts) {
api.posts.list().then(function successCallback(response) {
var posts = response.data;

posts.forEach(function (post) {
post.commentBox = {message: '', disabled: false};
post.comments = post.comments || [];
Expand All @@ -31,7 +33,9 @@ angular.module('koan.home').component('home', {
// disable the post box and push the new post to server
ctrl.postBox.disabled = true;
api.posts.create({message: ctrl.postBox.message})
.success(function (post) {
.then(function successCallback(response) {
var post = response.data;

// only add the post if we don't have it already in the posts list to avoid dupes
if (!_.some(ctrl.posts, function (p) {
return p.id === post.id;
Expand All @@ -49,8 +53,7 @@ angular.module('koan.home').component('home', {
// clear the post box and enable it
ctrl.postBox.message = '';
ctrl.postBox.disabled = false;
})
.error(function () {
}, function errorCallback(response) {
// don't clear the post box but enable it so the user can re-try
ctrl.postBox.disabled = false;
});
Expand All @@ -71,7 +74,9 @@ angular.module('koan.home').component('home', {
// disable the comment box and push the new comment to server
post.commentBox.disabled = true;
api.posts.comments.create(post.id, {message: post.commentBox.message})
.success(function (comment) {
.then(function successCallback(response) {
var comment = response.data;

// only add the comment if we don't have it already in the post's comments list to avoid dupes
if (!_.some(post.comments, function (c) {
return c.id === comment.id;
Expand All @@ -87,8 +92,7 @@ angular.module('koan.home').component('home', {
// clear the comment field and enable it
post.commentBox.message = '';
post.commentBox.disabled = false;
})
.error(function () {
}, function errorCallback(response) {
// don't clear the comment box but enable it so the user can re-try
post.commentBox.disabled = false;
});
Expand Down

0 comments on commit 0e4c634

Please sign in to comment.