@@ -12,7 +12,7 @@ import { isServerCall, omit } from '@hotandcold/shared/utils';
1212import {
1313 GameMode ,
1414 HardcoreAccessStatus ,
15- PurchasedProductBroadcast as PurchasedProductBroadcastMessage ,
15+ PurchasedProductBroadcast ,
1616 WebviewToBlocksMessage ,
1717} from '@hotandcold/classic-shared' ;
1818import { GuessService } from './core/guess.js' ;
@@ -76,11 +76,15 @@ Devvit.addCustomPostType({
7676 const purchaseRealtimeChannel = useChannel ( {
7777 name : PURCHASE_REALTIME_CHANNEL ,
7878 onMessage ( msg : JSONValue ) {
79- const msgCasted = msg as PurchasedProductBroadcastMessage ;
80- sendMessageToWebview ( context , {
81- type : 'HARDCORE_ACCESS_UPDATE' ,
82- payload : msgCasted . payload ,
83- } ) ;
79+ const msgCasted = msg as PurchasedProductBroadcast ;
80+ if ( msgCasted . payload . userId === context . userId ) {
81+ sendMessageToWebview ( context , {
82+ type : 'HARDCORE_ACCESS_UPDATE' ,
83+ payload : {
84+ access : msgCasted . payload . access ,
85+ } ,
86+ } ) ;
87+ }
8488 } ,
8589 onSubscribed : ( ) => {
8690 console . log ( 'listening for purchase success broadcast events' ) ;
@@ -103,6 +107,7 @@ Devvit.addCustomPostType({
103107 void purchaseRealtimeChannel . send ( {
104108 payload : {
105109 access,
110+ userId : context . userId ! ,
106111 } ,
107112 } ) ;
108113
0 commit comments