Clean up Scheduling Code

Update documentation, remove deprecated and unused code, and clean up formatting.
This commit is contained in:
Inhishonor
2025-07-08 16:26:03 -07:00
parent e8c92a1422
commit 56a767bbd7
8 changed files with 41 additions and 33 deletions
@@ -8,6 +8,7 @@ import io.reactivex.schedulers.Schedulers
import io.realm.Realm
import io.realm.RealmList
import io.realm.RealmResults
import timber.log.Timber
import javax.inject.Inject
class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRepository {
@@ -71,12 +72,12 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
realm.executeTransaction { message?.deleteFromRealm() }
}
}.subscribeOn(Schedulers.io()) // Perform the operation in a background thread
.observeOn(AndroidSchedulers.mainThread()) // Switch back to the main thread if needed
}.subscribeOn(Schedulers.io()) // Run on a background thread and switch to main if needed
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
// Handle completion, e.g., log success or update UI
Timber.v("Successfully deleted scheduled messages.")
}, {
// Handle error, e.g., log or show error message
Timber.e("Deleting scheduled messages failed.")
})
disposables.add(subscription)
@@ -96,9 +97,4 @@ class ScheduledMessageRepositoryImpl @Inject constructor() : ScheduledMessageRep
.map { it.id }
}
}
// Ensure to clear disposables when the repository is no longer needed
fun clearDisposables() {
disposables.clear()
}
}