Skip to content
Snippets Groups Projects
Commit d8dd9b5e authored by Kayz's avatar Kayz
Browse files

fix issues with favorites menu/add favorites when user has no favorites

parent 6cbf4034
No related branches found
No related tags found
No related merge requests found
...@@ -1830,7 +1830,7 @@ function favorites_menu(title, itemcount) { ...@@ -1830,7 +1830,7 @@ function favorites_menu(title, itemcount) {
bbs.menu("xtrn_head", P_NOERROR); bbs.menu("xtrn_head", P_NOERROR);
} }
menuitemsfiltered = typeof menuobj.items !== "undefined" ? menuobj.items : {}; menuitemsfiltered = typeof menuobj.items !== "undefined" ? menuobj.items : [];
// The quit item is intended to aid in the lightbar navigation // The quit item is intended to aid in the lightbar navigation
menuitemsfiltered.unshift({ menuitemsfiltered.unshift({
...@@ -2022,8 +2022,10 @@ function favorites_menu(title, itemcount) { ...@@ -2022,8 +2022,10 @@ function favorites_menu(title, itemcount) {
return; return;
} else if (menuitemsfiltered[selected_index].type == "add") { } else if (menuitemsfiltered[selected_index].type == "add") {
add_favorite(); add_favorite();
continue;
} else if (menuitemsfiltered[selected_index].type == "remove") { } else if (menuitemsfiltered[selected_index].type == "remove") {
remove_favorite(); remove_favorite();
continue;
} }
} else if ((keyin == 'q') || (keyin == "\x1B")) { } else if ((keyin == 'q') || (keyin == "\x1B")) {
console.clear(); console.clear();
...@@ -2240,6 +2242,7 @@ function add_favorite() ...@@ -2240,6 +2242,7 @@ function add_favorite()
key = console.getkey(K_NOSPIN); key = console.getkey(K_NOSPIN);
if (key == "\x0d") { if (key == "\x0d") {
// hit enter, item is selected // hit enter, item is selected
xtrn = tree.currentItem;
break; break;
} else if ((key.toLowerCase() == 'q') || (key == "\x1B")) { } else if ((key.toLowerCase() == 'q') || (key == "\x1B")) {
return; return;
...@@ -2248,6 +2251,7 @@ function add_favorite() ...@@ -2248,6 +2251,7 @@ function add_favorite()
break; break;
} else { } else {
selection = tree.getcmd({key: key, mouse: false}); selection = tree.getcmd({key: key, mouse: false});
xtrn = tree.currentItem;
if (key == KEY_UP || key == KEY_DOWN || key == KEY_HOME || key == KEY_END) { if (key == KEY_UP || key == KEY_DOWN || key == KEY_HOME || key == KEY_END) {
if ((key == KEY_UP) && (tree.line == 1)) { if ((key == KEY_UP) && (tree.line == 1)) {
...@@ -2267,7 +2271,7 @@ function add_favorite() ...@@ -2267,7 +2271,7 @@ function add_favorite()
s.cycle(); s.cycle();
} }
if (typeof xtrn.code !== "undefined") { if ((typeof xtrn !== "undefined") && (typeof xtrn.code !== "undefined")) {
jsonData.push(xtrn.code); jsonData.push(xtrn.code);
jsonClient.write("xtrnmenu", "favorites_" + user.alias, jsonData, 2); jsonClient.write("xtrnmenu", "favorites_" + user.alias, jsonData, 2);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment