Skip to content

Commit

Permalink
[1.184.*] Pre-release merge (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
tramline-github[bot] authored Jun 3, 2024
2 parents 806060c + aedd651 commit d958995
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlinx_serialization_json = "1.6.3"
decompose = "3.0.0"
essenty = "2.0.0"
androidx_activity = "1.9.0"
androidx_appcompat = "1.6.1"
androidx_appcompat = "1.7.0"
androidx_core = "1.13.1"
androidx_collection = "1.4.0"
androidx_test_runner = "1.5.2"
Expand All @@ -41,7 +41,7 @@ okio = "3.9.0"
paging = "3.3.0-alpha02-0.5.1"
stately = "2.0.7"
xmlutil = "0.86.3"
ktxml = "0.2.3"
ktxml = "0.2.4"
uri = "0.0.18"
webview = "1.9.8"
uuid = "0.8.4"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import dev.sasikanth.rss.reader.search.ui.SearchScreen
import dev.sasikanth.rss.reader.settings.ui.SettingsScreen
import dev.sasikanth.rss.reader.share.LocalShareHandler
import dev.sasikanth.rss.reader.share.ShareHandler
import dev.sasikanth.rss.reader.util.DispatchersProvider
import dev.sasikanth.rss.reader.utils.LocalWindowSizeClass
import me.tatarka.inject.annotations.Inject

Expand All @@ -62,6 +63,7 @@ fun App(
shareHandler: ShareHandler,
linkHandler: LinkHandler,
imageLoader: ImageLoader,
dispatchersProvider: DispatchersProvider,
) {
setSingletonImageLoaderFactory { imageLoader }

Expand Down Expand Up @@ -109,7 +111,11 @@ fun App(
AboutScreen(aboutPresenter = screen.presenter, modifier = fillMaxSizeModifier)
}
is Screen.Reader -> {
ReaderScreen(presenter = screen.presenter, modifier = fillMaxSizeModifier)
ReaderScreen(
presenter = screen.presenter,
dispatchersProvider = dispatchersProvider,
modifier = fillMaxSizeModifier
)
}
is Screen.AddFeed -> {
AddFeedScreen(presenter = screen.presenter, modifier = fillMaxSizeModifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

package dev.sasikanth.rss.reader.reader.ui

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.withContext
import twine.shared.generated.resources.Res

object ReaderHTML {
Expand Down Expand Up @@ -89,6 +86,6 @@ object ReaderHTML {
}

private suspend fun readFile(fileName: String): String {
return withContext(Dispatchers.IO) { Res.readBytes("files/reader/$fileName").decodeToString() }
return Res.readBytes("files/reader/$fileName").decodeToString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ import dev.sasikanth.rss.reader.resources.icons.TwineIcons
import dev.sasikanth.rss.reader.resources.icons.Website
import dev.sasikanth.rss.reader.share.LocalShareHandler
import dev.sasikanth.rss.reader.ui.AppTheme
import dev.sasikanth.rss.reader.util.DispatchersProvider
import dev.sasikanth.rss.reader.utils.asJSString
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

@Composable
internal fun ReaderScreen(presenter: ReaderPresenter, modifier: Modifier = Modifier) {
internal fun ReaderScreen(
presenter: ReaderPresenter,
dispatchersProvider: DispatchersProvider,
modifier: Modifier = Modifier
) {
val state by presenter.state.collectAsState()
val coroutineScope = rememberCoroutineScope()
val linkHandler = LocalLinkHandler.current
Expand Down Expand Up @@ -229,25 +235,30 @@ internal fun ReaderScreen(presenter: ReaderPresenter, modifier: Modifier = Modif
}

LaunchedEffect(state.content) {
val html =
ReaderHTML.create(
title = state.title!!,
feedName = state.feed!!.name,
feedHomePageLink = state.feed!!.homepageLink,
publishedAt = state.publishedAt!!,
)
withContext(dispatchersProvider.io) {
val htmlTemplate =
ReaderHTML.create(
title = state.title!!,
feedName = state.feed!!.name,
feedHomePageLink = state.feed!!.homepageLink,
publishedAt = state.publishedAt!!,
)

navigator.loadHtml(html, state.link)
navigator.loadHtml(htmlTemplate, state.link)
}
}

LaunchedEffect(webViewState.loadingState) {
if (
webViewState.loadingState == LoadingState.Finished && !state.content.isNullOrBlank()
) {
navigator.evaluateJavaScript(
script =
"renderReaderView(${state.link.asJSString}, ${state.content.asJSString}, ${colors.asJSString})"
)
withContext(dispatchersProvider.io) {
val hasHtmlTemplateLoaded =
webViewState.loadingState == LoadingState.Finished && !state.content.isNullOrBlank()

if (hasHtmlTemplateLoaded) {
navigator.evaluateJavaScript(
script =
"renderReaderView(${state.link.asJSString}, ${state.content.asJSString}, ${colors.asJSString})"
)
}
}
}

Expand Down

0 comments on commit d958995

Please sign in to comment.