Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 9b0af671 authored by alperozturk's avatar alperozturk
Browse files

getNotesPath - java.lang.RuntimeException

parent 183b85af
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -182,10 +182,12 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
            DirectEditingRepository.getInstance(requireContext().applicationContext)
        val urlDisposable = directEditingRepository.getDirectEditingUrl(account, note)
            .observeOn(AndroidSchedulers.mainThread()).subscribe({ url ->
                url?.let {
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "loadNoteInWebView: url = $url")
                    }
                    binding.noteWebview.loadUrl(url)
                }
            }, { throwable ->
                handleLoadError()
                Log.e(TAG, "loadNoteInWebView:", throwable)
+5 −5
Original line number Diff line number Diff line
@@ -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())
            }
    }