v1.18.x
Baris Soner Usakli 12 years ago
parent f7f5da00e1
commit 4527b3d53c

@ -182,14 +182,16 @@ var RDB = require('./redis.js'),
topicData.teaser_username = topicInfo.teaserInfo.username; topicData.teaser_username = topicInfo.teaserInfo.username;
topicData.teaser_userpicture = topicInfo.teaserInfo.picture; topicData.teaser_userpicture = topicInfo.teaserInfo.picture;
topicData.teaser_timestamp = utils.relativeTime(topicInfo.teaserInfo.timestamp); topicData.teaser_timestamp = utils.relativeTime(topicInfo.teaserInfo.timestamp);
if (isTopicVisible(topicData, topicInfo)) if (isTopicVisible(topicData, topicInfo))
retrieved_topics.push(topicData); retrieved_topics.push(topicData);
else else
--topicCountToLoad; --topicCountToLoad;
if(retrieved_topics.length === topicCountToLoad) if(retrieved_topics.length === topicCountToLoad) {
console.log('derp');
callback(retrieved_topics); callback(retrieved_topics);
}
}); });
}); });
} }

@ -293,14 +293,19 @@ marked.setOptions({
while(numPosts--) { while(numPosts--) {
if(posts[numPosts].deleted !== '1') { if(posts[numPosts].deleted !== '1') {
callback(posts[numPosts].pid); callback(posts[numPosts].pid);
break; return;
} }
} }
if(posts.length > 0)
callback(posts[0].pid);
else
callback(null);
}); });
} }
Topics.getTeaser = function(tid, callback) { Topics.getTeaser = function(tid, callback) {
Topics.get_latest_undeleted_pid(tid, function(pid) { Topics.get_latest_undeleted_pid(tid, function(pid) {
console.log(pid);
if (pid !== null) { if (pid !== null) {
posts.getPostFields(pid, ['content', 'uid', 'timestamp'], function(postData) { posts.getPostFields(pid, ['content', 'uid', 'timestamp'], function(postData) {
@ -320,6 +325,13 @@ marked.setOptions({
}); });
}); });
}); });
} else {
callback({
"text": "",
"username": "",
"picture": "",
"timestamp" : ""
});
} }
}); });
} }

Loading…
Cancel
Save