@@ -127,9 +127,14 @@ class ReleaseReminderWorker(context: Context, workerParams: WorkerParameters) :
127127 if (dateStr == null ) continue
128128
129129 val calendarExists = showTraktId?.let { checkTraktCalendarExists(tktDb, it) } ? : false
130- val movieExists = movieId?.let { checkMovieExists(movieDb, it) } ? : false
130+ val movieTypeMatches = if (movieId != null ) {
131+ val dbMediaType = movieDb.getMediaType(movieId)
132+ dbMediaType == type
133+ } else {
134+ false
135+ }
131136
132- if (calendarExists || movieExists ) {
137+ if (calendarExists || movieTypeMatches ) {
133138 val notificationKey = buildNotificationKey(type, movieId ? : 0 , seasonNumber, episodeNumber, dateStr)
134139 if (! scheduledNotificationDbHelper.hasNotificationBeenScheduled(notificationKey)) {
135140 scheduleNotification(cursor, dateStr, notificationKey, " episode_reminder" )
@@ -177,12 +182,12 @@ class ReleaseReminderWorker(context: Context, workerParams: WorkerParameters) :
177182 ).use { it.count > 0 }
178183 }
179184
180- private fun checkMovieExists (movieDb : MovieDatabaseHelper , movieId : Int ): Boolean {
181- return movieDb.readableDatabase.rawQuery(
182- " SELECT 1 FROM ${MovieDatabaseHelper .TABLE_MOVIES } WHERE ${MovieDatabaseHelper .COLUMN_MOVIES_ID } = ?" ,
183- arrayOf(movieId.toString())
184- ).use { it.count > 0 }
185- }
185+ // private fun checkMovieExists(movieDb: MovieDatabaseHelper, movieId: Int): Boolean {
186+ // return movieDb.readableDatabase.rawQuery(
187+ // "SELECT 1 FROM ${MovieDatabaseHelper.TABLE_MOVIES} WHERE ${MovieDatabaseHelper.COLUMN_MOVIES_ID} = ?",
188+ // arrayOf(movieId.toString())
189+ // ).use { it.count > 0 }
190+ // }
186191
187192 private fun scheduleNotification (cursor : Cursor , dateStr : String , notificationKey : String , source : String ) {
188193 try {
0 commit comments