From 0b42de5c6f0e8cecd6ad01a4cf0e660d46dec2ae Mon Sep 17 00:00:00 2001 From: jakepurple13 Date: Mon, 5 Apr 2021 15:03:07 -0400 Subject: [PATCH] - small update to update checker --- .../main/java/com/programmersbox/uiviews/UpdateChecker.kt | 3 ++- .../com/programmersbox/uiviews/utils/FirebaseUtils.kt | 8 +++++--- .../main/java/com/programmersbox/animeworld/AnimeApp.kt | 2 +- .../main/java/com/programmersbox/mangaworld/MangaApp.kt | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/UIViews/src/main/java/com/programmersbox/uiviews/UpdateChecker.kt b/UIViews/src/main/java/com/programmersbox/uiviews/UpdateChecker.kt index e9a1edff0..9137e8232 100644 --- a/UIViews/src/main/java/com/programmersbox/uiviews/UpdateChecker.kt +++ b/UIViews/src/main/java/com/programmersbox/uiviews/UpdateChecker.kt @@ -90,6 +90,7 @@ class UpdateWorker(context: Context, workerParams: WorkerParameters) : RxWorker( try { loadMarkersJob.getAndSet(methodReturningJob())?.cancel() val newData = sourceFromString(model.source)?.let { model.toItemModel(it).toInfoModel().blockingGet() } + println("Old: ${model.numChapters} New: ${newData?.chapters?.size}") if (model.numChapters >= newData?.chapters?.size ?: -1) null else Pair(newData, model) } catch (e: Exception) { @@ -166,7 +167,7 @@ class UpdateNotification(private val context: Context) { ) } showWhen = true - groupId = "showGroup" + groupId = "otakuGroup" pendingIntent { context -> NavDeepLinkBuilder(context) .setGraph(R.navigation.all_nav) diff --git a/UIViews/src/main/java/com/programmersbox/uiviews/utils/FirebaseUtils.kt b/UIViews/src/main/java/com/programmersbox/uiviews/utils/FirebaseUtils.kt index 02518173a..1464ba6f2 100644 --- a/UIViews/src/main/java/com/programmersbox/uiviews/utils/FirebaseUtils.kt +++ b/UIViews/src/main/java/com/programmersbox/uiviews/utils/FirebaseUtils.kt @@ -89,7 +89,8 @@ object FirebaseDb { val mangaUrl: String? = null, val imageUrl: String? = null, val source: String? = null, - var numEpisodes: Int = 0, + var numEpisodes: Int? = null, + var chapterCount: Int? = null ) private data class FirebaseChapterWatched( @@ -104,7 +105,7 @@ object FirebaseDb { (showUrl ?: mangaUrl).orEmpty(), imageUrl.orEmpty(), source.orEmpty(), - numEpisodes, + numEpisodes ?: chapterCount ?: 0, ) private fun DbModel.toFirebaseDbModel() = FirebaseDbModel( @@ -115,6 +116,7 @@ object FirebaseDb { imageUrl, source, numChapters, + numChapters ) private fun FirebaseChapterWatched.toChapterWatchedModel() = ChapterWatched( @@ -155,7 +157,7 @@ object FirebaseDb { fun updateShow(showDbModel: DbModel) = Completable.create { emitter -> showDoc2?.document(showDbModel.url.urlToPath()) - ?.update(CHAPTER_ID, showDbModel.numChapters) + ?.update(READ_OR_WATCHED_ID, showDbModel.numChapters) ?.addOnSuccessListener { emitter.onComplete() } ?.addOnFailureListener { emitter.onError(it) } ?: emitter.onComplete() } diff --git a/animeworld/src/main/java/com/programmersbox/animeworld/AnimeApp.kt b/animeworld/src/main/java/com/programmersbox/animeworld/AnimeApp.kt index 0bcbc39ee..b6204dffc 100644 --- a/animeworld/src/main/java/com/programmersbox/animeworld/AnimeApp.kt +++ b/animeworld/src/main/java/com/programmersbox/animeworld/AnimeApp.kt @@ -34,7 +34,7 @@ class AnimeApp : OtakuApp() { FirebaseDb.CHAPTERS_ID = "episodesWatched" FirebaseDb.COLLECTION_ID = "animeworld" FirebaseDb.ITEM_ID = "showUrl" - FirebaseDb.READ_OR_WATCHED_ID = "watched" + FirebaseDb.READ_OR_WATCHED_ID = "episodesWatched" val fetchConfiguration = FetchConfiguration.Builder(this) .enableAutoStart(true) diff --git a/mangaworld/src/main/java/com/programmersbox/mangaworld/MangaApp.kt b/mangaworld/src/main/java/com/programmersbox/mangaworld/MangaApp.kt index 861abdf5e..8a82405d2 100644 --- a/mangaworld/src/main/java/com/programmersbox/mangaworld/MangaApp.kt +++ b/mangaworld/src/main/java/com/programmersbox/mangaworld/MangaApp.kt @@ -27,7 +27,7 @@ class MangaApp : OtakuApp() { FirebaseDb.CHAPTERS_ID = "chaptersRead" FirebaseDb.COLLECTION_ID = "mangaworld" FirebaseDb.ITEM_ID = "mangaUrl" - FirebaseDb.READ_OR_WATCHED_ID = "chapters" + FirebaseDb.READ_OR_WATCHED_ID = "chapterCount" } } \ No newline at end of file