mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-23 19:20:41 +02:00
* Use more standard code paths & emit index events in ToggleMenuView
* Fix fetching areas & internal message attach area name * Use proper config in new MenuModule methods * More good progress on uploading
This commit is contained in:
parent
0a92eec5e8
commit
a45142f2fd
7 changed files with 205 additions and 45 deletions
|
@ -404,7 +404,7 @@ function getDefaultConfig() {
|
|||
},
|
||||
|
||||
areas: {
|
||||
systemm_message_attachment : {
|
||||
system_message_attachment : {
|
||||
name : 'Message attachments',
|
||||
desc : 'File attachments to messages',
|
||||
storageTags : 'sys_msg_attach', // may be string or array of strings
|
||||
|
|
|
@ -19,8 +19,10 @@ const paths = require('path');
|
|||
const temp = require('temp').track(); // track() cleans up temp dir/files for us
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
exports.isInternalArea = isInternalArea;
|
||||
exports.getAvailableFileAreas = getAvailableFileAreas;
|
||||
exports.getSortedAvailableFileAreas = getSortedAvailableFileAreas;
|
||||
exports.getAreaDefaultStorageDirectory = getAreaDefaultStorageDirectory;
|
||||
exports.getDefaultFileAreaTag = getDefaultFileAreaTag;
|
||||
exports.getFileAreaByTag = getFileAreaByTag;
|
||||
exports.getFileEntryPath = getFileEntryPath;
|
||||
|
@ -30,20 +32,23 @@ exports.scanFileAreaForChanges = scanFileAreaForChanges;
|
|||
|
||||
const WellKnownAreaTags = exports.WellKnownAreaTags = {
|
||||
Invalid : '',
|
||||
MessageAreaAttach : 'message_area_attach',
|
||||
MessageAreaAttach : 'system_message_attachment',
|
||||
};
|
||||
|
||||
function isInternalArea(areaTag) {
|
||||
return areaTag === WellKnownAreaTags.MessageAreaAttach;
|
||||
}
|
||||
|
||||
function getAvailableFileAreas(client, options) {
|
||||
options = options || { };
|
||||
|
||||
// perform ACS check per conf & omit system_internal if desired
|
||||
const areasWithTags = _.map(Config.fileBase.areas, (area, areaTag) => Object.assign(area, { areaTag : areaTag } ) );
|
||||
// perform ACS check per conf & omit internal if desired
|
||||
return _.omit(Config.fileBase.areas, (area, areaTag) => {
|
||||
if(!options.includeSystemInternal && WellKnownAreaTags.MessageAreaAttach === areaTag) {
|
||||
if(!options.includeSystemInternal && isInternalArea(areaTag)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(options.writeAcs && !client.acs.FileAreaWrite(area)) {
|
||||
if(options.writeAcs && !client.acs.hasFileAreaWrite(area)) {
|
||||
return true; // omit
|
||||
}
|
||||
|
||||
|
@ -122,16 +127,10 @@ function getAreaStorageDirectoryByTag(storageTag) {
|
|||
const storageLocation = (storageTag && Config.fileBase.storageTags[storageTag]);
|
||||
|
||||
return paths.resolve(Config.fileBase.areaStoragePrefix, storageLocation || '');
|
||||
|
||||
/*
|
||||
// absolute paths as-is
|
||||
if(storageLocation && '/' === storageLocation.charAt(0)) {
|
||||
return storageLocation;
|
||||
}
|
||||
}
|
||||
|
||||
// relative to |areaStoragePrefix|
|
||||
return paths.join(Config.fileBase.areaStoragePrefix, storageLocation || '');
|
||||
*/
|
||||
function getAreaDefaultStorageDirectory(areaInfo) {
|
||||
return getAreaStorageDirectoryByTag(areaInfo.storageTags[0]);
|
||||
}
|
||||
|
||||
function getAreaStorageLocations(areaInfo) {
|
||||
|
|
|
@ -340,7 +340,7 @@ MenuModule.prototype.displayAsset = function(name, options, cb) {
|
|||
return theme.displayThemedAsset(
|
||||
name,
|
||||
this.client,
|
||||
Object.merge( { font : this.menuConfig.config }, options ),
|
||||
Object.assign( { font : this.menuConfig.config.font }, options ),
|
||||
(err, artData) => {
|
||||
if(cb) {
|
||||
return cb(err, artData);
|
||||
|
@ -376,7 +376,7 @@ MenuModule.prototype.prepViewController = function(name, formId, artData, cb) {
|
|||
|
||||
MenuModule.prototype.prepViewControllerWithArt = function(name, formId, options, cb) {
|
||||
this.displayAsset(
|
||||
name,
|
||||
this.menuConfig.config.art[name],
|
||||
options,
|
||||
(err, artData) => {
|
||||
if(err) {
|
||||
|
|
|
@ -92,12 +92,10 @@ MenuView.prototype.getItem = function(index) {
|
|||
};
|
||||
|
||||
MenuView.prototype.focusNext = function() {
|
||||
// nothing @ base currently
|
||||
this.emit('index update', this.focusedItemIndex);
|
||||
};
|
||||
|
||||
MenuView.prototype.focusPrevious = function() {
|
||||
// nothign @ base currently
|
||||
this.emit('index update', this.focusedItemIndex);
|
||||
};
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@ function ToggleMenuView (options) {
|
|||
*/
|
||||
|
||||
this.updateSelection = function() {
|
||||
//assert(!self.positionCacheExpired);
|
||||
assert(this.focusedItemIndex >= 0 && this.focusedItemIndex <= self.items.length);
|
||||
|
||||
self.redraw();
|
||||
};
|
||||
}
|
||||
|
@ -74,28 +72,38 @@ ToggleMenuView.prototype.setFocus = function(focused) {
|
|||
this.redraw();
|
||||
};
|
||||
|
||||
ToggleMenuView.prototype.onKeyPress = function(ch, key) {
|
||||
if(key) {
|
||||
var needsUpdate;
|
||||
if(this.isKeyMapped('right', key.name) || this.isKeyMapped('down', key.name)) {
|
||||
if(this.items.length - 1 === this.focusedItemIndex) {
|
||||
this.focusedItemIndex = 0;
|
||||
} else {
|
||||
this.focusedItemIndex++;
|
||||
}
|
||||
needsUpdate = true;
|
||||
} else if(this.isKeyMapped('left', key.name) || this.isKeyMapped('up', key.name)) {
|
||||
if(0 === this.focusedItemIndex) {
|
||||
this.focusedItemIndex = this.items.length - 1;
|
||||
} else {
|
||||
this.focusedItemIndex--;
|
||||
}
|
||||
needsUpdate = true;
|
||||
}
|
||||
ToggleMenuView.prototype.focusNext = function() {
|
||||
if(this.items.length - 1 === this.focusedItemIndex) {
|
||||
this.focusedItemIndex = 0;
|
||||
} else {
|
||||
this.focusedItemIndex++;
|
||||
}
|
||||
|
||||
if(needsUpdate) {
|
||||
this.updateSelection();
|
||||
return;
|
||||
this.updateSelection();
|
||||
|
||||
ToggleMenuView.super_.prototype.focusNext.call(this);
|
||||
};
|
||||
|
||||
ToggleMenuView.prototype.focusPrevious = function() {
|
||||
|
||||
if(0 === this.focusedItemIndex) {
|
||||
this.focusedItemIndex = this.items.length - 1;
|
||||
} else {
|
||||
this.focusedItemIndex--;
|
||||
}
|
||||
|
||||
this.updateSelection();
|
||||
|
||||
ToggleMenuView.super_.prototype.focusPrevious.call(this);
|
||||
};
|
||||
|
||||
ToggleMenuView.prototype.onKeyPress = function(ch, key) {
|
||||
|
||||
if(key) {
|
||||
if(this.isKeyMapped('right', key.name) || this.isKeyMapped('down', key.name)) {
|
||||
this.focusNext();
|
||||
} else if(this.isKeyMapped('left', key.name) || this.isKeyMapped('up', key.nam4e)) {
|
||||
this.focusPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue