@@ -2,6 +2,15 @@ define(['./_module'], function (app) {
2
2
3
3
'use strict' ;
4
4
5
+ function checkErrorStatus ( error , $scope , msg ) {
6
+ if ( error . statusCode === 404 || error . statusCode === 410 ) {
7
+ // Event does not exist so we don't have to show the notification error
8
+
9
+ } else {
10
+ msg . failure ( 'Failed to load event content for stream \'' + $scope . streamId + '\': ' + error . message ) ;
11
+ }
12
+ }
13
+
5
14
return app . controller ( 'StreamsItemEventCtrl' , [
6
15
'$scope' , '$state' , '$stateParams' , 'StreamsService' , 'MessageService' ,
7
16
function ( $scope , $state , $stateParams , streamsService , msg ) {
@@ -21,28 +30,27 @@ define(['./_module'], function (app) {
21
30
// if this was a metadata, we do not need to update anything
22
31
return ;
23
32
}
33
+
34
+ if ( data . hasOwnProperty ( 'positionEventNumber' ) && data . hasOwnProperty ( 'positionStreamId' ) ) {
35
+ streamsService . eventContent ( $scope . streamId , data . positionEventNumber + 1 )
36
+ . then ( function ( ) {
37
+ $scope . next = true ;
38
+ } , function ( error ) {
39
+ checkErrorStatus ( error , $scope , msg ) ;
40
+ } ) ;
24
41
25
- streamsService . eventContent ( $scope . streamId , data . positionEventNumber + 1 )
26
- . then ( function ( ) {
27
- $scope . next = true ;
28
- } , function ( error ) {
29
- if ( error . statusCode !== 404 ) {
30
- msg . failure ( 'Failed to load event content for stream \'' + $scope . streamId + '\': ' + error . message ) ;
42
+ if ( data . positionEventNumber - 1 >= 0 ) {
43
+ streamsService . eventContent ( $scope . streamId , data . positionEventNumber - 1 )
44
+ . then ( function ( ) {
45
+ $scope . prev = true ;
46
+ } , function ( error ) {
47
+ checkErrorStatus ( error , $scope , msg ) ;
48
+ } ) ;
31
49
}
32
- } ) ;
33
-
34
- if ( data . positionEventNumber - 1 >= 0 ) {
35
- streamsService . eventContent ( $scope . streamId , data . positionEventNumber - 1 )
36
- . then ( function ( ) {
37
- $scope . prev = true ;
38
- } , function ( error ) {
39
- if ( error . statusCode !== 404 ) {
40
- msg . failure ( 'Failed to load event content for stream \'' + $scope . streamId + '\': ' + error . message ) ;
41
- }
42
- } ) ;
43
50
}
51
+
44
52
} , function ( error ) {
45
- msg . failure ( 'Failed to load event content for stream \'' + $scope . streamId + '\': ' + error . message ) ;
53
+ checkErrorStatus ( error , $scope , msg ) ;
46
54
} ) ;
47
55
}
48
56
] ) ;
0 commit comments