fix(secubox): resolve race condition in appstore and modules data loading
Fixed issue where first page load would show empty apps/modules list, requiring a refresh to display data. Changes: - Added error handling in refreshData() for both apps.js and modules.js - Added null/empty data checks before storing results - Fixed render() to use data parameter first, then fallback to cached instance data - Added console logging for debugging empty responses - Added user-friendly error notifications when API calls fail The render function now properly uses: var apps = (data && data.apps) || this.appsData || []; var modules = (data && data.modules) || this.modulesData || []; This ensures the data passed from load() is used on first render, preventing the empty state on initial page load. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3793606c7b
commit
bd032be85f
@ -44,9 +44,17 @@ return view.extend({
|
||||
refreshData: function() {
|
||||
var self = this;
|
||||
return API.getAppstoreApps().then(function(data) {
|
||||
if (!data) {
|
||||
console.warn('getAppstoreApps returned empty data');
|
||||
return { apps: [], categories: {} };
|
||||
}
|
||||
self.appsData = data.apps || [];
|
||||
self.categoriesData = data.categories || {};
|
||||
return data;
|
||||
}).catch(function(err) {
|
||||
console.error('Error loading appstore apps:', err);
|
||||
ui.addNotification(null, E('p', _('Failed to load app store: ') + err.message), 'error');
|
||||
return { apps: [], categories: {} };
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@ -43,14 +43,22 @@ return view.extend({
|
||||
refreshData: function() {
|
||||
var self = this;
|
||||
return API.getModules().then(function(data) {
|
||||
if (!data) {
|
||||
console.warn('getModules returned empty data');
|
||||
return { modules: [] };
|
||||
}
|
||||
self.modulesData = data.modules || [];
|
||||
return data;
|
||||
}).catch(function(err) {
|
||||
console.error('Error loading modules:', err);
|
||||
ui.addNotification(null, E('p', _('Failed to load modules: ') + err.message), 'error');
|
||||
return { modules: [] };
|
||||
});
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var self = this;
|
||||
var modules = this.modulesData;
|
||||
var modules = (data && data.modules) || this.modulesData || [];
|
||||
|
||||
var defaultFilter = this.currentFilter || 'all';
|
||||
var container = E('div', {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user