From 0471fd8145cf3fe9fc0082eca7bee2150ed5f24f Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sun, 29 Apr 2018 17:06:54 +0200 Subject: [PATCH] add clear orphans --- .../newpipe/settings/HistorySettingsFragment.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java index a2c3d4e57..cc1f408b7 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java @@ -19,6 +19,7 @@ import org.schabi.newpipe.util.InfoCache; import java.util.ArrayList; import java.util.Collection; +import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; @@ -74,6 +75,19 @@ public class HistorySettingsFragment extends BasePreferenceFragment { "Delete view history", R.string.general_error))); + final Disposable onClearOrphans = recordManager.removeOrphanedRecords() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + howManyDeleted -> {}, + throwable -> ErrorActivity.reportError(getContext(), + throwable, + SettingsActivity.class, null, + ErrorActivity.ErrorInfo.make( + UserAction.DELETE_FROM_HISTORY, + "none", + "Delete search history", + R.string.general_error))); + disposables.add(onClearOrphans); disposables.add(onDelete); })) .create() @@ -99,7 +113,6 @@ public class HistorySettingsFragment extends BasePreferenceFragment { "none", "Delete search history", R.string.general_error))); - disposables.add(onDelete); })) .create()