@@ -132,7 +132,7 @@ class Events extends Component {
132
132
case 'IssuesEvent' :
133
133
return `${ userEvent . payload . action } issue` ;
134
134
case 'MemberEvent' :
135
- return `${ userEvent . payload . action } user ` ;
135
+ return `${ userEvent . payload . action } ` ;
136
136
case 'PublicEvent' :
137
137
return 'open sourced' ;
138
138
case 'PullRequestEvent' :
@@ -181,15 +181,7 @@ class Events extends Component {
181
181
return (
182
182
< Text
183
183
style = { styles . linkDescription }
184
- onPress = { ( ) =>
185
- this . props . navigation . navigate ( 'Repository' , {
186
- repository : {
187
- ...userEvent . repo ,
188
- name : userEvent . repo . name . substring (
189
- userEvent . repo . name . indexOf ( '/' ) + 1
190
- ) ,
191
- } ,
192
- } ) }
184
+ onPress = { ( ) => this . navigateToRepository ( userEvent ) }
193
185
>
194
186
{ userEvent . repo . name }
195
187
</ Text >
@@ -205,18 +197,12 @@ class Events extends Component {
205
197
</ Text >
206
198
) ; // can only be branch or tag
207
199
case 'ForkEvent' :
200
+ case 'WatchEvent' :
201
+ case 'PublicEvent' :
208
202
return (
209
203
< Text
210
204
style = { styles . linkDescription }
211
- onPress = { ( ) =>
212
- this . props . navigation . navigate ( 'Repository' , {
213
- repository : {
214
- ...userEvent . repo ,
215
- name : userEvent . repo . name . substring (
216
- userEvent . repo . name . indexOf ( '/' ) + 1
217
- ) ,
218
- } ,
219
- } ) }
205
+ onPress = { ( ) => this . navigateToRepository ( userEvent ) }
220
206
>
221
207
{ userEvent . repo . name }
222
208
</ Text >
@@ -227,41 +213,19 @@ class Events extends Component {
227
213
the{ ' ' }
228
214
< Text
229
215
style = { styles . linkDescription }
230
- onPress = { ( ) =>
231
- this . props . navigation . navigate ( 'Repository' , {
232
- repository : {
233
- ...userEvent . repo ,
234
- name : userEvent . repo . name . substring (
235
- userEvent . repo . name . indexOf ( '/' ) + 1
236
- ) ,
237
- } ,
238
- } ) }
216
+ onPress = { ( ) => this . navigateToRepository ( userEvent ) }
239
217
>
240
218
{ userEvent . repo . name }
241
219
</ Text > { ' ' }
242
220
wiki
243
221
</ Text >
244
222
) ;
245
223
case 'IssueCommentEvent' :
246
- return (
247
- < Text
248
- style = { styles . linkDescription }
249
- onPress = { ( ) =>
250
- this . props . navigation . navigate ( 'Issue' , {
251
- issue : userEvent . payload . issue ,
252
- } ) }
253
- >
254
- { userEvent . payload . issue . title }
255
- </ Text >
256
- ) ;
257
224
case 'IssuesEvent' :
258
225
return (
259
226
< Text
227
+ onPress = { ( ) => this . navigateToIssue ( userEvent ) }
260
228
style = { styles . linkDescription }
261
- onPress = { ( ) =>
262
- this . props . navigation . navigate ( 'Issue' , {
263
- issue : userEvent . payload . issue ,
264
- } ) }
265
229
>
266
230
{ userEvent . payload . issue . title }
267
231
</ Text >
@@ -270,43 +234,13 @@ class Events extends Component {
270
234
return (
271
235
< Text
272
236
style = { styles . linkDescription }
273
- onPress = { ( ) =>
274
- this . props . navigation . navigate ( 'Profile' , {
275
- user : userEvent . payload . member ,
276
- } ) }
237
+ onPress = { ( ) => this . navigateToProfile ( userEvent ) }
277
238
>
278
239
{ userEvent . payload . member . login }
279
240
</ Text >
280
241
) ;
281
- case 'PublicEvent' :
282
- return (
283
- < Text
284
- style = { styles . linkDescription }
285
- onPress = { ( ) =>
286
- this . props . navigation . navigate ( 'Repository' , {
287
- repository : {
288
- ...userEvent . repo ,
289
- name : userEvent . repo . name . substring (
290
- userEvent . repo . name . indexOf ( '/' ) + 1
291
- ) ,
292
- } ,
293
- } ) }
294
- >
295
- { userEvent . repo . name }
296
- </ Text >
297
- ) ;
298
242
case 'PullRequestEvent' :
299
- return (
300
- < Text style = { styles . linkDescription } >
301
- { userEvent . payload . pull_request . title }
302
- </ Text >
303
- ) ;
304
243
case 'PullRequestReviewEvent' :
305
- return (
306
- < Text style = { styles . linkDescription } >
307
- { userEvent . payload . pull_request . title }
308
- </ Text >
309
- ) ;
310
244
case 'PullRequestReviewCommentEvent' :
311
245
return (
312
246
< Text style = { styles . linkDescription } >
@@ -327,37 +261,13 @@ class Events extends Component {
327
261
style = { styles . linkDescription }
328
262
onPress = { ( ) => {
329
263
if ( userEvent . action !== 'deleted' ) {
330
- this . props . navigation . navigate ( 'Repository' , {
331
- repository : {
332
- ...userEvent . repo ,
333
- name : userEvent . repo . name . substring (
334
- userEvent . repo . name . indexOf ( '/' ) + 1
335
- ) ,
336
- } ,
337
- } ) ;
264
+ this . navigateToRepository ( userEvent ) ;
338
265
}
339
266
} }
340
267
>
341
268
{ userEvent . repo . name }
342
269
</ Text >
343
270
) ;
344
- case 'WatchEvent' :
345
- return (
346
- < Text
347
- style = { styles . linkDescription }
348
- onPress = { ( ) =>
349
- this . props . navigation . navigate ( 'Repository' , {
350
- repository : {
351
- ...userEvent . repo ,
352
- name : userEvent . repo . name . substring (
353
- userEvent . repo . name . indexOf ( '/' ) + 1
354
- ) ,
355
- } ,
356
- } ) }
357
- >
358
- { userEvent . repo . name }
359
- </ Text >
360
- ) ;
361
271
default :
362
272
return null ;
363
273
}
@@ -377,15 +287,15 @@ class Events extends Component {
377
287
378
288
return null ;
379
289
}
380
- case 'DeleteEvent' :
381
- return 'at' ;
382
290
case 'ForkEvent' :
291
+ case 'MemberEvent' :
383
292
return 'to' ;
293
+ case 'DeleteEvent' :
384
294
case 'IssueCommentEvent' :
385
- return 'at' ;
386
295
case 'IssuesEvent' :
387
- return 'at' ;
388
296
case 'PushEvent' :
297
+ case 'PullRequestEvent' :
298
+ case 'PullRequestReviewCommentEvent' :
389
299
return 'at' ;
390
300
default :
391
301
return null ;
@@ -404,15 +314,7 @@ class Events extends Component {
404
314
return (
405
315
< Text
406
316
style = { styles . linkDescription }
407
- onPress = { ( ) =>
408
- this . props . navigation . navigate ( 'Repository' , {
409
- repository : {
410
- ...userEvent . repo ,
411
- name : userEvent . repo . name . substring (
412
- userEvent . repo . name . indexOf ( '/' ) + 1
413
- ) ,
414
- } ,
415
- } ) }
317
+ onPress = { ( ) => this . navigateToRepository ( userEvent ) }
416
318
>
417
319
{ userEvent . repo . name }
418
320
</ Text >
@@ -422,86 +324,29 @@ class Events extends Component {
422
324
return null ;
423
325
}
424
326
case 'DeleteEvent' :
425
- return (
426
- < Text
427
- style = { styles . linkDescription }
428
- onPress = { ( ) =>
429
- this . props . navigation . navigate ( 'Repository' , {
430
- repository : {
431
- ...userEvent . repo ,
432
- name : userEvent . repo . name . substring (
433
- userEvent . repo . name . indexOf ( '/' ) + 1
434
- ) ,
435
- } ,
436
- } ) }
437
- >
438
- { userEvent . repo . name }
439
- </ Text >
440
- ) ;
441
- case 'ForkEvent' :
442
- return (
443
- < Text
444
- style = { styles . linkDescription }
445
- onPress = { ( ) =>
446
- this . props . navigation . navigate ( 'Repository' , {
447
- repository : userEvent . payload . forkee ,
448
- } ) }
449
- >
450
- { userEvent . payload . forkee . full_name }
451
- </ Text >
452
- ) ;
453
327
case 'IssueCommentEvent' :
454
- return (
455
- < Text
456
- style = { styles . linkDescription }
457
- onPress = { ( ) =>
458
- this . props . navigation . navigate ( 'Repository' , {
459
- repository : {
460
- ...userEvent . repo ,
461
- name : userEvent . repo . name . substring (
462
- userEvent . repo . name . indexOf ( '/' ) + 1
463
- ) ,
464
- } ,
465
- } ) }
466
- >
467
- { userEvent . repo . name }
468
- </ Text >
469
- ) ;
470
328
case 'IssuesEvent' :
329
+ case 'PushEvent' :
330
+ case 'PullRequestEvent' :
331
+ case 'MemberEvent' :
332
+ case 'PullRequestReviewCommentEvent' :
471
333
return (
472
334
< Text
473
335
style = { styles . linkDescription }
474
- onPress = { ( ) =>
475
- this . props . navigation . navigate ( 'Repository' , {
476
- repository : {
477
- ...userEvent . repo ,
478
- name : userEvent . repo . name . substring (
479
- userEvent . repo . name . indexOf ( '/' ) + 1
480
- ) ,
481
- } ,
482
- } ) }
336
+ onPress = { ( ) => this . navigateToRepository ( userEvent ) }
483
337
>
484
338
{ userEvent . repo . name }
485
339
</ Text >
486
340
) ;
487
- case 'PushEvent ' :
341
+ case 'ForkEvent ' :
488
342
return (
489
343
< Text
490
344
style = { styles . linkDescription }
491
- onPress = { ( ) =>
492
- this . props . navigation . navigate ( 'Repository' , {
493
- repository : {
494
- ...userEvent . repo ,
495
- name : userEvent . repo . name . substring (
496
- userEvent . repo . name . indexOf ( '/' ) + 1
497
- ) ,
498
- } ,
499
- } ) }
345
+ onPress = { ( ) => this . navigateToRepository ( userEvent , true ) }
500
346
>
501
- { userEvent . repo . name }
347
+ { userEvent . payload . forkee . full_name }
502
348
</ Text >
503
349
) ;
504
-
505
350
default :
506
351
return null ;
507
352
}
@@ -554,6 +399,31 @@ class Events extends Component {
554
399
}
555
400
} ;
556
401
402
+ navigateToRepository = ( userEvent , isForkEvent ) => {
403
+ this . props . navigation . navigate ( 'Repository' , {
404
+ repository : ! isForkEvent
405
+ ? {
406
+ ...userEvent . repo ,
407
+ name : userEvent . repo . name . substring (
408
+ userEvent . repo . name . indexOf ( '/' ) + 1
409
+ ) ,
410
+ }
411
+ : userEvent . payload . forkee ,
412
+ } ) ;
413
+ }
414
+
415
+ navigateToIssue = userEvent => {
416
+ this . props . navigation . navigate ( 'Issue' , {
417
+ issue : userEvent . payload . issue ,
418
+ } ) ;
419
+ }
420
+
421
+ navigateToProfile = userEvent => {
422
+ this . props . navigation . navigate ( 'Profile' , {
423
+ user : userEvent . payload . member ,
424
+ } ) ;
425
+ }
426
+
557
427
keyExtractor = item => {
558
428
return item . id ;
559
429
} ;
@@ -563,10 +433,7 @@ class Events extends Component {
563
433
< Text style = { styles . descriptionContainer } >
564
434
< Text
565
435
style = { styles . linkDescription }
566
- onPress = { ( ) =>
567
- this . props . navigation . navigate ( 'Profile' , {
568
- user : userEvent . actor ,
569
- } ) }
436
+ onPress = { ( ) => this . navigateToProfile ( userEvent ) }
570
437
>
571
438
{ userEvent . actor . login } { ' ' }
572
439
</ Text >
0 commit comments