Skip to content

Commit

Permalink
refetches scenario list on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Oct 3, 2023
1 parent 0eb4a8a commit 3efa0b8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/hooks/scenarios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export function useScenarios(pId, options: UseScenariosOptionsProps = {}) {
const query = useInfiniteQuery(['scenarios', pId, JSON.stringify(options)], fetchScenarios, {
retry: false,
keepPreviousData: true,
refetchOnWindowFocus: true,
getNextPageParam: (lastPage) => {
const {
data: { meta },
Expand Down
6 changes: 3 additions & 3 deletions app/layout/project/navigation/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const useInventoryItems = (): SubMenuItem[] => {
export const useGridSetupItems = (): SubMenuItem[] => {
const { query, route } = useRouter();
const { pid, sid, tab } = query as { pid: string; sid: string; tab: string };
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE);
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE) && !route.endsWith('/new');

return [
{
Expand Down Expand Up @@ -91,7 +91,7 @@ export const useGridSetupItems = (): SubMenuItem[] => {
export const useSolutionItems = (): SubMenuItem[] => {
const { query, route } = useRouter();
const { pid, sid, tab } = query as { pid: string; sid: string; tab: string };
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE);
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE) && !route.endsWith('/new');

return [
{
Expand All @@ -112,7 +112,7 @@ export const useSolutionItems = (): SubMenuItem[] => {
export const useAdvancedSettingsItems = (): SubMenuItem[] => {
const { query, route } = useRouter();
const { pid, sid, tab } = query as { pid: string; sid: string; tab: string };
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE);
const isScenarioRoute = route.startsWith(SCENARIO_ROUTE) && !route.endsWith('/new');

return [
{
Expand Down
6 changes: 3 additions & 3 deletions app/layout/project/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const Navigation = (): JSX.Element => {
const { query, route } = useRouter();
const { pid, sid, tab } = query as { pid: string; sid: string; tab: string };

const isProjectRoute = route === '/projects/[pid]';
const isScenarioRoute = route.startsWith('/projects/[pid]/scenarios/');
const isProjectRoute = route.startsWith('/projects/[pid]');
const isScenarioRoute = route.startsWith('/projects/[pid]/scenarios/') && !route.endsWith('/new');

const { addToast } = useToasts();
const plausible = usePlausible();
Expand Down Expand Up @@ -149,7 +149,7 @@ export const Navigation = (): JSX.Element => {
},
}
);
}, [addToast, runScenarioMutation, sid]);
}, [addToast, runScenarioMutation, sid, plausible, user]);

const isSolutionsSectionEnabled = scenarioQuery.data?.ranAtLeastOnce ?? false;

Expand Down
2 changes: 1 addition & 1 deletion app/layout/project/sidebar/header/title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const EditableTitle = ({
<input
{...input}
ref={titleInputRef}
className="absolute left-0 top-0 h-full w-full cursor-pointer overflow-ellipsis border-none bg-transparent px-1.5 font-heading text-3xl focus:bg-primary-300 focus:text-gray-600 focus:outline-none"
className="absolute left-0 top-0 h-full w-full cursor-pointer overflow-ellipsis border-none bg-transparent font-heading text-3xl focus:bg-primary-300 focus:text-gray-600 focus:outline-none"
disabled={!editting}
value={input.value}
/>
Expand Down
4 changes: 3 additions & 1 deletion app/layout/project/sidebar/scenario/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const ScenarioHeader = (): JSX.Element => {
[saveScenarioMutation, sid]
);

return <Title title={name} description={description} onEditTitle={onEditScenarioName} />;
return (
<>{sid && <Title title={name} description={description} onEditTitle={onEditScenarioName} />}</>
);
};

export default ScenarioHeader;

0 comments on commit 3efa0b8

Please sign in to comment.