@@ -2,6 +2,15 @@ define(['./_module'], function (app) {
22
33 'use strict' ;
44
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+
514 return app . controller ( 'StreamsItemEventCtrl' , [
615 '$scope' , '$state' , '$stateParams' , 'StreamsService' , 'MessageService' ,
716 function ( $scope , $state , $stateParams , streamsService , msg ) {
@@ -21,28 +30,27 @@ define(['./_module'], function (app) {
2130 // if this was a metadata, we do not need to update anything
2231 return ;
2332 }
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+ } ) ;
2441
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+ } ) ;
3149 }
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- } ) ;
4350 }
51+
4452 } , function ( error ) {
45- msg . failure ( 'Failed to load event content for stream \'' + $scope . streamId + '\': ' + error . message ) ;
53+ checkErrorStatus ( error , $scope , msg ) ;
4654 } ) ;
4755 }
4856 ] ) ;
0 commit comments