Skip to content

Commit

Permalink
Fixed layout state sync issues (TryGhost#21443)
Browse files Browse the repository at this point in the history
refs https://linear.app/ghost/issue/AP-544

useState was still called twice, we should have pulled that out - but
instead passing values down for now
  • Loading branch information
allouis authored and tilak999 committed Nov 20, 2024
1 parent ba2925c commit 1733292
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/admin-x-activitypub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tryghost/admin-x-activitypub",
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions apps/admin-x-activitypub/src/components/Inbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface InboxProps {}
const Inbox: React.FC<InboxProps> = ({}) => {
const [, setArticleContent] = useState<ObjectProperties | null>(null);
const [, setArticleActor] = useState<ActorProperties | null>(null);
const {layout} = useLayout();
const {layout, setFeed, setInbox} = useLayout();

const {
data,
Expand Down Expand Up @@ -104,7 +104,7 @@ const Inbox: React.FC<InboxProps> = ({}) => {

return (
<>
<MainNavigation page='home'/>
<MainNavigation layout={layout} page='home' setFeed={setFeed} setInbox={setInbox}/>
<div className='z-0 my-5 flex w-full flex-col'>
<div className='w-full px-8'>
{isLoading ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import MainHeader from './MainHeader';
import React from 'react';
import {Button, Tooltip} from '@tryghost/admin-x-design-system';
import {useLayout} from '../../hooks/layout';
import {useRouting} from '@tryghost/admin-x-framework/routing';

interface MainNavigationProps {
page: string;
layout?: 'feed' | 'inbox';
setFeed?: () => void;
setInbox?: () => void;
}

const MainNavigation: React.FC<MainNavigationProps> = ({
page = ''
page = '',
layout,
setFeed,
setInbox
}) => {
const {route, updateRoute} = useRouting();
const mainRoute = route.split('/')[0];
const {layout, setFeed, setInbox} = useLayout();

return (
<MainHeader>
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-x-activitypub/src/hooks/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export function useLayout() {
const setFeed = () => setLayout('feed');
const setInbox = () => setLayout('inbox');

return {layout, setInbox, setFeed};
return {layout, setInbox, setFeed} as {layout: Layout, setInbox: () => void, setFeed: () => void};
}

0 comments on commit 1733292

Please sign in to comment.