Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove usage of false in component return #861

Merged
merged 1 commit into from
Sep 30, 2024
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
4 changes: 2 additions & 2 deletions src/modules/item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ const Item = ({
id,
isChildren = false,
showPinnedOnly = false,
}: Props): JSX.Element | false => {
}: Props): JSX.Element | null => {
const { t: translateMessage } = useMessagesTranslation();
const { data: item, isInitialLoading: isLoadingItem, isError } = useItem(id);
const title = usePageTitle();
Expand Down Expand Up @@ -584,7 +584,7 @@ const Item = ({
</Alert>
);
}
return false;
return null;
};

export default Item;
4 changes: 2 additions & 2 deletions src/modules/navigationIsland/ChatButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PLAYER } from '@/langs/constants';

import { ToolButton } from './CustomButtons';

const useChatButton = (): { chatButton: JSX.Element | false } => {
const useChatButton = (): { chatButton: JSX.Element | null } => {
const { t } = usePlayerTranslation();
const { itemId, rootId } = useParams();
const { data: item } = hooks.useItem(itemId);
Expand Down Expand Up @@ -64,6 +64,6 @@ const useChatButton = (): { chatButton: JSX.Element | false } => {
};
}
// disable the chat button if there are no items with the chat enabled
return { chatButton: false };
return { chatButton: null };
};
export default useChatButton;
4 changes: 2 additions & 2 deletions src/modules/navigationIsland/GeolocationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ToolButton } from './CustomButtons';

const cm = ClientHostManager.getInstance();

const useGeolocationButton = (): { geolocationButton: JSX.Element | false } => {
const useGeolocationButton = (): { geolocationButton: JSX.Element | null } => {
const { t } = usePlayerTranslation();
// get inherited geoloc
const { itemId, rootId } = useParams();
Expand All @@ -26,7 +26,7 @@ const useGeolocationButton = (): { geolocationButton: JSX.Element | false } => {
const { data: geoloc } = hooks.useItemGeolocation(item?.id);

if (!allGeoloc?.length) {
return { geolocationButton: false };
return { geolocationButton: null };
}

const url = geoloc
Expand Down
4 changes: 2 additions & 2 deletions src/modules/navigationIsland/NavigationIsland.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useGeolocationButton from './GeolocationButton';
import usePinnedItemsButton from './PinnedItemsButton';
import usePreviousNextButtons from './PreviousNextButtons';

const NavigationIslandBox = (): JSX.Element | false => {
const NavigationIslandBox = (): JSX.Element | null => {
const { previousButton, nextButton } = usePreviousNextButtons();
const { chatButton } = useChatButton();
const { geolocationButton } = useGeolocationButton();
Expand All @@ -21,7 +21,7 @@ const NavigationIslandBox = (): JSX.Element | false => {
!nextButton &&
!geolocationButton
) {
return false;
return null;
}

return (
Expand Down
4 changes: 2 additions & 2 deletions src/modules/navigationIsland/PinnedItemsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PLAYER } from '@/langs/constants';

import { ToolButton } from './CustomButtons';

const usePinnedItemsButton = (): { pinnedButton: JSX.Element | false } => {
const usePinnedItemsButton = (): { pinnedButton: JSX.Element | null } => {
const { t } = usePlayerTranslation();
const { togglePinned, isPinnedOpen } = useLayoutContext();
const { itemId } = useParams();
Expand All @@ -29,7 +29,7 @@ const usePinnedItemsButton = (): { pinnedButton: JSX.Element | false } => {

// don't show the button if there are no items pinned in all descendants
if (childrenPinnedCount <= 0) {
return { pinnedButton: false };
return { pinnedButton: null };
}

const canWrite = item?.permission
Expand Down
10 changes: 5 additions & 5 deletions src/modules/navigationIsland/PreviousNextButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { combineUuids, shuffleAllButLastItemInArray } from '@/utils/shuffle.ts';
import { LoadingButton, NavigationButton } from './CustomButtons';

const usePreviousNextButtons = (): {
previousButton: JSX.Element | false;
nextButton: JSX.Element | false;
previousButton: JSX.Element | null;
nextButton: JSX.Element | null;
} => {
const { rootId, itemId } = useParams();
const [searchParams] = useSearchParams();
Expand Down Expand Up @@ -52,7 +52,7 @@ const usePreviousNextButtons = (): {

// if there are no descendants then there is no need to navigate
if (!isArray(descendants)) {
return { previousButton: false, nextButton: false };
return { previousButton: null, nextButton: null };
}

let folderHierarchy = descendants;
Expand All @@ -78,7 +78,7 @@ const usePreviousNextButtons = (): {

// if index is not found, then do not show navigation
if (idx < 0) {
return { previousButton: false, nextButton: false };
return { previousButton: null, nextButton: null };
}

// if index is 0, previous is root
Expand All @@ -101,7 +101,7 @@ const usePreviousNextButtons = (): {

// should we display both buttons if they are disabled ?
if (!prev && !next) {
return { previousButton: false, nextButton: false };
return { previousButton: null, nextButton: null };
}

return {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DisplayItems = ({
}: {
items?: PackedItem[];
isLoading: boolean;
}): JSX.Element[] | false => {
}): JSX.Element[] | null => {
if (items) {
return items.map((item) => (
<GridWrapper key={item.id}>
Expand All @@ -50,7 +50,7 @@ const DisplayItems = ({
</GridWrapper>
));
}
return false;
return null;
};

const HomePage = (): JSX.Element => {
Expand Down