getNotesPath - java.lang.RuntimeException

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk
2025-07-07 14:12:22 +02:00
parent 183b85af03
commit 9b0af6714b
2 changed files with 10 additions and 8 deletions

View File

@ -182,10 +182,12 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
DirectEditingRepository.getInstance(requireContext().applicationContext)
val urlDisposable = directEditingRepository.getDirectEditingUrl(account, note)
.observeOn(AndroidSchedulers.mainThread()).subscribe({ url ->
if (BuildConfig.DEBUG) {
Log.d(TAG, "loadNoteInWebView: url = $url")
url?.let {
if (BuildConfig.DEBUG) {
Log.d(TAG, "loadNoteInWebView: url = $url")
}
binding.noteWebview.loadUrl(url)
}
binding.noteWebview.loadUrl(url)
}, { throwable ->
handleLoadError()
Log.e(TAG, "loadNoteInWebView:", throwable)

View File

@ -24,19 +24,20 @@ class DirectEditingRepository private constructor(private val applicationContext
)
}
private fun getNotesPath(account: SingleSignOnAccount): Single<String> {
private fun getNotesPath(account: SingleSignOnAccount): Single<String?> {
return Single.fromCallable {
val call = notesRepository.getServerSettings(account, ApiVersion.API_VERSION_1_0)
val response = call.execute()
response.body()?.notesPath ?: throw RuntimeException("No notes path available")
response.body()?.notesPath
}.subscribeOn(Schedulers.io())
}
fun getDirectEditingUrl(
account: SingleSignOnAccount,
note: Note,
): Single<String> {
return getNotesPath(account)
): Single<String?> {
val notesPath = getNotesPath(account)
return notesPath
.flatMap { notesPath ->
val filesAPI = apiProvider.getFilesAPI(applicationContext, account)
Single.fromCallable {
@ -50,7 +51,6 @@ class DirectEditingRepository private constructor(private val applicationContext
)
val response = call.execute()
response.body()?.ocs?.data?.url
?: throw RuntimeException("No url available")
}.subscribeOn(Schedulers.io())
}
}