@@ -33,7 +33,7 @@ import Cache from './lib/cache';
3333import Updater from './lib/updater' ;
3434import * as http from './lib/http' ;
3535
36- const scriptVersion = 15 ;
36+ const scriptVersion = 16 ;
3737const sourceRepo = "evandcoleman/scriptable" ;
3838const scriptName = "MLB" ;
3939
@@ -259,22 +259,24 @@ async function createExpandedWidget() {
259259 }
260260 }
261261 namePitchesStack . addSpacer ( ) ;
262- } else if ( isPostGame ) {
262+ } else if ( isPostGame && game . decisions ) {
263263 const abTitleText = lowerStack . addText ( "Winning Pitcher:" )
264264 abTitleText . font = Font . mediumSystemFont ( 11 ) ;
265265 abTitleText . textColor = Color . lightGray ( ) ;
266266 const nameCountStack = lowerStack . addStack ( ) ;
267267 nameCountStack . layoutHorizontally ( ) ;
268268 nameCountStack . centerAlignContent ( ) ;
269- const playerNameText = nameCountStack . addText ( game . decisions . winner . fullName ) ;
269+ const playerNameText = nameCountStack . addText ( game . decisions . winner ? .fullName || "N/A" ) ;
270270 playerNameText . font = Font . regularSystemFont ( 12 ) ;
271271 playerNameText . textColor = Color . white ( ) ;
272272 // playerNameText.minimumScaleFactor = 0.9;
273273 nameCountStack . addSpacer ( 4 ) ;
274- const winnerStats = game . decisions . winner . stats . filter ( stat => stat . type . displayName === 'statsSingleSeason' && stat . group . displayName === 'pitching' ) [ 0 ] . stats ;
275- const countText = nameCountStack . addText ( `(${ winnerStats . wins } -${ winnerStats . losses } )` ) ;
276- countText . font = Font . regularSystemFont ( 10 ) ;
277- countText . textColor = Color . lightGray ( ) ;
274+ if ( game . decisions . winner && game . decisions . winner . stats ) {
275+ const winnerStats = game . decisions . winner . stats . filter ( stat => stat . type . displayName === 'statsSingleSeason' && stat . group . displayName === 'pitching' ) [ 0 ] . stats ;
276+ const countText = nameCountStack . addText ( `(${ winnerStats . wins } -${ winnerStats . losses } )` ) ;
277+ countText . font = Font . regularSystemFont ( 10 ) ;
278+ countText . textColor = Color . lightGray ( ) ;
279+ }
278280 nameCountStack . addSpacer ( ) ;
279281
280282 const pitcherTitleText = lowerStack . addText ( "Losing Pitcher:" )
@@ -283,15 +285,17 @@ async function createExpandedWidget() {
283285 const namePitchesStack = lowerStack . addStack ( ) ;
284286 namePitchesStack . layoutHorizontally ( ) ;
285287 namePitchesStack . centerAlignContent ( ) ;
286- const pitcherNameText = namePitchesStack . addText ( game . decisions . loser . fullName ) ;
288+ const pitcherNameText = namePitchesStack . addText ( game . decisions . loser ? .fullName || "N/A" ) ;
287289 pitcherNameText . font = Font . regularSystemFont ( 12 ) ;
288290 pitcherNameText . textColor = Color . white ( ) ;
289291 // pitcherNameText.minimumScaleFactor = 0.9;
290292 namePitchesStack . addSpacer ( 4 ) ;
291- const loserStats = game . decisions . loser . stats . filter ( stat => stat . type . displayName === 'statsSingleSeason' && stat . group . displayName === 'pitching' ) [ 0 ] . stats ;
292- const pitchesThrownText = namePitchesStack . addText ( `(${ loserStats . wins } -${ loserStats . losses } )` ) ;
293- pitchesThrownText . font = Font . regularSystemFont ( 10 ) ;
294- pitchesThrownText . textColor = Color . lightGray ( ) ;
293+ if ( game . decisions . loser && game . decisions . loser . stats ) {
294+ const loserStats = game . decisions . loser . stats . filter ( stat => stat . type . displayName === 'statsSingleSeason' && stat . group . displayName === 'pitching' ) [ 0 ] . stats ;
295+ const pitchesThrownText = namePitchesStack . addText ( `(${ loserStats . wins } -${ loserStats . losses } )` ) ;
296+ pitchesThrownText . font = Font . regularSystemFont ( 10 ) ;
297+ pitchesThrownText . textColor = Color . lightGray ( ) ;
298+ }
295299 namePitchesStack . addSpacer ( ) ;
296300 }
297301
0 commit comments