Skip to content

Commit

Permalink
Cleaning loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
cdedreuille committed Aug 1, 2023
1 parent c5f6677 commit 1b138a9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
12 changes: 1 addition & 11 deletions code/addons/controls/src/ControlsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface ControlsParameters {

export const ControlsPanel: FC = () => {
const [isLoading, setIsLoading] = useState(true);
const [isSoftLoading, setIsSoftLoading] = useState(true);
const [args, updateArgs, resetArgs] = useArgs();
const [globals] = useGlobals();
const rows = useArgTypes();
Expand All @@ -35,17 +34,9 @@ export const ControlsPanel: FC = () => {
// If the story is prepared, then show the args table
// and reset the loading states
useChannel({
[STORY_PREPARED]: () => {
setIsLoading(false);
setIsSoftLoading(false);
},
[STORY_PREPARED]: () => setIsLoading(false),
});

// If the story changes, then show the loading state
useEffect(() => {
setIsSoftLoading(true);
}, [path]);

const hasControls = Object.values(rows).some((arg) => arg?.control);

const withPresetColors = Object.entries(rows).reduce((acc, [key, arg]) => {
Expand All @@ -66,7 +57,6 @@ export const ControlsPanel: FC = () => {
inAddonPanel
sort={sort}
isLoading={isLoading}
isSoftLoading={isSoftLoading}
/>
);
};
6 changes: 0 additions & 6 deletions code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export interface ArgsTableOptionProps {
inAddonPanel?: boolean;
initialExpandedArgs?: boolean;
isLoading?: boolean;
isSoftLoading?: boolean;
sort?: SortType;
}
interface ArgsTableDataProps {
Expand Down Expand Up @@ -316,7 +315,6 @@ export const ArgsTable: FC<ArgsTableProps> = (props) => {
initialExpandedArgs,
sort = 'none',
isLoading,
isSoftLoading,
} = props;

if ('error' in props) {
Expand All @@ -335,10 +333,6 @@ export const ArgsTable: FC<ArgsTableProps> = (props) => {
// This happen when you load the manager and the story is not yet loaded
if (isLoading) return <Skeleton />;

// If the story is soft loading, don't show anything
// This happens when you switch stories and the story is not yet loaded
if (isSoftLoading) return null;

const { rows, args, globals } = 'rows' in props && props;
const groups = groupRows(
pickBy(
Expand Down

0 comments on commit 1b138a9

Please sign in to comment.