@@ -3,15 +3,29 @@ import PropTypes from 'prop-types';
3
3
4
4
import SimpleDropdown from '../../../common/simple-dropdown/simple.dropdown' ;
5
5
import { getTranslator } from '../../../../../../Resources/public/js/scripts/helpers/context.helper' ;
6
- import { CurrentViewContext , ViewContext } from '../../universal.discovery.module' ;
6
+ import {
7
+ ITEMS_VIEW_TYPE_STORAGE_KEY_PREFIX ,
8
+ CurrentViewContext ,
9
+ MarkedLocationIdContext ,
10
+ ViewContext ,
11
+ RootLocationIdContext
12
+ } from '../../universal.discovery.module' ;
7
13
8
14
const ViewSwitcher = ( { isDisabled } ) => {
9
15
const Translator = getTranslator ( ) ;
10
16
const viewLabel = Translator . trans ( /*@Desc ("View")*/ 'view_switcher.view' , { } , 'ibexa_universal_discovery_widget' ) ;
11
17
const [ currentView , setCurrentView ] = useContext ( CurrentViewContext ) ;
12
18
const { views } = useContext ( ViewContext ) ;
19
+ const rootLocationId = useContext ( RootLocationIdContext ) ;
20
+ const [ markedLocationId ] = useContext ( MarkedLocationIdContext ) ;
13
21
const selectedOption = views . find ( ( option ) => option . value === currentView ) ;
22
+
23
+ console . log ( 'ViewSwitcher render' , startingLocationId , rootLocationId , markedLocationId ) ;
24
+
14
25
const onOptionClick = ( { value } ) => {
26
+ const itemsViewTypeStorageKey = `${ ITEMS_VIEW_TYPE_STORAGE_KEY_PREFIX } -${ markedLocationId ?? rootLocationId } ` ;
27
+
28
+ window . localStorage . setItem ( itemsViewTypeStorageKey , value ) ;
15
29
setCurrentView ( value ) ;
16
30
} ;
17
31
0 commit comments