Allow users to confirm link preview on text story before it loads.

This commit is contained in:
Alex Hart
2025-11-10 11:36:54 -04:00
committed by GitHub
parent b9a999b0d0
commit 2225a14e13
7 changed files with 31 additions and 38 deletions

View File

@@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.mediasend.v2.text
import android.content.DialogInterface
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.EditText
import androidx.constraintlayout.widget.Group
@@ -64,7 +63,7 @@ class TextStoryPostLinkEntryFragment(private val shouldPreset: Boolean = false)
confirmButton.setOnClickListener {
val linkPreviewState = linkPreviewViewModel.linkPreviewState.value
if (linkPreviewState != null) {
val url = linkPreviewState.linkPreview.map { it.url }.orElseGet { linkPreviewState.activeUrlForError }
val url = linkPreviewState.url ?: ""
if (LinkUtil.isValidTextStoryPostPreview(url)) {
viewModel.setLinkPreview(url)
@@ -82,7 +81,7 @@ class TextStoryPostLinkEntryFragment(private val shouldPreset: Boolean = false)
linkPreviewViewModel.linkPreviewState.observe(viewLifecycleOwner) { state ->
linkPreview.bind(state, useLargeThumbnail = false)
shareALinkGroup.visible = !state.isLoading && !state.linkPreview.isPresent && (state.error == null && state.activeUrlForError == null)
confirmButton.isEnabled = state.linkPreview.isPresent || !TextUtils.isEmpty(state.activeUrlForError)
confirmButton.isEnabled = state.url != null
}
}