Stop using isvalidating (#478)

Using isValidating, we see flickering in the UI because we don't use the
caching of SWR optimally. We only need to check whether there is some
data available, expired or not.
This commit is contained in:
Erik Vroon
2024-02-15 19:17:35 +01:00
committed by GitHub
parent b40ff6de35
commit 15870bfbb1
7 changed files with 7 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ export default function ClubsTable({ swrClubsResponse }: { swrClubsResponse: SWR
const { t } = useTranslation();
if (swrClubsResponse.error) return <RequestErrorAlert error={swrClubsResponse.error} />;
if (swrClubsResponse.isLoading || swrClubsResponse.isValidating) {
if (swrClubsResponse.isLoading) {
return <TableSkeletonSingleColumn />;
}

View File

@@ -24,7 +24,7 @@ export default function CourtsTable({
const courts: Court[] = swrCourtsResponse.data != null ? swrCourtsResponse.data.data : [];
const tableState = getTableState('id');
if (swrCourtsResponse.isLoading || swrCourtsResponse.isValidating) {
if (swrCourtsResponse.isLoading) {
return <TableSkeletonSingleColumn />;
}

View File

@@ -53,7 +53,7 @@ export default function PlayersTable({
if (swrPlayersResponse.error) return <RequestErrorAlert error={swrPlayersResponse.error} />;
if (swrPlayersResponse.isLoading || swrPlayersResponse.isValidating) {
if (swrPlayersResponse.isLoading) {
return <TableSkeletonSingleColumn />;
}

View File

@@ -28,7 +28,7 @@ export default function TeamsTable({
const tableState = getTableState('name');
if (swrTeamsResponse.error) return <RequestErrorAlert error={swrTeamsResponse.error} />;
if (swrTeamsResponse.isLoading || swrTeamsResponse.isValidating) {
if (swrTeamsResponse.isLoading) {
return <TableSkeletonSingleColumn />;
}

View File

@@ -27,7 +27,7 @@ export default function TournamentsTable({
if (swrTournamentsResponse.error) {
return <RequestErrorAlert error={swrTournamentsResponse.error} />;
}
if (swrTournamentsResponse.isLoading || swrTournamentsResponse.isValidating) {
if (swrTournamentsResponse.isLoading) {
return <TableSkeletonSingleColumn />;
}

View File

@@ -28,12 +28,7 @@ export default function StagesPage() {
swrStagesResponse.data != null ? swrStagesResponse.data.data : [];
let content;
if (
swrStagesResponse.isLoading ||
swrTournamentResponse.isLoading ||
swrStagesResponse.isValidating ||
swrTournamentResponse.isValidating
) {
if (swrStagesResponse.isLoading || swrTournamentResponse.isLoading) {
content = <TableSkeletonTwoColumnsSmall />;
} else if (stages.length < 1) {
content = (

View File

@@ -23,7 +23,7 @@ export default function HomePage() {
let content;
content = user != null ? <UserForm user={user} /> : null;
if (swrUserResponse.isValidating || swrUserResponse.isLoading) {
if (swrUserResponse.isLoading) {
content = (
<Group maw="40rem">
<TableSkeletonSingleColumn />