fix(forums): fixed logic issue when delete first reply in any topic

This commit is contained in:
OldHawk
2018-06-27 17:47:49 +08:00
parent a7bd2696ed
commit 3dcda6a102

View File

@@ -1029,8 +1029,13 @@ exports.deleteReply = function (req, res) {
if (lastReply === r) {
lastReply = topic._replies[topic._replies.length - 2];
}
topic.lastReplyAt = lastReply.createdAt;
topic.lastUser = lastReply.user;
if (lastReply) {
topic.lastReplyAt = lastReply.createdAt;
topic.lastUser = lastReply.user;
} else {
topic.lastReplyAt = undefined;
topic.lastUser = undefined;
}
topic.save(function (err) {
if (err) {