Skip to content

Commit e150cbe

Browse files
authored
Merge pull request #195 from hypercerts-org/fix/order_cache_invalidation
Order cache invalidation
2 parents 905d32d + 47b1f5f commit e150cbe

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/supabase.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ const handleChangeHyperboards = (
188188
}
189189
};
190190

191+
/* eslint-disable @typescript-eslint/no-explicit-any */
192+
const handleChangeOrders = (
193+
payload: RealtimePostgresChangesPayload<{ [key: string]: any }>,
194+
) => {
195+
console.log(payload);
196+
switch (payload.eventType) {
197+
case "INSERT":
198+
case "UPDATE":
199+
case "DELETE":
200+
cache.invalidate([{ typename: "Order" }]);
201+
break;
202+
default:
203+
break;
204+
}
205+
};
206+
191207
supabaseCaching
192208
.channel("schema-db-changes")
193209
.on(
@@ -368,4 +384,22 @@ supabaseData
368384
},
369385
(payload) => handleChangeHyperboards(payload),
370386
)
387+
.on(
388+
"postgres_changes",
389+
{
390+
event: "*",
391+
schema: "public",
392+
table: "marketplace_orders",
393+
},
394+
(payload) => handleChangeOrders(payload),
395+
)
396+
.on(
397+
"postgres_changes",
398+
{
399+
event: "*",
400+
schema: "public",
401+
table: "marketplace_order_nonces",
402+
},
403+
(payload) => handleChangeOrders(payload),
404+
)
371405
.subscribe();

0 commit comments

Comments
 (0)