(collection: ModCollection, id: string)
| 300 | } |
| 301 | |
| 302 | export function removeMod(collection: ModCollection, id: string): ModCollection { |
| 303 | const items = { ...collection.items }; |
| 304 | delete items[id]; |
| 305 | const activeId = |
| 306 | collection.activeId === id ? (Object.keys(items)[0] ?? DEFAULT_MOD_ID) : collection.activeId; |
| 307 | if (Object.keys(items).length === 0) { |
| 308 | items[DEFAULT_MOD_ID] = { config: DEFAULT_MOD, state: defaultState(DEFAULT_MOD) }; |
| 309 | return { activeId: DEFAULT_MOD_ID, items }; |
| 310 | } |
| 311 | return { activeId, items }; |
| 312 | } |
| 313 | |
| 314 | export function setActiveMod(collection: ModCollection, id: string): ModCollection { |
| 315 | if (!collection.items[id]) return collection; |
nothing calls this directly
no test coverage detected