@@ -104,6 +104,10 @@ class MediaManager {
104
104
}
105
105
106
106
public setAllMediaUnplayed ( effect_id : string , type : MediaType ) : void {
107
+ if ( ! this . _db . exists ( this . getPathForType ( type ) ) ) {
108
+ return ;
109
+ }
110
+
107
111
// Get all media from the database
108
112
const media : Media [ ] = this . getCopy ( this . getAllMedia ( effect_id , type ) ) ;
109
113
@@ -120,19 +124,23 @@ class MediaManager {
120
124
}
121
125
122
126
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' ) ) ;
124
129
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
+ }
129
135
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' ) ) ;
131
138
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
+ }
136
144
}
137
145
138
146
public getUnplayedMedia ( effect_id : string , type : MediaType ) : Media {
0 commit comments