|
|
@@ -16,6 +16,7 @@ import loggerFactory from '~/utils/logger';
|
|
|
import FormattedDistanceDate from '../FormattedDistanceDate';
|
|
|
|
|
|
import InfiniteScroll from './InfiniteScroll';
|
|
|
+import { SidebarHeaderReloadButton } from './SidebarHeaderReloadButton';
|
|
|
|
|
|
import TagLabelsStyles from '../Page/TagLabels.module.scss';
|
|
|
import styles from './RecentChanges.module.scss';
|
|
|
@@ -130,12 +131,17 @@ const SmallPageItem = memo(({ page }: PageItemProps): JSX.Element => {
|
|
|
SmallPageItem.displayName = 'SmallPageItem';
|
|
|
|
|
|
const RecentChanges = (): JSX.Element => {
|
|
|
+
|
|
|
const PER_PAGE = 20;
|
|
|
const { t } = useTranslation();
|
|
|
const swr = useSWRInifinitexRecentlyUpdated();
|
|
|
+ const { data, error, mutate } = swr;
|
|
|
+
|
|
|
const [isRecentChangesSidebarSmall, setIsRecentChangesSidebarSmall] = useState(false);
|
|
|
- const isEmpty = swr.data?.[0].length === 0;
|
|
|
- const isReachingEnd = isEmpty || (swr.data && swr.data[swr.data.length - 1]?.length < PER_PAGE);
|
|
|
+ const isEmpty = data?.[0].length === 0;
|
|
|
+ const isLoading = error == null && data === undefined;
|
|
|
+ const isReachingEnd = isEmpty || (data && data[data.length - 1]?.length < PER_PAGE);
|
|
|
+
|
|
|
const retrieveSizePreferenceFromLocalStorage = useCallback(() => {
|
|
|
if (window.localStorage.isRecentChangesSidebarSmall === 'true') {
|
|
|
setIsRecentChangesSidebarSmall(true);
|
|
|
@@ -155,10 +161,8 @@ const RecentChanges = (): JSX.Element => {
|
|
|
return (
|
|
|
<div data-testid="grw-recent-changes">
|
|
|
<div className="grw-sidebar-content-header p-3 d-flex">
|
|
|
- <h3 className="mb-0 text-nowrap">{t('Recent Changes')}</h3>
|
|
|
- <button type="button" className="btn btn-sm ml-auto grw-btn-reload" onClick={() => swr.mutate()}>
|
|
|
- <i className="icon icon-reload"></i>
|
|
|
- </button>
|
|
|
+ <h3 className="mb-0 text-nowrap">{t('Recent Changes')}</h3>
|
|
|
+ <SidebarHeaderReloadButton onClick={() => mutate()}/>
|
|
|
<div className="d-flex align-items-center">
|
|
|
<div className={`grw-recent-changes-resize-button ${styles['grw-recent-changes-resize-button']} custom-control custom-switch ml-1`}>
|
|
|
<input
|