* Ensures that at least one app is active. * Call this AFTER all plugins have been loaded to handle cases where * the stored section was from an uninstalled plugin. * @returns {void}
()
| 126 | * @returns {void} |
| 127 | */ |
| 128 | function ensureActiveApp() { |
| 129 | const activeApps = apps.filter((app) => app.active); |
| 130 | if (activeApps.length === 1) return; |
| 131 | |
| 132 | if (activeApps.length > 1) { |
| 133 | const preferredActiveApp = activeApps.find( |
| 134 | (app) => app.id === currentSection, |
| 135 | ); |
| 136 | setActiveApp(preferredActiveApp?.id || activeApps[0].id); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | if (apps.length > 0) { |
| 141 | const preferredApp = apps.find((app) => app.id === currentSection); |
| 142 | setActiveApp(preferredApp?.id || apps[0].id); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Gets the container of the app with the given ID. |
nothing calls this directly
no test coverage detected