Skip to content

Commit

Permalink
Merge pull request #195 from hypercerts-org/fix/order_cache_invalidation
Browse files Browse the repository at this point in the history
Order cache invalidation
  • Loading branch information
bitbeckers authored Nov 28, 2024
2 parents 905d32d + 47b1f5f commit e150cbe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
27 changes: 3 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/client/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ const handleChangeHyperboards = (
}
};

/* eslint-disable @typescript-eslint/no-explicit-any */
const handleChangeOrders = (
payload: RealtimePostgresChangesPayload<{ [key: string]: any }>,
) => {
console.log(payload);
switch (payload.eventType) {
case "INSERT":
case "UPDATE":
case "DELETE":
cache.invalidate([{ typename: "Order" }]);
break;
default:
break;
}
};

supabaseCaching
.channel("schema-db-changes")
.on(
Expand Down Expand Up @@ -368,4 +384,22 @@ supabaseData
},
(payload) => handleChangeHyperboards(payload),
)
.on(
"postgres_changes",
{
event: "*",
schema: "public",
table: "marketplace_orders",
},
(payload) => handleChangeOrders(payload),
)
.on(
"postgres_changes",
{
event: "*",
schema: "public",
table: "marketplace_order_nonces",
},
(payload) => handleChangeOrders(payload),
)
.subscribe();

0 comments on commit e150cbe

Please sign in to comment.