Commit 87440aa 1 parent 053f93d commit 87440aa Copy full SHA for 87440aa
File tree 1 file changed +13
-2
lines changed
electron/renderer/context
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -112,12 +112,17 @@ export const GameProvider: React.FC<GameProviderProps> = (
112
112
characterName,
113
113
gameCode,
114
114
} ) ;
115
+ pubsub . publish ( 'game:connect' , {
116
+ accountName,
117
+ characterName,
118
+ gameCode,
119
+ } ) ;
115
120
}
116
121
) ;
117
122
return ( ) => {
118
123
unsubscribe ( ) ;
119
124
} ;
120
- } , [ logger ] ) ;
125
+ } , [ logger , pubsub ] ) ;
121
126
122
127
useEffect ( ( ) => {
123
128
const unsubscribe = window . api . onMessage (
@@ -129,6 +134,11 @@ export const GameProvider: React.FC<GameProviderProps> = (
129
134
characterName,
130
135
gameCode,
131
136
} ) ;
137
+ pubsub . publish ( 'game:disconnect' , {
138
+ accountName,
139
+ characterName,
140
+ gameCode,
141
+ } ) ;
132
142
// In the event that the user quits the game via a command,
133
143
// or the game client closes unexpectedly, we need to explicitly
134
144
// run the quit character hook logic to update UI state.
@@ -140,14 +150,15 @@ export const GameProvider: React.FC<GameProviderProps> = (
140
150
return ( ) => {
141
151
unsubscribe ( ) ;
142
152
} ;
143
- } , [ logger , quitCharacter ] ) ;
153
+ } , [ logger , pubsub , quitCharacter ] ) ;
144
154
145
155
useEffect ( ( ) => {
146
156
const unsubscribe = window . api . onMessage (
147
157
'game:error' ,
148
158
( _event : IpcRendererEvent , message : GameErrorMessage ) => {
149
159
const { error } = message ;
150
160
logger . error ( 'game:error' , { error } ) ;
161
+ pubsub . publish ( 'game:error' , error ) ;
151
162
pubsub . publish ( 'toast:add' , {
152
163
title : 'Game Error' ,
153
164
type : 'danger' ,
You can’t perform that action at this time.
0 commit comments