Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/social-web/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,39 @@ export function Layout() {
setSelectedItemId( itemId );
}, [] );

// Listen for hash changes (back/forward navigation)
// Listen for hash changes (back/forward navigation).
useEffect( () => {
const handleHashChange = () => {
const syncUrlToState = () => {
const { section, itemId } = parseHash();
setActiveSection( section );
setSelectedItemId( itemId );
};

window.addEventListener( 'hashchange', handleHashChange );
window.addEventListener( 'hashchange', syncUrlToState );
return () => {
window.removeEventListener( 'hashchange', handleHashChange );
window.removeEventListener( 'hashchange', syncUrlToState );
};
}, [] );

const handleSelectItem = ( id: string | number ) => {
const selectItem = ( id: string | number ) => {
setSelectedItemId( id );
updateHash( activeSection, id );
};

const handleCloseInspector = () => {
const closeInspector = () => {
setSelectedItemId( null );
updateHash( activeSection );
};

const handleNavigate = ( section: string ) => {
const navigate = ( section: string ) => {
setActiveSection( section );
setSelectedItemId( null );
updateHash( section );
};

// Render main content (stage) with Suspense for lazy loading
const renderStage = () => {
const props = { onSelectItem: handleSelectItem };
const props = { onSelectItem: selectItem };

let StageComponent;
switch ( activeSection ) {
Expand Down Expand Up @@ -145,7 +145,7 @@ export function Layout() {
return null;
}
InspectorComponent = FeedInspector;
props = { id: selectedItemId, onClose: handleCloseInspector };
props = { id: selectedItemId, onClose: closeInspector };
}

return (
Expand All @@ -169,7 +169,7 @@ export function Layout() {
<div className="app-content">
{ /* Sidebar - 240px fixed width (no Panel wrapper, stays dark) */ }
<div className="sidebar-region">
<Sidebar activeSection={ activeSection } onNavigate={ handleNavigate } />
<Sidebar activeSection={ activeSection } onNavigate={ navigate } />
</div>

{ /* Stage - main content area */ }
Expand Down
4 changes: 2 additions & 2 deletions src/social-web/routes/feed/stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function FeedStage( { onSelectItem }: FeedStageProps ) {
}
}, [ feed, selection ] );

const handleChangeSelection = useCallback(
const changeSelection = useCallback(
( nextSelection: string[] ) => {
setSelection( nextSelection );

Expand Down Expand Up @@ -116,7 +116,7 @@ export default function FeedStage( { onSelectItem }: FeedStageProps ) {
isItemClickable={ () => true }
getItemId={ ( item ) => item.id.toString() }
selection={ selection }
onChangeSelection={ handleChangeSelection }
onChangeSelection={ changeSelection }
empty={
<p>
{ view.search
Expand Down