Skip to content

Commit a4e43a4

Browse files
committed
Fix shell app ordering
1 parent 5bee6a9 commit a4e43a4

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

Applications/Shell/Shell.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,53 @@ void Shell::InitializeFolderSystem() {
9393
// Check if any apps are missing from the folders and add them to appropriate folders
9494
bool missing_apps_found = false;
9595

96-
// Check all apps in all_applications (includes both native and Python apps)
97-
for (const auto& [app_id, app_entry] : all_applications) {
96+
// First, check native apps in registration order
97+
for (const auto& [order_id, app_id] : application_ids) {
9898
// If app is not in any folder, add it
9999
if (apps_in_folders.find(app_id) == apps_in_folders.end()) {
100-
uint8_t folder_id = GetAppFolder(app_id, app_entry);
100+
auto app_entry_it = all_applications.find(app_id);
101+
if (app_entry_it == all_applications.end()) {
102+
continue;
103+
}
104+
105+
uint8_t folder_id = GetAppFolder(app_id, app_entry_it->second);
101106

102107
// Add to the appropriate folder
103108
folders[folder_id].app_ids.push_back(app_id);
104109
missing_apps_found = true;
105110

106-
Application_Info* info = (app_entry.type == ApplicationType::Native) ?
107-
app_entry.native.info :
108-
&(app_entry.python.info->info);
109-
MLOGD("Shell", "Added app %s-%s to folder %d",
111+
Application_Info* info = app_entry_it->second.native.info;
112+
MLOGD("Shell", "Added native app %s-%s to folder %d",
110113
info->author.c_str(),
111114
info->name.c_str(),
112115
folder_id);
113116
}
114117
}
115118

119+
// Then, check Python apps in discovery order
120+
for (auto& py_app : python_app_infos) {
121+
uint32_t app_id = StringHash(py_app.info.author + "-" + py_app.info.name);
122+
123+
// If app is not in any folder, add it
124+
if (apps_in_folders.find(app_id) == apps_in_folders.end()) {
125+
auto app_entry_it = all_applications.find(app_id);
126+
if (app_entry_it == all_applications.end()) {
127+
continue;
128+
}
129+
130+
uint8_t folder_id = GetAppFolder(app_id, app_entry_it->second);
131+
132+
// Add to the appropriate folder
133+
folders[folder_id].app_ids.push_back(app_id);
134+
missing_apps_found = true;
135+
136+
MLOGD("Shell", "Added Python app %s-%s to folder %d",
137+
py_app.info.author.c_str(),
138+
py_app.info.name.c_str(),
139+
folder_id);
140+
}
141+
}
142+
116143
// Save vectors if we loaded existing ones but found missing apps, or if no folders were loaded
117144
if (missing_apps_found || !folders_loaded) {
118145
SaveAllFolderVectors();

0 commit comments

Comments
 (0)