fix unparsed html in "replying to" toggle (#2448)

This commit is contained in:
Konrad Pozniak 2022-04-21 18:46:43 +02:00 committed by GitHub
parent 7499ff5733
commit 43709532d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -35,6 +35,7 @@ import com.keylesspalace.tusky.components.compose.ComposeActivity
import com.keylesspalace.tusky.databinding.ActivityDraftsBinding import com.keylesspalace.tusky.databinding.ActivityDraftsBinding
import com.keylesspalace.tusky.db.DraftEntity import com.keylesspalace.tusky.db.DraftEntity
import com.keylesspalace.tusky.di.ViewModelFactory import com.keylesspalace.tusky.di.ViewModelFactory
import com.keylesspalace.tusky.util.parseAsMastodonHtml
import com.keylesspalace.tusky.util.visible import com.keylesspalace.tusky.util.visible
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
@ -100,7 +101,7 @@ class DraftsActivity : BaseActivity(), DraftActionListener {
content = draft.content, content = draft.content,
contentWarning = draft.contentWarning, contentWarning = draft.contentWarning,
inReplyToId = draft.inReplyToId, inReplyToId = draft.inReplyToId,
replyingStatusContent = status.content.toString(), replyingStatusContent = status.content.parseAsMastodonHtml().toString(),
replyingStatusAuthor = status.account.localUsername, replyingStatusAuthor = status.account.localUsername,
draftAttachments = draft.attachments, draftAttachments = draft.attachments,
poll = draft.poll, poll = draft.poll,

View file

@ -97,7 +97,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
} }
override fun onReply(position: Int) { override fun onReply(position: Int) {
searchAdapter.peek(position)?.status?.let { status -> searchAdapter.peek(position)?.let { status ->
reply(status) reply(status)
} }
} }
@ -199,8 +199,8 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
fun newInstance() = SearchStatusesFragment() fun newInstance() = SearchStatusesFragment()
} }
private fun reply(status: Status) { private fun reply(status: StatusViewData.Concrete) {
val actionableStatus = status.actionableStatus val actionableStatus = status.actionable
val mentionedUsernames = actionableStatus.mentions.map { it.username } val mentionedUsernames = actionableStatus.mentions.map { it.username }
.toMutableSet() .toMutableSet()
.apply { .apply {
@ -216,7 +216,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
contentWarning = actionableStatus.spoilerText, contentWarning = actionableStatus.spoilerText,
mentionedUsernames = mentionedUsernames, mentionedUsernames = mentionedUsernames,
replyingStatusAuthor = actionableStatus.account.localUsername, replyingStatusAuthor = actionableStatus.account.localUsername,
replyingStatusContent = actionableStatus.content.toString() replyingStatusContent = status.content.toString()
) )
) )
startActivity(intent) startActivity(intent)

View file

@ -15,6 +15,8 @@
package com.keylesspalace.tusky.fragment; package com.keylesspalace.tusky.fragment;
import static com.keylesspalace.tusky.util.StatusParsingHelper.parseAsMastodonHtml;
import android.Manifest; import android.Manifest;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.ClipData; import android.content.ClipData;
@ -150,7 +152,7 @@ public abstract class SFragment extends Fragment implements Injectable {
composeOptions.setContentWarning(contentWarning); composeOptions.setContentWarning(contentWarning);
composeOptions.setMentionedUsernames(mentionedUsernames); composeOptions.setMentionedUsernames(mentionedUsernames);
composeOptions.setReplyingStatusAuthor(actionableStatus.getAccount().getLocalUsername()); composeOptions.setReplyingStatusAuthor(actionableStatus.getAccount().getLocalUsername());
composeOptions.setReplyingStatusContent(actionableStatus.getContent().toString()); composeOptions.setReplyingStatusContent(parseAsMastodonHtml(actionableStatus.getContent()).toString());
Intent intent = ComposeActivity.startIntent(getContext(), composeOptions); Intent intent = ComposeActivity.startIntent(getContext(), composeOptions);
getActivity().startActivity(intent); getActivity().startActivity(intent);