* Remove message_area_desc property -- just fetch it
This commit is contained in:
parent
150bd5778a
commit
1cb95bd44e
|
@ -11,6 +11,7 @@ var ToggleMenuView = require('./toggle_menu_view.js').ToggleMenuView;
|
||||||
var MaskEditTextView = require('./mask_edit_text_view.js').MaskEditTextView;
|
var MaskEditTextView = require('./mask_edit_text_view.js').MaskEditTextView;
|
||||||
var StatusBarView = require('./status_bar_view.js').StatusBarView;
|
var StatusBarView = require('./status_bar_view.js').StatusBarView;
|
||||||
var MultiLineEditTextView = require('./multi_line_edit_text_view.js').MultiLineEditTextView;
|
var MultiLineEditTextView = require('./multi_line_edit_text_view.js').MultiLineEditTextView;
|
||||||
|
var getMessageAreaByName = require('./message_area.js').getMessageAreaByName;
|
||||||
|
|
||||||
var Config = require('./config.js').config;
|
var Config = require('./config.js').config;
|
||||||
var ansi = require('./ansi_term.js');
|
var ansi = require('./ansi_term.js');
|
||||||
|
@ -29,6 +30,14 @@ function MCIViewFactory(client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
function getMessageAreaDescription() {
|
||||||
|
var area = getMessageAreaByName(self.client.user.properties.message_area_name);
|
||||||
|
return area ? area.desc : '';
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
BN : Config.general.boardName,
|
BN : Config.general.boardName,
|
||||||
|
@ -49,7 +58,7 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
||||||
UT : this.client.user.properties.theme_id,
|
UT : this.client.user.properties.theme_id,
|
||||||
MS : moment(this.client.user.properties.account_created).format(this.client.currentTheme.helpers.getDateFormat()),
|
MS : moment(this.client.user.properties.account_created).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||||
|
|
||||||
MA : this.client.user.properties.message_area_desc,
|
MA : getMessageAreaDescription(),
|
||||||
|
|
||||||
|
|
||||||
SH : this.client.term.termHeight.toString(),
|
SH : this.client.term.termHeight.toString(),
|
||||||
|
|
|
@ -9,17 +9,32 @@ var _ = require('lodash');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
exports.getAvailableMessageAreas = getAvailableMessageAreas;
|
exports.getAvailableMessageAreas = getAvailableMessageAreas;
|
||||||
|
exports.getMessageAreaByName = getMessageAreaByName;
|
||||||
exports.changeMessageArea = changeMessageArea;
|
exports.changeMessageArea = changeMessageArea;
|
||||||
|
|
||||||
function getAvailableMessageAreas() {
|
function getAvailableMessageAreas() {
|
||||||
return Config.messages.areas;
|
return Config.messages.areas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMessageAreaByName(areaName) {
|
||||||
|
areaName = areaName.toLowerCase();
|
||||||
|
|
||||||
|
var availAreas = getAvailableMessageAreas();
|
||||||
|
var index = _.findIndex(availAreas, function pred(an) {
|
||||||
|
return an.name == areaName;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(index > -1) {
|
||||||
|
return availAreas[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function changeMessageArea(client, areaName, cb) {
|
function changeMessageArea(client, areaName, cb) {
|
||||||
|
|
||||||
async.waterfall(
|
async.waterfall(
|
||||||
[
|
[
|
||||||
function getArea(callback) {
|
function getArea(callback) {
|
||||||
|
/*
|
||||||
var availAreas = getAvailableMessageAreas();
|
var availAreas = getAvailableMessageAreas();
|
||||||
|
|
||||||
areaName = areaName.toLowerCase(); // always lookup lowercase
|
areaName = areaName.toLowerCase(); // always lookup lowercase
|
||||||
|
@ -32,13 +47,21 @@ function changeMessageArea(client, areaName, cb) {
|
||||||
} else {
|
} else {
|
||||||
callback(new Error('Invalid message area'));
|
callback(new Error('Invalid message area'));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
var area = getMessageAreaByName(areaName);
|
||||||
|
if(area) {
|
||||||
|
callback(null, area);
|
||||||
|
} else {
|
||||||
|
callback(new Error('Invalid message area'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
function validateAccess(area, callback) {
|
function validateAccess(area, callback) {
|
||||||
// :TODO: validate user has access to |area| -- must belong to group(s) specified
|
// :TODO: validate user has access to |area| -- must belong to group(s) specified
|
||||||
callback(null, area);
|
callback(null, area);
|
||||||
},
|
},
|
||||||
function changeArea(area, callback) {
|
function changeArea(area, callback) {
|
||||||
client.user.persistProperties( { message_area_name : area.name, message_area_desc : area.desc }, function persisted(err) {
|
client.user.persistProperty('message_area_name', area.name, function persisted(err) {
|
||||||
callback(err, area);
|
callback(err, area);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,9 +197,7 @@ User.prototype.create = function(options, cb) {
|
||||||
if(1 === self.userId) {
|
if(1 === self.userId) {
|
||||||
self.properties.account_status = User.AccountStatus.active;
|
self.properties.account_status = User.AccountStatus.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue