fixed a crash if user profile is viewed when they have no posts, fixed the footer user link it uses the userslug now

v1.18.x
Baris Soner Usakli 12 years ago
parent 119708bc8a
commit caf81b7312

@ -15,7 +15,7 @@
if (data.username == '') {
latest_user.innerHTML = '';
} else {
latest_user.innerHTML = "The most recent user to register is <b><a href='/users/"+data.username+"'>" + data.username + "</a></b>.";
latest_user.innerHTML = "The most recent user to register is <b><a href='/users/"+data.userslug+"'>" + data.username + "</a></b>.";
}
});
socket.emit('api:user.active.get');

@ -311,22 +311,27 @@ marked.setOptions({
RDB.lrange('uid:' + uid + ':posts', 0, 10, function(err, pids) {
if(err === null) {
Posts.getPostsByPids(pids, uid, function(posts) {
var returnData = [];
var len = posts.postData.pid.length;
for (var i=0; i < len; ++i) {
returnData.push({
pid: posts.postData.pid[i],
content: posts.postData.content[i],
timestamp: utils.relativeTime(posts.postData.timestamp[i]),
tid: posts.postData.tid[i]
});
};
callback(returnData);
});
if(pids && pids.length) {
Posts.getPostsByPids(pids, uid, function(posts) {
var returnData = [];
var len = posts.postData.pid.length;
for (var i=0; i < len; ++i) {
returnData.push({
pid: posts.postData.pid[i],
content: posts.postData.content[i],
timestamp: utils.relativeTime(posts.postData.timestamp[i]),
tid: posts.postData.tid[i]
});
};
callback(returnData);
});
}
else
callback([]);
}
});
}

@ -151,7 +151,7 @@ var utils = require('./../public/src/utils.js'),
RDB.del('followers:' + uid);
RDB.del('following:' + uid);
RDB.lrem('userlist', 1, uid);
RDB.lrem('userlist', 1, data['username']);
callback(true);
});
@ -219,7 +219,7 @@ var utils = require('./../public/src/utils.js'),
});
RDB.lpush('userlist', username);
io.sockets.emit('user.latest', {username: username});
io.sockets.emit('user.latest', {userslug: userslug, username: username});
callback(null, uid);
@ -438,7 +438,13 @@ var utils = require('./../public/src/utils.js'),
User.latest = function(socket) {
RDB.lrange('userlist', 0, 0, function(err, username) {
RDB.handle(err);
socket.emit('user.latest', {username: username});
User.get_uid_by_username(username, function(uid) {
User.getUserField(uid, 'userslug', function(userslug) {
socket.emit('user.latest', {userslug: userslug, username: username});
});
});
});
}

Loading…
Cancel
Save