Skip to content

Commit

Permalink
Update SyncWorker.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
amberin authored May 18, 2024
1 parent d4181d1 commit bfa2271
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions app/src/main/java/com/orgzly/android/sync/SyncWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,7 @@ class SyncWorker(val context: Context, val params: WorkerParameters) :
}

if (msg != null) {
if (isSingleRookDeleted(dataRepository)) {
val book = dataRepository.getBooksWithError()[0]
val activity = App.getCurrentActivity()
if (activity == null) {
SyncNotifications.showRookDeletedNotification(
context,
book)
} else {
val fragment = RookDeletedDialogFragment.newInstance(book.id)
fragment.show(
App.getCurrentActivity().supportFragmentManager,
RookDeletedDialogFragment.FRAGMENT_TAG
)
}
} else {
SyncNotifications.showSyncFailedNotification(context, msg)
}
SyncNotifications.showSyncFailedNotification(context, msg)
}
}
}
Expand Down Expand Up @@ -146,14 +130,6 @@ class SyncWorker(val context: Context, val params: WorkerParameters) :
return sb.toString().trim().ifEmpty { null }
}

private fun isSingleRookDeleted(dataRepository: DataRepository): Boolean {
val books = dataRepository.getBooksWithError()
if (books.size == 1 && books[0].syncStatus.equals(BookSyncStatus.SYNCED_ROOK_NO_LONGER_EXISTS.toString())) {
return true
}
return false
}

private fun checkConditions(): SyncState? {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG)

Expand Down

0 comments on commit bfa2271

Please sign in to comment.