Skip to content

Commit

Permalink
remove nostore since data is static and re-name a var
Browse files Browse the repository at this point in the history
  • Loading branch information
StephDietz committed May 9, 2024
1 parent 1b7a9ee commit d90336d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/components/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ interface ExpandedSections {
}

export default function Panel({
authors,
selectedAuthors,
allAuthors,
}: {
authors: string[];
selectedAuthors: string[];
allAuthors: string[];
}) {
let router = useRouter();
let [pending, startTransition] = useTransition();
let [optimisticAuthors, setOptimisticAuthors] = useOptimistic(authors);
let [optimisticAuthors, setOptimisticAuthors] =
useOptimistic(selectedAuthors);
let [expandedSections, setExpandedSections] = useState<ExpandedSections>({});
let [isPanelVisible, setPanelVisibility] = useState(false);

Expand Down
4 changes: 0 additions & 4 deletions app/lib/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sql } from "@vercel/postgres";
import { unstable_noStore as noStore } from "next/cache";

const ITEMS_PER_PAGE = 30;

Expand All @@ -13,7 +12,6 @@ export async function fetchFilteredBooks(
query: string,
currentPage: number,
) {
noStore();
const offset = (currentPage - 1) * ITEMS_PER_PAGE;
if (selectedAuthors.length > 0) {
try {
Expand Down Expand Up @@ -96,7 +94,6 @@ export async function fetchBookById(id: string) {
}

export async function fetchAuthors() {
noStore();
try {
const authors = await sql`
SELECT DISTINCT "author"
Expand All @@ -116,7 +113,6 @@ export async function fetchAuthors() {
}

export async function fetchPages(query: string, selectedAuthors: string[]) {
noStore();
if (selectedAuthors.length > 0) {
try {
const authorsDelimited = selectedAuthors.join("|");
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default async function Page({
<Pagination totalPages={totalPages} />
</div>
<div className="flex flex-col gap-6 py-6 lg:flex-row">
<Panel authors={selectedAuthors} allAuthors={allAuthors} />
<Panel selectedAuthors={selectedAuthors} allAuthors={allAuthors} />
<Suspense fallback={<LoadingSkeleton />}>
<Grid
selectedAuthors={selectedAuthors}
Expand Down

0 comments on commit d90336d

Please sign in to comment.