diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt index 08938b559..6e2a6ac32 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt @@ -82,7 +82,7 @@ class ShareDialog : DialogFragment() { binding.timeStamp.addTextChangedListener { binding.linkPreview.text = generateLinkText(binding, customInstanceUrl) } - binding.timeStamp.setText((shareData.currentPosition ?: 0L).toString()) + binding.timeStamp.setText((shareData.currentPosition ?: getWatchPosition(id) ?: 0L).toString()) if (binding.timeCodeSwitch.isChecked) { binding.timeStampInputLayout.isVisible = true } @@ -145,6 +145,10 @@ class ShareDialog : DialogFragment() { return url } + private fun getWatchPosition(videoId: String) = runBlocking { + Database.watchPositionDao().findById(videoId) + }?.position?.div(1000) + companion object { const val YOUTUBE_FRONTEND_URL = "https://www.youtube.com" const val YOUTUBE_SHORT_URL = "https://youtu.be"