-
Notifications
You must be signed in to change notification settings - Fork 462
Expand file tree
/
Copy pathicons.ts
More file actions
27 lines (23 loc) · 872 Bytes
/
icons.ts
File metadata and controls
27 lines (23 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import type { Reducer, IconsWithClassNames } from 'firefox-profiler/types';
const favicons: Reducer<IconsWithClassNames> = (state = new Map(), action) => {
switch (action.type) {
case 'ICON_HAS_LOADED': {
const { icon, className } = action.iconWithClassName;
return new Map([...state.entries(), [icon, className]]);
}
case 'ICON_BATCH_ADD': {
const newState = new Map([...state.entries()]);
for (const { icon, className } of action.icons) {
newState.set(icon, className);
}
return newState;
}
case 'ICON_IN_ERROR': // nothing to do
default:
return state;
}
};
export default favicons;