* DRY menu pop/goto into reloadMenu() (temp hack until we can find a good solution for simple redraw)
* Only reloadMenu() if we actually change areas * Code style cleanup
This commit is contained in:
parent
34b72d5040
commit
c94f663947
|
@ -78,101 +78,69 @@ function nextMenu(callingMenu) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function prevConf(callingMenu) {
|
// :TODO: prev/nextConf, prev/nextArea should use a NYI MenuModule.redraw() or such -- avoid pop/goto() hack!
|
||||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
function reloadMenu(menu) {
|
||||||
|
const prevMenu = menu.client.menuStack.pop();
|
||||||
let curr_idx = confs.findIndex((e) => {
|
|
||||||
if (e.confTag === callingMenu.client.user.properties.message_conf_tag) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (curr_idx === 0) {
|
|
||||||
curr_idx = confs.length;
|
|
||||||
}
|
|
||||||
messageArea.changeMessageConference(callingMenu.client, confs[curr_idx - 1].confTag, err => {
|
|
||||||
if (err) {
|
|
||||||
//...
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
|
||||||
prevMenu.instance.leave();
|
prevMenu.instance.leave();
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
menu.client.menuStack.goto(prevMenu.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prevConf(callingMenu) {
|
||||||
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
|
const currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag) || confs.length;
|
||||||
|
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, confs[currIndex - 1].confTag, err => {
|
||||||
|
if(err) {
|
||||||
|
return; // logged within changeMessageConference()
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadMenu(callingMenu);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextConf(callingMenu) {
|
function nextConf(callingMenu) {
|
||||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
|
let currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag);
|
||||||
|
|
||||||
let curr_idx = confs.findIndex((e) => {
|
if(currIndex === confs.length - 1) {
|
||||||
if (e.confTag === callingMenu.client.user.properties.message_conf_tag) {
|
currIndex = -1;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (curr_idx === confs.length - 1) {
|
|
||||||
curr_idx = -1;
|
|
||||||
}
|
}
|
||||||
messageArea.changeMessageConference(callingMenu.client, confs[curr_idx + 1].confTag, err => {
|
|
||||||
if (err) {
|
messageArea.changeMessageConference(callingMenu.client, confs[currIndex + 1].confTag, err => {
|
||||||
//...
|
if(err) {
|
||||||
|
return; // logged within changeMessageConference()
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
reloadMenu(callingMenu);
|
||||||
});
|
});
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
|
||||||
prevMenu.instance.leave();
|
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prevArea(callingMenu) {
|
function prevArea(callingMenu) {
|
||||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||||
|
const currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag) || areas.length;
|
||||||
|
|
||||||
let curr_idx = areas.findIndex((e) => {
|
messageArea.changeMessageArea(callingMenu.client, areas[currIndex - 1].areaTag, err => {
|
||||||
if (e.areaTag === callingMenu.client.user.properties.message_area_tag) {
|
if(err) {
|
||||||
return true;
|
return; // logged within changeMessageArea()
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
reloadMenu(callingMenu);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (curr_idx === 0) {
|
|
||||||
curr_idx = areas.length;
|
|
||||||
}
|
|
||||||
messageArea.changeMessageArea(callingMenu.client, areas[curr_idx - 1].areaTag, err => {
|
|
||||||
if (err) {
|
|
||||||
//...
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
|
||||||
prevMenu.instance.leave();
|
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextArea(callingMenu) {
|
function nextArea(callingMenu) {
|
||||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||||
|
let currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag);
|
||||||
|
|
||||||
let curr_idx = areas.findIndex((e) => {
|
if(currIndex === areas.length - 1) {
|
||||||
if (e.areaTag === callingMenu.client.user.properties.message_area_tag) {
|
currIndex = -1;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (curr_idx === areas.length - 1) {
|
|
||||||
curr_idx = -1;
|
|
||||||
}
|
}
|
||||||
messageArea.changeMessageArea(callingMenu.client, areas[curr_idx + 1].areaTag, err => {
|
|
||||||
if (err) {
|
|
||||||
//...
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
messageArea.changeMessageArea(callingMenu.client, areas[currIndex + 1].areaTag, err => {
|
||||||
prevMenu.instance.leave();
|
if(err) {
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
return; // logged within changeMessageArea()
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadMenu(callingMenu);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue