|
66 | 66 | const allowed_objects = ref({}) |
67 | 67 | const toggle_loading = useToggle(loading) |
68 | 68 |
|
69 | | -
|
70 | | -function select_geode_object(object_map) { |
71 | | - const object_keys = Object.keys(object_map) |
72 | | - if (!object_keys.length) { |
73 | | - return |
74 | | - } |
75 | | - if (object_keys.length === 1 && object_map[object_keys[0]].is_loadable > 0) { |
76 | | - return object_keys[0] |
77 | | - } |
78 | | - const highest_load_score = Math.max( |
79 | | - ...object_keys.map((key) => object_map[key].is_loadable), |
80 | | - ) |
81 | | - if (highest_load_score <= 0) { |
| 69 | + function select_geode_object(object_map) { |
| 70 | + const object_keys = Object.keys(object_map) |
| 71 | + if (!object_keys.length) { |
| 72 | + return |
| 73 | + } |
| 74 | + if ( |
| 75 | + object_keys.length === 1 && |
| 76 | + object_map[object_keys[0]].is_loadable > 0 |
| 77 | + ) { |
| 78 | + return object_keys[0] |
| 79 | + } |
| 80 | + const highest_load_score = Math.max( |
| 81 | + ...object_keys.map((key) => object_map[key].is_loadable), |
| 82 | + ) |
| 83 | + if (highest_load_score <= 0) { |
| 84 | + return |
| 85 | + } |
| 86 | + const best_score_objects = object_keys.filter( |
| 87 | + (key) => object_map[key].is_loadable === highest_load_score, |
| 88 | + ) |
| 89 | + if (best_score_objects.length === 1) { |
| 90 | + return best_score_objects[0] |
| 91 | + } |
| 92 | + const highest_priority = Math.max( |
| 93 | + ...best_score_objects.map( |
| 94 | + (key) => object_map[key].object_priority ?? -Infinity, |
| 95 | + ), |
| 96 | + ) |
| 97 | + const best_priority_objects = best_score_objects.filter( |
| 98 | + (key) => object_map[key].object_priority === highest_priority, |
| 99 | + ) |
| 100 | + if (highest_priority !== -Infinity && best_priority_objects.length === 1) { |
| 101 | + return best_priority_objects[0] |
| 102 | + } |
82 | 103 | return |
83 | 104 | } |
84 | | - const best_score_objects = object_keys.filter( |
85 | | - (key) => object_map[key].is_loadable === highest_load_score, |
86 | | - ) |
87 | | - if (best_score_objects.length === 1) { |
88 | | - return best_score_objects[0] |
89 | | - } |
90 | | - const highest_priority = Math.max( |
91 | | - ...best_score_objects.map( |
92 | | - (key) => object_map[key].object_priority ?? -Infinity, |
93 | | - ), |
94 | | - ) |
95 | | - const best_priority_objects = best_score_objects.filter( |
96 | | - (key) => object_map[key].object_priority === highest_priority, |
97 | | - ) |
98 | | - if (highest_priority !== -Infinity && best_priority_objects.length === 1) { |
99 | | - return best_priority_objects[0] |
100 | | - } |
101 | | - return |
102 | | -} |
103 | 105 |
|
104 | 106 | function select_geode_object(object_map) { |
105 | 107 | const object_keys = Object.keys(object_map) |
|
0 commit comments