* Removes a sidebar app with the given ID. * @param {string} id - The ID of the sidebar app to remove. * @returns {void}
(id)
| 50 | * @returns {void} |
| 51 | */ |
| 52 | function remove(id) { |
| 53 | const app = apps.find((app) => app.id === id); |
| 54 | if (!app) return; |
| 55 | const wasActive = app.active; |
| 56 | app.remove(); |
| 57 | apps.splice(apps.indexOf(app), 1); |
| 58 | if (wasActive && apps.length > 0) { |
| 59 | const preferredApp = apps.find((app) => app.id === currentSection); |
| 60 | setActiveApp(preferredApp?.id || apps[0].id); |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | if (!apps.length) { |
| 65 | currentSection = null; |
| 66 | localStorage.removeItem(SIDEBAR_APPS_LAST_SECTION); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Initialize sidebar apps |
nothing calls this directly
no test coverage detected