Crash on delete in BBS List with zero entries #156

This commit is contained in:
Bryan Ashby 2018-03-13 19:10:20 -06:00
parent 534b51933a
commit 66423068b1
1 changed files with 5 additions and 0 deletions

View File

@ -99,6 +99,10 @@ exports.getModule = class BBSListModule extends MenuModule {
self.displayAddScreen(cb);
},
deleteBBS : function(formData, extraArgs, cb) {
if(!_.isNumber(self.selectedBBS) || 0 === self.entries.length) {
return cb(null);
}
const entriesView = self.viewControllers.view.getView(MciViewIds.view.BBSList);
if(self.entries[self.selectedBBS].submitterUserId !== self.client.user.userId && !self.client.user.isSysOp()) {
@ -323,6 +327,7 @@ exports.getModule = class BBSListModule extends MenuModule {
entriesView.setFocusItemIndex(self.selectedBBS);
self.drawSelectedEntry(self.entries[self.selectedBBS]);
} else if (self.entries.length > 0) {
self.selectedBBS = 0;
entriesView.setFocusItemIndex(0);
self.drawSelectedEntry(self.entries[0]);
}