Skip to content

Commit

Permalink
- small update to update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
jakepurple13 committed Apr 5, 2021
1 parent ecbf31e commit 0b42de5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -104,7 +105,7 @@ object FirebaseDb {
(showUrl ?: mangaUrl).orEmpty(),
imageUrl.orEmpty(),
source.orEmpty(),
numEpisodes,
numEpisodes ?: chapterCount ?: 0,
)

private fun DbModel.toFirebaseDbModel() = FirebaseDbModel(
Expand All @@ -115,6 +116,7 @@ object FirebaseDb {
imageUrl,
source,
numChapters,
numChapters
)

private fun FirebaseChapterWatched.toChapterWatchedModel() = ChapterWatched(
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}
}

0 comments on commit 0b42de5

Please sign in to comment.