@@ -3,15 +3,29 @@ import PropTypes from 'prop-types';
33
44import SimpleDropdown from '../../../common/simple-dropdown/simple.dropdown' ;
55import { 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' ;
713
814const ViewSwitcher = ( { isDisabled } ) => {
915 const Translator = getTranslator ( ) ;
1016 const viewLabel = Translator . trans ( /*@Desc ("View")*/ 'view_switcher.view' , { } , 'ibexa_universal_discovery_widget' ) ;
1117 const [ currentView , setCurrentView ] = useContext ( CurrentViewContext ) ;
1218 const { views } = useContext ( ViewContext ) ;
19+ const rootLocationId = useContext ( RootLocationIdContext ) ;
20+ const [ markedLocationId ] = useContext ( MarkedLocationIdContext ) ;
1321 const selectedOption = views . find ( ( option ) => option . value === currentView ) ;
22+
23+ console . log ( 'ViewSwitcher render' , startingLocationId , rootLocationId , markedLocationId ) ;
24+
1425 const onOptionClick = ( { value } ) => {
26+ const itemsViewTypeStorageKey = `${ ITEMS_VIEW_TYPE_STORAGE_KEY_PREFIX } -${ markedLocationId ?? rootLocationId } ` ;
27+
28+ window . localStorage . setItem ( itemsViewTypeStorageKey , value ) ;
1529 setCurrentView ( value ) ;
1630 } ;
1731
0 commit comments