Skip to content

Commit 1d23e36

Browse files
authored
find and move 'Clock' to the front of the list in a more robust way
1 parent c31e982 commit 1d23e36

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/bigclkinfo/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ let clock_info = require("clock_info");
1313

1414
// Load the clock infos
1515
let clockInfoItems = clock_info.load();
16-
if (clockInfoItems[0].items[6]) { // TODO: Should maybe be more robust against changes to clock info, i.e. search for "clock" among items.
17-
let clockItem = clockInfoItems[0].items.pop();
18-
clockInfoItems[0].items.unshift(clockItem);
16+
let clockInfoClockIdx = clockInfoItems[0].items.findIndex(c => c.name=="Clock");
17+
if (clockInfoClockIdx>0) { // pull the clock to the front (if it exists and not there already)
18+
let clockInfoClock = clockInfoItems[0].items[clockInfoClockIdx];
19+
clockInfoItems[0].items.splice(clockInfoClockIdx,1); // remove
20+
clockInfoItems[0].items.unshift(clockInfoClock); // add to front
1921
}
2022
// Add the
2123
let clockInfoMenu = clock_info.addInteractive(clockInfoItems, {

0 commit comments

Comments
 (0)