MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / ensureActiveApp

Function ensureActiveApp

src/sidebarApps/index.js:128–144  ·  view source on GitHub ↗

* 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}

()

Source from the content-addressed store, hash-verified

126 * @returns {void}
127 */
128function 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.

Callers

nothing calls this directly

Calls 1

setActiveAppFunction · 0.85

Tested by

no test coverage detected