remove parseInts

This commit is contained in:
Barış Soner Uşaklı
2018-10-25 17:02:59 -04:00
parent aca50f1fe1
commit f3a679e268
42 changed files with 103 additions and 137 deletions

View File

@@ -60,9 +60,8 @@ module.exports = function (SocketPosts) {
function (results, next) {
var posts = results.posts;
posts.tools = results.tools.tools;
posts.deleted = parseInt(posts.deleted, 10) === 1;
posts.bookmarked = results.bookmarked;
posts.selfPost = socket.uid && socket.uid === parseInt(posts.uid, 10);
posts.selfPost = socket.uid && socket.uid === posts.uid;
posts.display_edit_tools = results.canEdit.flag;
posts.display_delete_tools = results.canDelete.flag;
posts.display_purge_tools = results.canPurge;
@@ -226,9 +225,9 @@ module.exports = function (SocketPosts) {
posts.getTopicFields(pid, ['tid', 'cid', 'deleted'], next);
},
function (topic, next) {
if (parseInt(topic.deleted, 10) !== 1 && command === 'delete') {
if (command === 'delete' && !topic.deleted) {
socketTopics.doTopicAction('delete', 'event:topic_deleted', socket, { tids: [topic.tid], cid: topic.cid }, next);
} else if (parseInt(topic.deleted, 10) === 1 && command === 'restore') {
} else if (command === 'restore' && topic.deleted) {
socketTopics.doTopicAction('restore', 'event:topic_restored', socket, { tids: [topic.tid], cid: topic.cid }, next);
} else {
setImmediate(next);
@@ -244,7 +243,7 @@ module.exports = function (SocketPosts) {
},
isLast: function (next) {
posts.getTopicFields(pid, ['postcount'], function (err, topic) {
next(err, topic ? parseInt(topic.postcount, 10) === 1 : false);
next(err, topic ? topic.postcount === 1 : false);
});
},
}, callback);