mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Add ability to explicitly remove tracking from track search dialog (closes #2532)
This commit is contained in:
parent
a288c0f280
commit
f966187ea4
2 changed files with 13 additions and 3 deletions
|
@ -91,10 +91,14 @@ class TrackPresenter(
|
|||
.subscribe({ },
|
||||
{ error -> context.toast(error.message) }))
|
||||
} else {
|
||||
db.deleteTrackForManga(manga, service).executeAsBlocking()
|
||||
unregisterTracking(service)
|
||||
}
|
||||
}
|
||||
|
||||
fun unregisterTracking(service: TrackService) {
|
||||
db.deleteTrackForManga(manga, service).executeAsBlocking()
|
||||
}
|
||||
|
||||
private fun updateRemote(track: Track, service: TrackService) {
|
||||
service.update(track)
|
||||
.flatMap { db.insertTrack(track).asRxObservable() }
|
||||
|
@ -127,4 +131,4 @@ class TrackPresenter(
|
|||
updateRemote(track, item.service)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,10 @@ class TrackSearchDialog : DialogController {
|
|||
val dialog = MaterialDialog.Builder(activity!!)
|
||||
.customView(R.layout.track_search_dialog, false)
|
||||
.positiveText(android.R.string.ok)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive { _, _ -> onPositiveButtonClick() }
|
||||
.negativeText(android.R.string.cancel)
|
||||
.neutralText(R.string.action_remove)
|
||||
.onNeutral { _, _ -> onRemoveButtonClick() }
|
||||
.build()
|
||||
|
||||
if (subscriptions.isUnsubscribed) {
|
||||
|
@ -137,6 +139,10 @@ class TrackSearchDialog : DialogController {
|
|||
trackController.presenter.registerTracking(selectedItem, service)
|
||||
}
|
||||
|
||||
private fun onRemoveButtonClick() {
|
||||
trackController.presenter.unregisterTracking(service)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val KEY_SERVICE = "service_id"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue