Skip to content

Commit

Permalink
Merge pull request #10 from prasek/order-refresh
Browse files Browse the repository at this point in the history
use workflow as exclusive source of truth for orders page
  • Loading branch information
tomwheeler authored Sep 9, 2024
2 parents 2514bc0 + 09d8573 commit fa78436
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/lib/components/shipment-status.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
export let id: string | undefined = undefined;
export let status = '';
if (id) {
const broadcaster = new BroadcastChannel(`shipment-${id}`);
broadcaster?.addEventListener('message', (event) => {
status = event.data;
});
}
const inactiveStatuses = ['pending', 'unavailable', 'cancelled', 'failed'];
const activeStatuses = ['booked', 'dispatched', 'delivered'];
Expand Down
12 changes: 12 additions & 0 deletions src/routes/shipments/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
$: {
if (shipment?.id) {
broadcaster = new BroadcastChannel(`shipment-${shipment.id}`);
//note: the customer order page is polling for order status from the
//workflow itself since this courier shipping page is not the only
//source of workflow state changes
//however to avoid polling on this this courier shipping page if
//multiple browser windows are open to the same shipping page we'd
//like those to be in sync, so will listen for events from a
//different browser window opened to the same shipping page
broadcaster?.addEventListener('message', (event) => {
status = event.data;
});
}
}
Expand Down

0 comments on commit fa78436

Please sign in to comment.