|
|
|
@ -361,17 +361,30 @@
|
|
|
|
|
|
|
|
|
|
likeStatus(index) {
|
|
|
|
|
let status = this.feed[index];
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].favourites_count = count + 1;
|
|
|
|
|
this.feed[index].favourited = !status.favourited;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
status = status.reblog;
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].reblog.favourites_count = count + 1;
|
|
|
|
|
this.feed[index].reblog.favourited = !status.favourited;
|
|
|
|
|
} else {
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].favourites_count = count + 1;
|
|
|
|
|
this.feed[index].favourited = !status.favourited;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/statuses/' + status.id + '/favourite')
|
|
|
|
|
.then(res => {
|
|
|
|
|
//
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.feed[index].favourites_count = count;
|
|
|
|
|
this.feed[index].favourited = false;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
this.feed[index].reblog.favourites_count = count;
|
|
|
|
|
this.feed[index].reblog.favourited = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].favourites_count = count;
|
|
|
|
|
this.feed[index].favourited = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let el = document.createElement('p');
|
|
|
|
|
el.classList.add('text-left');
|
|
|
|
@ -413,17 +426,30 @@
|
|
|
|
|
|
|
|
|
|
unlikeStatus(index) {
|
|
|
|
|
let status = this.feed[index];
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].favourites_count = count - 1;
|
|
|
|
|
this.feed[index].favourited = !status.favourited;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
status = status.reblog;
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].reblog.favourites_count = count - 1;
|
|
|
|
|
this.feed[index].reblog.favourited = !status.favourited;
|
|
|
|
|
} else {
|
|
|
|
|
let state = status.favourited;
|
|
|
|
|
let count = status.favourites_count;
|
|
|
|
|
this.feed[index].favourites_count = count - 1;
|
|
|
|
|
this.feed[index].favourited = !status.favourited;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/statuses/' + status.id + '/unfavourite')
|
|
|
|
|
.then(res => {
|
|
|
|
|
//
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.feed[index].favourites_count = count;
|
|
|
|
|
this.feed[index].favourited = false;
|
|
|
|
|
if(status.reblog && status.pf_type == 'share') {
|
|
|
|
|
this.feed[index].reblog.favourites_count = count;
|
|
|
|
|
this.feed[index].reblog.favourited = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].favourites_count = count;
|
|
|
|
|
this.feed[index].favourited = false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -445,7 +471,8 @@
|
|
|
|
|
|
|
|
|
|
openLikesModal(idx) {
|
|
|
|
|
this.postIndex = idx;
|
|
|
|
|
this.likesModalPost = this.feed[this.postIndex];
|
|
|
|
|
let post = this.feed[this.postIndex];
|
|
|
|
|
this.likesModalPost = post.reblog ? post.reblog : post;
|
|
|
|
|
this.showLikesModal = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.likesModal.open();
|
|
|
|
@ -454,7 +481,8 @@
|
|
|
|
|
|
|
|
|
|
openSharesModal(idx) {
|
|
|
|
|
this.postIndex = idx;
|
|
|
|
|
this.sharesModalPost = this.feed[this.postIndex];
|
|
|
|
|
let post = this.feed[this.postIndex];
|
|
|
|
|
this.sharesModalPost = post.reblog ? post.reblog : post;
|
|
|
|
|
this.showSharesModal = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.sharesModal.open();
|
|
|
|
@ -492,19 +520,32 @@
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
counterChange(index, type) {
|
|
|
|
|
let post = this.feed[index];
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'comment-increment':
|
|
|
|
|
this.feed[index].reply_count = this.feed[index].reply_count + 1;
|
|
|
|
|
if(post.reblog != null) {
|
|
|
|
|
this.feed[index].reblog.reply_count = this.feed[index].reblog.reply_count + 1;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].reply_count = this.feed[index].reply_count + 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'comment-decrement':
|
|
|
|
|
this.feed[index].reply_count = this.feed[index].reply_count - 1;
|
|
|
|
|
if(post.reblog != null) {
|
|
|
|
|
this.feed[index].reblog.reply_count = this.feed[index].reblog.reply_count - 1;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].reply_count = this.feed[index].reply_count - 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
openCommentLikesModal(post) {
|
|
|
|
|
this.likesModalPost = post;
|
|
|
|
|
if(post.reblog != null) {
|
|
|
|
|
this.likesModalPost = post.reblog;
|
|
|
|
|
} else {
|
|
|
|
|
this.likesModalPost = post;
|
|
|
|
|
}
|
|
|
|
|
this.showLikesModal = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.likesModal.open();
|
|
|
|
@ -513,33 +554,59 @@
|
|
|
|
|
|
|
|
|
|
shareStatus(index) {
|
|
|
|
|
let status = this.feed[index];
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblogs_count = count + 1;
|
|
|
|
|
this.feed[index].reblogged = !status.reblogged;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
status = status.reblog;
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblog.reblogs_count = count + 1;
|
|
|
|
|
this.feed[index].reblog.reblogged = !status.reblogged;
|
|
|
|
|
} else {
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblogs_count = count + 1;
|
|
|
|
|
this.feed[index].reblogged = !status.reblogged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/statuses/' + status.id + '/reblog')
|
|
|
|
|
.then(res => {
|
|
|
|
|
//
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.feed[index].reblogs_count = count;
|
|
|
|
|
this.feed[index].reblogged = false;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
this.feed[index].reblog.reblogs_count = count;
|
|
|
|
|
this.feed[index].reblog.reblogged = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].reblogs_count = count;
|
|
|
|
|
this.feed[index].reblogged = false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unshareStatus(index) {
|
|
|
|
|
let status = this.feed[index];
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblogs_count = count - 1;
|
|
|
|
|
this.feed[index].reblogged = !status.reblogged;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
status = status.reblog;
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblog.reblogs_count = count - 1;
|
|
|
|
|
this.feed[index].reblog.reblogged = !status.reblogged;
|
|
|
|
|
} else {
|
|
|
|
|
let state = status.reblogged;
|
|
|
|
|
let count = status.reblogs_count;
|
|
|
|
|
this.feed[index].reblogs_count = count - 1;
|
|
|
|
|
this.feed[index].reblogged = !status.reblogged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/statuses/' + status.id + '/unreblog')
|
|
|
|
|
.then(res => {
|
|
|
|
|
//
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.feed[index].reblogs_count = count;
|
|
|
|
|
this.feed[index].reblogged = false;
|
|
|
|
|
if(status.reblog) {
|
|
|
|
|
this.feed[index].reblog.reblogs_count = count;
|
|
|
|
|
this.feed[index].reblog.reblogged = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].reblogs_count = count;
|
|
|
|
|
this.feed[index].reblogged = false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -554,11 +621,19 @@
|
|
|
|
|
handleBookmark(index) {
|
|
|
|
|
let p = this.feed[index];
|
|
|
|
|
|
|
|
|
|
if(p.reblog) {
|
|
|
|
|
p = p.reblog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios.post('/i/bookmark', {
|
|
|
|
|
item: p.id
|
|
|
|
|
})
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.feed[index].bookmarked = !p.bookmarked;
|
|
|
|
|
if(this.feed[index].reblog) {
|
|
|
|
|
this.feed[index].reblog.bookmarked = !p.bookmarked;
|
|
|
|
|
} else {
|
|
|
|
|
this.feed[index].bookmarked = !p.bookmarked;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
// this.feed[index].bookmarked = false;
|
|
|
|
@ -571,31 +646,51 @@
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
follow(index) {
|
|
|
|
|
// this.feed[index].relationship.following = true;
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].account.id + '/follow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count + 1 });
|
|
|
|
|
this.feed[index].account.followers_count = this.feed[index].account.followers_count + 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to follow this account.', 'error');
|
|
|
|
|
this.feed[index].relationship.following = false;
|
|
|
|
|
});
|
|
|
|
|
if(this.feed[index].reblog) {
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].reblog.account.id + '/follow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count + 1 });
|
|
|
|
|
this.feed[index].reblog.account.followers_count = this.feed[index].reblog.account.followers_count + 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to follow this account.', 'error');
|
|
|
|
|
this.feed[index].reblog.relationship.following = false;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].account.id + '/follow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count + 1 });
|
|
|
|
|
this.feed[index].account.followers_count = this.feed[index].account.followers_count + 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to follow this account.', 'error');
|
|
|
|
|
this.feed[index].relationship.following = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unfollow(index) {
|
|
|
|
|
// this.feed[index].relationship.following = false;
|
|
|
|
|
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].account.id + '/unfollow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count - 1 });
|
|
|
|
|
this.feed[index].account.followers_count = this.feed[index].account.followers_count - 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to unfollow this account.', 'error');
|
|
|
|
|
this.feed[index].relationship.following = true;
|
|
|
|
|
});
|
|
|
|
|
if(this.feed[index].reblog) {
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].reblog.account.id + '/unfollow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count - 1 });
|
|
|
|
|
this.feed[index].reblog.account.followers_count = this.feed[index].reblog.account.followers_count - 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to unfollow this account.', 'error');
|
|
|
|
|
this.feed[index].reblog.relationship.following = true;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
axios.post('/api/v1/accounts/' + this.feed[index].account.id + '/unfollow')
|
|
|
|
|
.then(res => {
|
|
|
|
|
this.$store.commit('updateRelationship', [res.data]);
|
|
|
|
|
this.updateProfile({ following_count: this.profile.following_count - 1 });
|
|
|
|
|
this.feed[index].account.followers_count = this.feed[index].account.followers_count - 1;
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
swal('Oops!', 'An error occured when attempting to unfollow this account.', 'error');
|
|
|
|
|
this.feed[index].relationship.following = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateProfile(delta) {
|
|
|
|
|