Skip to content

Commit

Permalink
Fix: Ensure collections are initiated in store (#2627)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Jun 16, 2023
1 parent 8a6c1f1 commit a0a75ca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const UnstyledResourceExplorer = (props: any) => {

const dispatch: AppDispatch = useDispatch();
const classes = classNames(props);
const selectedLinks = collections ? collections.find(k => k.isDefault)!.paths : [];
const selectedLinks = collections && collections.length > 0 ? collections.find(k => k.isDefault)!.paths : [];
const versions: any[] = [
{ key: 'v1.0', text: 'v1.0' },
{ key: 'beta', text: 'beta' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const PathsReview: React.FC<PopupsComponent<IPathsReview>> = (props) => {
const { collections } = useAppSelector(
(state) => state
);
const items = collections ? collections.find(k => k.isDefault)!.paths : [];
const items = collections && collections.length > 0 ? collections.find(k => k.isDefault)!.paths : [];
const [selectedItems, setSelectedItems] = useState<IResourceLink[]>([]);

const columns = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CommandOptions = (props: ICommandOptions) => {
const theme = getTheme();

const { collections } = useAppSelector((state) => state);
const paths = collections ? collections.find(k => k.isDefault)!.paths : [];
const paths = collections && collections.length > 0 ? collections.find(k => k.isDefault)!.paths : [];

const itemStyles = resourceExplorerStyles(theme).itemStyles;
const commandStyles = resourceExplorerStyles(theme).commandBarStyles;
Expand Down
3 changes: 2 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const initialState: any = {
sampleHeaders: [],
selectedVersion: 'v1.0'
},
termsOfUse: true
termsOfUse: true,
collections: []
};

export const store = createStore(
Expand Down

0 comments on commit a0a75ca

Please sign in to comment.