wid_edit: restore alphabetical sort

pull/2938/head
Rob Pilling 2023-07-31 22:04:20 +01:00
parent ba995ddf4e
commit 2023138295
4 changed files with 4 additions and 2 deletions

View File

@ -4,3 +4,4 @@
Allow changing widgets into all areas, including bottom widget bar Allow changing widgets into all areas, including bottom widget bar
0.03: Fix editing widgets whose draw method takes the widget 0.03: Fix editing widgets whose draw method takes the widget
0.04: Remove double-sort 0.04: Remove double-sort
0.05: Restore alphabetical sort

View File

@ -14,6 +14,7 @@ Bangle.loadWidgets = (o => ()=>{
const W = global.WIDGETS; const W = global.WIDGETS;
global.WIDGETS = {}; global.WIDGETS = {};
Object.keys(W) Object.keys(W)
.sort() // sort alphabetically. the next sort is stable and preserves this if sortorder matches
.sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder)) .sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder))
.forEach(k => global.WIDGETS[k] = W[k]); .forEach(k => global.WIDGETS[k] = W[k]);
})(Bangle.loadWidgets); })(Bangle.loadWidgets);

View File

@ -1,6 +1,6 @@
{ {
"id": "wid_edit", "id": "wid_edit",
"version": "0.04", "version": "0.05",
"name": "Widget Editor", "name": "Widget Editor",
"icon": "icon.png", "icon": "icon.png",
"description": "Customize widget locations", "description": "Customize widget locations",

View File

@ -27,7 +27,7 @@
let W = global.WIDGETS; let W = global.WIDGETS;
global.WIDGETS = {}; global.WIDGETS = {};
Object.keys(W) Object.keys(W)
.sort() .sort() // see comment in boot.js
.sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder)) .sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder))
.forEach(k => {global.WIDGETS[k] = W[k];}); .forEach(k => {global.WIDGETS[k] = W[k];});
Bangle.drawWidgets(); Bangle.drawWidgets();