Fix issue where the favorite preset button could be stale

Use first in, first out favoriting order
This commit is contained in:
Quincy Morgan
2019-02-27 13:13:15 -05:00
parent 0fe4513e2a
commit b302d853ac
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -325,12 +325,13 @@ export function coreContext() {
return !(d.id === preset.id && d.geom === geom);
});
} else {
//only allow 3 favorites
//replace the last one
// only allow 3 favorites
if (favs.length === 3) {
favs = favs.slice(0,2);
// remove the last favorite (first in, first out)
favs.pop();
}
favs.push({id: preset.id, geom: geom});
// prepend array
favs.unshift({id: preset.id, geom: geom});
}
context.storage('favorite_presets', JSON.stringify(favs));
+1 -1
View File
@@ -340,8 +340,8 @@ export function uiEntityEditor(context) {
_activePreset = val;
_tagReference = uiTagReference(_activePreset.reference(context.geometry(_entityID)), context)
.showing(false);
_presetFavorite = uiPresetFavorite(_activePreset, context.geometry(_entityID), context);
}
_presetFavorite = uiPresetFavorite(_activePreset, context.geometry(_entityID), context);
return entityEditor;
};