|
@@ -4,11 +4,13 @@ import android.webkit.WebView
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.setValue
|
|
|
+import androidx.core.net.toUri
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
|
import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.withContext
|
|
|
+import kotlin.random.Random
|
|
|
|
|
|
class WebViewNavigator(
|
|
|
private val coroutineScope: CoroutineScope,
|
|
@@ -40,7 +42,7 @@ class WebViewNavigator(
|
|
|
Event.Forward -> goForward()
|
|
|
Event.Reload -> reload()
|
|
|
Event.Stop -> stopLoading()
|
|
|
- is Event.LoadUrl -> loadUrl(it.url, it.additionalHttpHeaders ?: emptyMap())
|
|
|
+ is Event.LoadUrl -> loadUrl(it.url.timestamp(), it.additionalHttpHeaders ?: emptyMap())
|
|
|
else -> {}
|
|
|
}
|
|
|
}
|
|
@@ -69,4 +71,17 @@ class WebViewNavigator(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private fun String.timestamp(): String {
|
|
|
+ return try {
|
|
|
+ val uri = toUri()
|
|
|
+ val timestamp = System.currentTimeMillis()
|
|
|
+ return uri.buildUpon().apply {
|
|
|
+ appendQueryParameter("_t", timestamp.toString())
|
|
|
+ appendQueryParameter("_r", Random.nextInt(1000).toString())
|
|
|
+ }.build().toString()
|
|
|
+ } catch (e: Exception) {
|
|
|
+ this
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|