@@ -104,6 +104,10 @@ class MediaManager {
104104 }
105105
106106 public setAllMediaUnplayed ( effect_id : string , type : MediaType ) : void {
107+ if ( ! this . _db . exists ( this . getPathForType ( type ) ) ) {
108+ return ;
109+ }
110+
107111 // Get all media from the database
108112 const media : Media [ ] = this . getCopy ( this . getAllMedia ( effect_id , type ) ) ;
109113
@@ -120,19 +124,23 @@ class MediaManager {
120124 }
121125
122126 public setAllEffectsUnplayed ( ) : void {
123- const videoEffects : Record < string , Media [ ] > = this . _db . getData ( this . getPathForType ( 'VIDEO' ) ) ;
127+ if ( this . _db . exists ( this . getPathForType ( 'VIDEO' ) ) ) {
128+ const videoEffects : Record < string , Media [ ] > = this . _db . getData ( this . getPathForType ( 'VIDEO' ) ) ;
124129
125- Object . values ( videoEffects ) . forEach ( medias => {
126- medias . forEach ( media => media . played = false ) ;
127- } ) ;
128- this . _db . push ( this . getPathForType ( 'VIDEO' ) , videoEffects , true ) ;
130+ Object . values ( videoEffects ) . forEach ( medias => {
131+ medias . forEach ( media => media . played = false ) ;
132+ } ) ;
133+ this . _db . push ( this . getPathForType ( 'VIDEO' ) , videoEffects , true ) ;
134+ }
129135
130- const audioEffects : Record < string , Media [ ] > = this . _db . getData ( this . getPathForType ( 'AUDIO' ) ) ;
136+ if ( this . _db . exists ( this . getPathForType ( 'AUDIO' ) ) ) {
137+ const audioEffects : Record < string , Media [ ] > = this . _db . getData ( this . getPathForType ( 'AUDIO' ) ) ;
131138
132- Object . values ( audioEffects ) . forEach ( medias => {
133- medias . forEach ( media => media . played = false ) ;
134- } ) ;
135- this . _db . push ( this . getPathForType ( 'AUDIO' ) , audioEffects , true ) ;
139+ Object . values ( audioEffects ) . forEach ( medias => {
140+ medias . forEach ( media => media . played = false ) ;
141+ } ) ;
142+ this . _db . push ( this . getPathForType ( 'AUDIO' ) , audioEffects , true ) ;
143+ }
136144 }
137145
138146 public getUnplayedMedia ( effect_id : string , type : MediaType ) : Media {
0 commit comments