File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,33 @@ export default function okapiReducer(state = {}, action) {
4141 case 'UPDATE_CURRENT_USER' :
4242 return { ...state , currentUser : { ...state . currentUser , ...action . data } } ;
4343
44- case 'ADD_ICON' :
45- return { ...state , icons : { ...state . icons , [ action . key ] : action . icon } } ;
44+ /**
45+ * state.icons looks like
46+ * {
47+ * "@folio /some-app": {
48+ * app: { alt, src},
49+ * otherIcon: { alt, src }
50+ * },
51+ * "@folio/other-app": { app: ...}
52+ * }
53+ *
54+ * action.key looks like @folio /some-app or @folio/other-app
55+ * action.icon looks like { alt: ... } or { otherIcon: ... }
56+ */
57+ case 'ADD_ICON' : {
58+ let val = action . icon ;
59+
60+ // if there are already icons defined for this key,
61+ // add this payload to them
62+ if ( state . icons ?. [ action . key ] ) {
63+ val = {
64+ ...state . icons [ action . key ] ,
65+ ...action . icon ,
66+ } ;
67+ }
68+
69+ return { ...state , icons : { ...state . icons , [ action . key ] : val } } ;
70+ }
4671
4772 default :
4873 return state ;
You can’t perform that action at this time.
0 commit comments