Skip to content

Node.js based forum software built for the modern web

upgrade script, and fixed client-side generation of user icon

Julian Lama43d40fbc70e
diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js
index 22e69c5498..59b8a311ab 100644
--- a/public/src/client/account/edit.js
+++ b/public/src/client/account/edit.js
@@ -349,7 +349,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
$('#user-uploaded-picture').attr('src', uploadedPicture);
}
- $('#default-box').toggle(true).find('.user-icon').css('background-color', ajaxify.data['icon:bgColor']).text(ajaxify.data['username'].slice(0, 1));
+ $('#default-box').toggle(true).find('.user-icon').css('background-color', ajaxify.data['icon:bgColor']).text(ajaxify.data['username'].slice(0, 1).toUpperCase());
$('#uploaded-box').toggle(!!uploadedPicture);
$('#default-box .fa-check').toggle(currentPicture !== uploadedPicture);
diff --git a/src/upgrade.js b/src/upgrade.js
index 0e0b2a0954..f7fa3eed2e 100644
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@ -21,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
- latestSchema = Date.UTC(2015, 7, 18);
+ latestSchema = Date.UTC(2015, 8, 27);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@@ -486,6 +486,27 @@ Upgrade.upgrade = function(callback) {
winston.info('[2015/08/18] Creating children category sorted sets skipped');
next();
}
+ },
+ function(next) {
+ thisSchemaDate = Date.UTC(2015, 8, 27);
+ if (schemaDate < thisSchemaDate) {
+ updatesMade = true;
+ winston.info('[2015/09/27] Generating user icons');
+
+ db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
+ async.eachLimit(uids, 20, User.icon.generate, function(err) {
+ if (err) {
+ return next(err);
+ }
+
+ winston.info('[2015/09/27] Generating user icons done');
+ Upgrade.update(thisSchemaDate, next);
+ })
+ })
+ } else {
+ winston.info('[2015/09/27] Generating user icons skipped');
+ next();
+ }
}
diff --git a/src/user/icon.js b/src/user/icon.js
index 361b37d9ad..fbf9274492 100644
--- a/src/user/icon.js
+++ b/src/user/icon.js
@@ -8,7 +8,7 @@ module.exports = function(User) {
User.icon.generate = function(uid, callback) {
// For convenience, only backgrounds that work well with white as used
var backgrounds = ['#AB4642', '#DC9656', '#A1B56C', '#7CAFC2', '#BA8BAF', '#A16946'],
- bgColor = backgrounds[Math.floor(Math.random() * backgrounds.length) + 1];
+ bgColor = backgrounds[Math.floor(Math.random() * backgrounds.length)];
User.getUserField(uid, 'username', function(err, username) {
User.setUserFields(uid, {