Skip to content

Commit

Permalink
Stop using isvalidating (#478)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
evroon committed Feb 15, 2024
1 parent b40ff6d commit 15870bf
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/tables/clubs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/tables/courts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/tables/players.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/tables/teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/tables/tournaments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
}

Expand Down
7 changes: 1 addition & 6 deletions frontend/src/pages/tournaments/[id]/stages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand Down

0 comments on commit 15870bf

Please sign in to comment.